Hi,
I'm struggling with a packer build for a long time now. So I'm trying to 
build Ubuntu 1404 server image with Packer using chef provisioner. 
Initially build was getting stuck at the following command after installing 
chef successfully,

> 2019/08/31 17:36:04 ui: ==> virtualbox-iso: Provisioning with chef-solo
> 2019/08/31 17:36:04 ui:     virtualbox-iso: Installing Chef...
> 2019/08/31 17:36:04 packer: 2019/08/31 17:36:04 opening new ssh session
> 2019/08/31 17:36:04 packer: 2019/08/31 17:36:04 starting remote command: 
> curl -L https://omnitruck.chef.io/install.sh | { echo 'qwerty'; cat -; } | 
> sudo -S bash -s -- -v 13.8.5
> 2019/08/31 17:36:04 ui:     virtualbox-iso: % Total    % Received % Xferd  
> Average Speed   Time    Time     Time  Current
> 2019/08/31 17:36:04 ui:     virtualbox-iso: Dload  Upload   Total   
> Spent    Left  Speed
> 2019/08/31 17:36:04 ui:     virtualbox-iso: 0     0    0     0    0     
> 0      0      0 --:--:-- --:--:-- --:--:--     0[sudo] password for 
> metasploitable3: no talloc stackframe at ../source3/param/loadparm.c:4864, 
> leaking memory
> 2019/08/31 17:36:04 ui:     virtualbox-iso: 100 23103  100 23103    0     
> 0   166k      0 --:--:-- --:--:-- --:--:--  167k
> 2019/08/31 17:36:04 ui:     virtualbox-iso: ubuntu 14.04 x86_64
> 2019/08/31 17:36:04 ui:     virtualbox-iso: Getting information for chef 
> stable 13.8.5 for ubuntu...
> 2019/08/31 17:36:04 ui:     virtualbox-iso: downloading 
> https://omnitruck.chef.io/stable/chef/metadata?v=13.8.5&p=ubuntu&pv=14.04&m=x86_64
> 2019/08/31 17:36:04 ui:     virtualbox-iso: to file 
> /tmp/install.sh.1749/metadata.txt
> 2019/08/31 17:36:04 ui:     virtualbox-iso: trying wget...
> 2019/08/31 17:36:04 ui:     virtualbox-iso: sha1    
> 1ecb70effcf557dbac0d0de528bbef6937f9c581
> 2019/08/31 17:36:04 ui:     virtualbox-iso: sha256    
> ce0ff3baf39c8c13ed474104928e7e4568a4997a1d5797cae2b2ba3ee001e3a8
> 2019/08/31 17:36:04 ui:     virtualbox-iso: url    
> https://packages.chef.io/files/stable/chef/13.8.5/ubuntu/14.04/chef_13.8.5-1_amd64.deb
> 2019/08/31 17:36:04 ui:     virtualbox-iso: version    13.8.5
> 2019/08/31 17:36:04 ui:     virtualbox-iso: downloaded metadata file looks 
> valid...
> 2019/08/31 17:36:04 ui:     virtualbox-iso: downloading 
> https://packages.chef.io/files/stable/chef/13.8.5/ubuntu/14.04/chef_13.8.5-1_amd64.deb
> 2019/08/31 17:36:04 ui:     virtualbox-iso: to file 
> /tmp/install.sh.1749/chef_13.8.5-1_amd64.deb
> 2019/08/31 17:36:04 ui:     virtualbox-iso: trying wget...
> 2019/08/31 17:36:45 ui:     virtualbox-iso: Comparing checksum with 
> sha256sum...
> 2019/08/31 17:36:46 ui:     virtualbox-iso: Installing chef 13.8.5
> 2019/08/31 17:36:46 ui:     virtualbox-iso: installing with dpkg...
> 2019/08/31 17:36:46 ui:     virtualbox-iso: Selecting previously 
> unselected package chef.
> 2019/08/31 17:36:46 ui:     virtualbox-iso: (Reading database ... 68348 
> files and directories currently installed.)
> 2019/08/31 17:36:46 ui:     virtualbox-iso: Preparing to unpack 
> .../chef_13.8.5-1_amd64.deb ...
> 2019/08/31 17:36:46 ui:     virtualbox-iso: Unpacking chef (13.8.5-1) ...
> 2019/08/31 17:36:52 ui:     virtualbox-iso: Setting up chef (13.8.5-1) ...
> 2019/08/31 17:36:52 ui:     virtualbox-iso: Thank you for installing Chef!
> 2019/08/31 17:36:52 packer: 2019/08/31 17:36:52 [INFO] RPC endpoint: 
> Communicator ended with: 0
> 2019/08/31 17:36:52 [INFO] 0 bytes written for 'stderr'
> 2019/08/31 17:36:52 [INFO] 2006 bytes written for 'stdout'
> 2019/08/31 17:36:52 [INFO] RPC client: Communicator ended with: 0
> 2019/08/31 17:36:52 [INFO] RPC endpoint: Communicator ended with: 0
> 2019/08/31 17:36:52 packer: 2019/08/31 17:36:52 [INFO] 2006 bytes written 
> for 'stdout'
> 2019/08/31 17:36:52 packer: 2019/08/31 17:36:52 [INFO] 0 bytes written for 
> 'stderr'
> 2019/08/31 17:36:52 packer: 2019/08/31 17:36:52 [INFO] RPC client: 
> Communicator ended with: 0
> 2019/08/31 17:36:52 ui:     virtualbox-iso: Creating directory: 
> /tmp/packer-chef-solo
> 2019/08/31 17:36:52 packer: 2019/08/31 17:36:52 opening new ssh session
> 2019/08/31 17:36:52 packer: 2019/08/31 17:36:52 starting remote command: 
> mkdir -p '/tmp/packer-chef-solo'
>
>
Looks like it was waiting for password because `sudo` was being used. So I 
added the flag 
prevent_sudo= true

