How can I just simple install apache2 package in a packer template for virtualbox-iso Ubuntu and the shell inline provisionning ?
I'm testing this template :
{
"builders": [{
"boot_command": [
"<esc><wait>",
"<esc><wait>",
"<enter><wait>",
"/install/vmlinuz<wait>",
" auto<wait>",
" console-setup/ask_detect=false<wait>",
" console-setup/layoutcode=fr<wait>",
" console-setup/modelcode=pc105<wait>",
" debconf/frontend=noninteractive<wait>",
" debian-installer=fr_FR<wait>",
" fb=false<wait>",
" initrd=/install/initrd.gz<wait>",
" kbd-chooser/method=fr<wait>",
" keyboard-configuration/layout=fr<wait>",
" keyboard-configuration/variant=fr<wait>",
" locale=fr_FR<wait>",
" netcfg/get_domain=vm<wait>",
" netcfg/get_hostname=vagrant<wait>",
" noapic<wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
" -- <wait>",
"<enter><wait>"
],
"boot_wait": "20s",
"disk_size": 20480,
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"guest_os_type": "Ubuntu_64",
"http_directory": "http",
"headless": false,
"iso_checksum": "0501c446929f713eb162ae2088d8dc8b6426224a",
"iso_checksum_type": "sha1",
"iso_url": "http://mirrors.mit.edu/ubuntu-releases/trusty/ubuntu-14.04.3-server-amd64.iso",
"output_directory": "packer-ubuntu-14.04-amd64-virtualbox",
"shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"type": "virtualbox-iso",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"1024"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"1"
]
],
"virtualbox_version_file": ".vbox_version",
"vm_name": "packer-ubuntu-14.04-amd64"
}],
"post-processors": [{
"output": "builds/ubuntu-14.04.box",
"type": "vagrant"
}],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"inline": [
"echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers",
"sudo apt-get install -y apache2"
]
}
]
}
This result of test provisionning is :
==> virtualbox-iso: Provisioning with shell script: C:\Users\toto\AppData\Local\Temp\packer-shell178737243
virtualbox-iso: [sudo] password for vagrant: Sorry, try again.
virtualbox-iso: [sudo] password for vagrant:
virtualbox-iso: sudo: 1 incorrect password attempt
The first step of building Vagrant seem to be good with preseed.cfg file. But this issue arrived when start the provisionning vagrant.
What is the trick for use a inline provisionning with good right for administration in packer and vagrant system Ubuntu ?
technical context
- OS Host : windows 7 pro
- OS Guest : Ubuntu 14.04 LTS
- VM technology : VirtualBox 5.0.10 + Vagrant 1.7.4
- VM tools builder : Packer 0.8.6
PS : My template is validated by packer validate