forked from ruzickap/packer-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_ubuntu-server.json
144 lines (141 loc) · 4.82 KB
/
my_ubuntu-server.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
{
"_comment": "NAME=my_ubuntu-18.04-server-amd64 UBUNTU_CODENAME=bionic PACKER_IMAGES_OUTPUT_DIR=/var/tmp/ packer build my_ubuntu-server.json",
"_comment": "NAME=my_ubuntu-16.04-server-amd64 UBUNTU_CODENAME=xenial PACKER_IMAGES_OUTPUT_DIR=/var/tmp/ packer build my_ubuntu-server.json",
"_comment": "NAME=my_ubuntu-14.04-server-amd64 UBUNTU_CODENAME=trusty PACKER_IMAGES_OUTPUT_DIR=/var/tmp/ packer build my_ubuntu-server.json",
"variables": {
"name": "{{ env `NAME` }}",
"packer_images_output_dir": "{{ env `PACKER_IMAGES_OUTPUT_DIR` }}",
"cpus": "2",
"memory": "4096",
"ubuntu_codename": "{{ env `UBUNTU_CODENAME` }}",
"ubuntu_mirror": "http://archive.ubuntu.com/ubuntu/dists/",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"preseed_file_name": "my-preseed.cfg",
"disk_size": "51200",
"headless": "false"
},
"builders":
[
{
"vm_name": "{{ user `name` }}",
"type": "qemu",
"iso_checksum_type": "sha256",
"iso_checksum_url": "{{ user `ubuntu_mirror` }}{{ user `ubuntu_codename` }}-updates/main/installer-amd64/current/images/SHA256SUMS",
"iso_urls": [ "{{ user `ubuntu_mirror` }}{{ user `ubuntu_codename` }}-updates/main/installer-amd64/current/images/netboot/mini.iso" ],
"ssh_username": "{{ user `ssh_username` }}",
"ssh_password": "{{ user `ssh_password` }}",
"ssh_wait_timeout": "60m",
"accelerator": "kvm",
"headless": "{{ user `headless` }}",
"output_directory": "{{ user `name` }}-qemu",
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
"accelerator": "kvm",
"qemuargs": [
[ "-m", "{{ user `memory` }}" ],
[ "-smp", "{{ user `cpus` }}" ]
],
"boot_wait": "5s",
"boot_command":
[
"<tab>",
"url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu-server/{{ user `preseed_file_name` }} ",
"auto=true ",
"net.ifnames=0 ",
"hostname=localhost ",
"<enter>"
],
"disk_size": "{{ user `disk_size` }}",
"http_directory": "http"
},
{
"vm_name": "{{ user `name` }}",
"type": "virtualbox-iso",
"guest_os_type": "Ubuntu_64",
"iso_checksum_type": "sha256",
"iso_checksum_url": "{{ user `ubuntu_mirror` }}{{ user `ubuntu_codename` }}-updates/main/installer-amd64/current/images/SHA256SUMS",
"iso_urls": [ "{{ user `ubuntu_mirror` }}{{ user `ubuntu_codename` }}-updates/main/installer-amd64/current/images/netboot/mini.iso" ],
"ssh_username": "{{ user `ssh_username` }}",
"ssh_password": "{{ user `ssh_password` }}",
"ssh_wait_timeout": "60m",
"headless": "{{ user `headless` }}",
"output_directory": "{{ user `name` }}-virtualbox-iso",
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
"hard_drive_interface": "sata",
"disk_size": "{{ user `disk_size` }}",
"vboxmanage": [
[
"modifyvm",
"{{ .Name }}",
"--cpus",
"{{ user `cpus` }}"
],
[
"modifyvm",
"{{ .Name }}",
"--memory",
"{{ user `memory` }}"
],
[
"modifyvm",
"{{ .Name }}",
"--audiocontroller",
"hda"
]
],
"boot_wait": "5s",
"boot_command":
[
"<tab>",
"url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu-server/{{ user `preseed_file_name` }} ",
"auto=true ",
"net.ifnames=0 ",
"hostname=localhost ",
"<enter>"
],
"http_directory": "http"
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -S -E bash -x '{{ .Path }}'",
"scripts": [
"scripts/ubuntu/update.sh",
"scripts/ubuntu/add_libpam-systemd.sh",
"scripts/ubuntu/disable_apt-daily.sh",
"scripts/ubuntu/virtualbox-guest.sh",
"scripts/linux-common/vagrant.sh"
]
},
{
"type": "shell",
"environment_vars": [ "DEBIAN_FRONTEND=noninteractive" ],
"inline": [ "sudo -E apt-get install -y aptitude python > /dev/null" ]
},
{
"type": "ansible",
"user": "vagrant",
"ansible_env_vars": [ "ANSIBLE_CONFIG=ansible/ansible.cfg" ],
"extra_arguments": [ "--become", "--extra-vars", "packer_build_name={{ user `name` }}" ],
"playbook_file": "ansible/site.yml"
},
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -S -E bash -x '{{ .Path }}'",
"scripts": [
"scripts/linux-common/cleanup.sh"
]
}
],
"post-processors": [
[
{
"type": "vagrant",
"compression_level": 9,
"vagrantfile_template": "Vagrantfile-linux.template",
"output": "{{ user `packer_images_output_dir` }}/{{ user `name` }}-{{ .Provider }}.box"
}
]
]
}