From 88fa42928cdc0e22c03a024ab91857efe1a092d3 Mon Sep 17 00:00:00 2001 From: Rhythm Chopra Date: Sun, 1 Sep 2019 22:17:10 +0300 Subject: [PATCH] Add `sudo` provisioner before `chef-solo` To disable `sudo` password prompt from building user --- packer/templates/ubuntu_1404.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packer/templates/ubuntu_1404.json b/packer/templates/ubuntu_1404.json index d8cfeb12..b9149a8e 100644 --- a/packer/templates/ubuntu_1404.json +++ b/packer/templates/ubuntu_1404.json @@ -64,7 +64,9 @@ "ssh_username": "vagrant", "ssh_password": "vagrant", "ssh_wait_timeout": "2h", - "shutdown_command": "echo 'packer' | sudo -S shutdown -P now", + "ssh_pty": true, + "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now", + "shutdown_timeout": "10m", "guest_os_type": "Ubuntu_64", "disk_size": 40000, "vm_name": "metasploitable3-ub1404", @@ -121,6 +123,12 @@ } ], "provisioners": [ + { + "type": "shell", + "inline": [ + "echo 'Disabling sudo password for the user...'", + "echo 'vagrant' | sudo -S bash -c 'echo \"vagrant ALL=(ALL) NOPASSWD:ALL\" >> /etc/sudoers'"] + }, { "type": "chef-solo", "version": "13.8.5",