Question

I do have an Ubuntu Server 12.04 VM using VMWare Fusion that i would like to provision with a set of Jenkins Steps.

So far i have the server VM with the following packages by default when installing the OS.

  1. default-java (This is the OpenJDK for Jenkins Slave)
  2. openssh-server (for communication with my clients)

I would like to make the following changes to this VM template so i can use it later for any purpose.

  1. Change the hostname/hosts configuration (needs a reboot)
  2. run package installations if necessary (git-core)
  3. Install a puppet master server.

I do have a problem when trying to execute commands since ubuntu does not have the root account.

+ sudo hostname ubuntu
sudo: no tty present and no askpass program specified
Build step 'Execute shell' marked build as failure
Finished: FAILURE

I did try changing the sudoers NOPASSWD configuration for the sudo group members with luck only if i log in to the VM but not with jenkins even when the jenkins user is the only user in the system that is a member of the sudo group.

I would say having and image with a specific OS should be enough but i am guessing in this scenario need the jenkins slave in place to start managing the VM. I am not using Vagrant since is super slow on the MAC and VM Ware Fusion is super fast even than parallels.

Any clues?

Was it helpful?

Solution

First create an shell script that will act as your askpass program. It needs to output the password when executed. e.g., if your password is mycleverpassword then the following script will do the trick:

#! /bin/sh
echo mycleverpassword

Then, instead of calling sudo hostname ubuntu, you would call

export SUDO_ASKPASS="/path/to/myaskpass.sh"; sudo -A hostname ubuntu

Lemme know if pain persists.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top