Now, the above steps completed properly, but later my build fails at 

> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 opening new ssh session
> 2019/08/31 17:36:53 [INFO] 58 bytes written for 'uploadData'
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 Starting remote scp 
> process:  scp -vt /tmp/packer-chef-solo
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 Started SCP session, 
> beginning transfers...
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 Copying input data into 
> temporary file so we can read the length
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 [DEBUG] scp: Uploading 
> solo.rb: perms=C0644 size=58
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 SCP session complete, 
> closing stdin pipe.
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 Waiting for SSH session to 
> complete.
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 scp stderr (length 23): 
> Sink: C0644 58 solo.rb
> 2019/08/31 17:36:53 ui:     virtualbox-iso: Creating JSON attribute file
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 [INFO] 619 bytes written 
> for 'uploadData'
> 2019/08/31 17:36:53 [INFO] 619 bytes written for 'uploadData'
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 opening new ssh session
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 Starting remote scp 
> process:  scp -vt /tmp/packer-chef-solo
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 Started SCP session, 
> beginning transfers...
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 Copying input data into 
> temporary file so we can read the length
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 [DEBUG] scp: Uploading 
> node.json: perms=C0644 size=619
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 SCP session complete, 
> closing stdin pipe.
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 Waiting for SSH session to 
> complete.
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 scp stderr (length 26): 
> Sink: C0644 619 node.json
> 2019/08/31 17:36:53 ui:     virtualbox-iso: Executing Chef: chef-solo 
> --no-color -c /tmp/packer-chef-solo/solo.rb -j 
> /tmp/packer-chef-solo/node.json
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 opening new ssh session
> 2019/08/31 17:36:53 packer: 2019/08/31 17:36:53 starting remote command: 
> chef-solo --no-color -c /tmp/packer-chef-solo/solo.rb -j 
> /tmp/packer-chef-solo/node.json
> 2019/08/31 17:36:54 ui:     virtualbox-iso: Starting Chef Client, version 
> 13.8.5
> 2019/08/31 17:36:56 ui:     virtualbox-iso: resolving cookbooks for run 
> list: ["metasploitable::users", "metasploitable::mysql", 
> "metasploitable::apache_continuum", "metasploitable::apache", 
> "metasploitable::php_545", "metasploitable::phpmyadmin", 
> "metasploitable::proftpd", "metasploitable::docker", 
> "metasploitable::samba", "metasploitable::sinatra", 
> "metasploitable::unrealircd", "metasploitable::chatbot", 
> "metasploitable::payroll_app", "metasploitable::readme_app", 
> "metasploitable::cups", "metasploitable::drupal", "metasploitable::knockd", 
> "metasploitable::iptables", "metasploitable::flags"]
> 2019/08/31 17:36:57 ui:     virtualbox-iso: Synchronizing Cookbooks:
> 2019/08/31 17:36:57 ui:     virtualbox-iso: - metasploitable (0.1.0)
> 2019/08/31 17:36:57 ui:     virtualbox-iso: - docker (4.9.2)
> 2019/08/31 17:36:57 ui:     virtualbox-iso: - mysql (8.2.0)
> 2019/08/31 17:36:57 ui:     virtualbox-iso: Installing Cookbook Gems:
> 2019/08/31 17:37:14 ui:     virtualbox-iso:
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Running handlers:
> 2019/08/31 17:37:14 ui:     virtualbox-iso: [2019-08-31T17:37:19+03:00] 
> ERROR: Running exception handlers
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Running handlers complete
> 2019/08/31 17:37:14 ui:     virtualbox-iso: [2019-08-31T17:37:19+03:00] 
> ERROR: Exception handlers complete
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Chef Client failed. 0 
> resources updated in 20 seconds
> 2019/08/31 17:37:14 ui:     virtualbox-iso: [2019-08-31T17:37:19+03:00] 
> FATAL: Stacktrace dumped to 
> /tmp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
> 2019/08/31 17:37:14 ui:     virtualbox-iso: [2019-08-31T17:37:19+03:00] 
> FATAL: Please provide the contents of the stacktrace.out file if you file a 
> bug report
> 2019/08/31 17:37:14 ui:     virtualbox-iso: [2019-08-31T17:37:19+03:00] 
> ERROR: Expected process to exit with [0], but received '5'
> 2019/08/31 17:37:14 ui:     virtualbox-iso: ---- Begin output of bundle 
> install ----
> 2019/08/31 17:37:14 ui:     virtualbox-iso: STDOUT: Fetching gem metadata 
> from https://www.rubygems.org/..............
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Fetching version metadata from 
> https://www.rubygems.org/.
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Resolving dependencies...
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Using bundler 1.15.4
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Fetching excon 0.66.0
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Using multi_json 1.13.1
> 2019/08/31 17:37:14 ui:     virtualbox-iso: 
> Bundler::SudoNotPermittedError: Bundler requires sudo access to install at 
> the
> 2019/08/31 17:37:14 ui:     virtualbox-iso: moment. Try installing again, 
> granting Bundler sudo access when prompted, or
> 2019/08/31 17:37:14 ui:     virtualbox-iso: installing into a different 
> path.
> 2019/08/31 17:37:14 ui:     virtualbox-iso: An error occurred while 
> installing excon (0.66.0), and Bundler cannot continue.
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Make sure that `gem install 
> excon -v '0.66.0'` succeeds before bundling.
> 2019/08/31 17:37:14 ui:     virtualbox-iso:
> 2019/08/31 17:37:14 ui:     virtualbox-iso: In Gemfile:
> 2019/08/31 17:37:14 ui:     virtualbox-iso: docker-api was resolved to 
> 1.34.2, which depends on
> 2019/08/31 17:37:14 ui:     virtualbox-iso: excon
> 2019/08/31 17:37:14 ui:     virtualbox-iso: STDERR: sudo: no tty present 
> and no askpass program specified
> 2019/08/31 17:37:14 ui:     virtualbox-iso: ---- End output of bundle 
> install ----
> 2019/08/31 17:37:14 ui:     virtualbox-iso: Ran bundle install returned 5
> 2019/08/31 17:37:14 ui:     virtualbox-iso: [2019-08-31T17:37:19+03:00] 
> FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited 
> unsuccessfully (exit code 1)
>
>
Now, I can't understand how to get around it. Because this is expecting 
sudo, whereas I had to disable it to get past the previous block call.

Please suggest.

Thanks,
Rhythm

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/41baa57c-419c-4764-9a0b-bb261b0810e0%40googlegroups.com.

Reply via email to