This repository has been archived by the owner on Nov 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
packer-debian9-qemu-kvm.json
101 lines (99 loc) · 3.94 KB
/
packer-debian9-qemu-kvm.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
{
"variables": {
"ansible_roles_path": "./ansible/roles",
"build_id": "{{isotime \"20060102150405\"}}",
"build_ref": "{{env `BUILD_REF`}}",
"build_name": "packer-debian9-qemu-kvm",
"disk_size": "10240",
"iso_checksum": "87368242b8332a9ae6ddf48c5265c6618cbbca0497ced6ab1c05c674ac7a7f6aac2adff0534e65976b7d8bfddf4e4e87046190b01f61fecf8a9d75ca49cc7cdf",
"iso_checksum_type": "sha512",
"iso_name": "debian-9.7.0-amd64-netinst.iso",
"local_domain": "lan.mydomain.com",
"local_mirror_url": "http://localhost",
"output_dir": "output",
"dynamic_mirror_url": "http://debian-cd.debian.net/debian-cd/9.7.0/amd64/iso-cd",
"remote_mirror_url": "https://cdimage.debian.org/debian-cd/9.7.0/amd64/iso-cd"
},
"builders": [
{
"accelerator": "kvm",
"boot_command": [
"<esc><wait>",
"auto <wait>",
"console-keymaps-at/keymap=us <wait>",
"console-setup/ask_detect=false <wait>",
"debconf/frontend=noninteractive <wait>",
"debian-installer=en_US <wait>",
"fb=false <wait>",
"install <wait>",
"kbd-chooser/method=us <wait>",
"keyboard-configuration/xkb-keymap=us <wait>",
"locale=en_US <wait>",
"netcfg/get_domain={{ user `local_domain` }} <wait>",
"netcfg/get_hostname={{ .Name }} <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg <wait>",
"<enter><wait>"
],
"boot_wait": "5s",
"disk_size": "{{ user `disk_size` }}",
"format": "qcow2",
"headless": true,
"http_directory": "http",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_urls": [
"{{ user `local_mirror_url` }}/{{ user `iso_name` }}",
"{{ user `dynamic_mirror_url` }}/{{ user `iso_name` }}",
"{{ user `remote_mirror_url` }}/{{ user `iso_name` }}"
],
"output_directory": "{{ user `output_dir` }}/{{ user `build_name` }}-qemu-{{ user `build_id` }}",
"qemuargs": [
[ "-m", "1024M" ]
],
"shutdown_command": "sudo /sbin/halt -h -p",
"ssh_password": "root",
"ssh_port": 22,
"ssh_username": "root",
"ssh_wait_timeout": "1800s",
"type": "qemu",
"vm_name": "{{ user `build_name` }}-{{ user `build_ref` }}-{{ user `build_id` }}"
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "{{.Vars}} bash '{{.Path}}'",
"inline": [
"sleep 15",
"DEBIAN_FRONTEND=noninteractive apt-get -y update",
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" dist-upgrade",
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" install build-essential python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev zlib1g-dev",
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" --purge remove python-cffi",
"wget https://bootstrap.pypa.io/get-pip.py -O /usr/local/bin/get-pip.py",
"chmod +x /usr/local/bin/get-pip.py",
"python /usr/local/bin/get-pip.py",
"pip install ansible==2.4.2"
]
},
{
"type": "ansible-local",
"group_vars": "ansible/inventory/group_vars",
"playbook_dir": "ansible",
"playbook_file": "ansible/playbook.yml",
"role_paths": [
"{{ user `ansible_roles_path` }}/serial-console"
]
},
{
"type": "shell",
"execute_command": "{{.Vars}} bash '{{.Path}}'",
"inline": [
"pip uninstall -y ansible httplib2 Jinja2 paramiko PyYAML six",
"apt-get -y purge python-dev python-pip libffi-dev libssl-dev libxml2-dev libxslt1-dev zlib1g-dev",
"apt-get -y autoremove --purge",
"apt-get -y clean",
"rm -rf /tmp ; mkdir /tmp ; chmod 1777 /tmp"
]
}
]
}