This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.pkr.hcl
103 lines (85 loc) · 3.35 KB
/
build.pkr.hcl
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
build {
sources = [
"linode.main",
"vagrant.main",
]
provisioner "shell" {
# Ensure sudo for subsequent build steps. If no sudo and not
# logging in as root, we're screwed anyway. Fail out.
inline = [
"if [ `id -u` -eq 1 ]; then apt-get update && apt-get install -y sudo; fi",
]
}
provisioner "shell" {
scripts = [
"${path.root}/scripts/ansible-prep.sh",
]
execute_command = "chmod +x {{ .Path }}; sudo env {{ .Vars }} sh -c {{ .Path }}"
}
provisioner "ansible" {
# Wrap commands in a venv, install it during the run,
# and set relevant environment variables
command = "${path.root}/ansible/bin/call-ansible-playbook.sh"
galaxy_command = "${path.root}/ansible/bin/call-ansible-galaxy.sh"
skip_version_check = true
# Because CentOS:
# sftp_command = "/usr/libexec/openssh/sftp-server -e"
extra_arguments = [
"--extra-vars", "bot_username=${var.ssh_username} ssh_port=${var.ssh_port} ansible_python_interpreter=/usr/bin/python3",
]
# Setting these should fix some of the (false alarm) warnings
ansible_env_vars = [
"ANSIBLE_HOST_KEY_CHECKING=False",
"ANSIBLE_COLLECTIONS_PATH=${path.root}/ansible/collections",
"ANSIBLE_ROLES_PATH=${path.root}/ansible/roles",
]
groups = ["packer"]
# Paths to files and locations
playbook_file = "${path.root}/ansible/site.yml"
galaxy_file = "${path.root}/ansible/requirements.yml"
roles_path = "${path.root}/ansible/roles"
collections_path = "${path.root}/ansible/collections"
inventory_directory = "${path.root}/ansible"
}
provisioner "ansible" {
# Wrap commands in a venv, install it during the run,
# and set relevant environment variables
command = "${path.root}/ansible/bin/call-ansible-playbook.sh"
galaxy_command = "${path.root}/ansible/bin/call-ansible-galaxy.sh"
skip_version_check = true
# Because CentOS:
# sftp_command = "/usr/libexec/openssh/sftp-server -e"
extra_arguments = [
"--extra-vars", "bot_username=${var.ssh_username} ssh_port=${var.ssh_port} ansible_python_interpreter=/usr/bin/python3",
]
# Setting these should fix some of the (false alarm) warnings
ansible_env_vars = [
"ANSIBLE_HOST_KEY_CHECKING=False",
"ANSIBLE_COLLECTIONS_PATH=${path.root}/ansible/collections",
"ANSIBLE_ROLES_PATH=${path.root}/ansible/roles",
]
groups = ["packer"]
# Paths to files and locations
playbook_file = "${path.root}/ansible/test.yml"
# galaxy_file = "${path.root}/ansible/requirements.yml"
# roles_path = "${path.root}/ansible/roles"
# collections_path = "${path.root}/ansible/collections"
inventory_directory = "${path.root}/ansible"
}
provisioner "shell" {
scripts = [
"${path.root}/scripts/cleanup.sh",
"${path.root}/scripts/zero-out-disk.sh",
# This allows us to remove unique identifiers from
# the template and minimize image size at the end.
"${path.root}/scripts/vm-cleanup.sh",
]
execute_command = "chmod +x {{ .Path }}; sudo env {{ .Vars }} sh -c {{ .Path }}"
}
post-processor "vagrant-cloud" {
box_tag = var.vagrant_box_name
version = var.vagrant_box_version
vagrant_cloud_url = "https://app.vagrantup.com/api/v1"
no_release = true
}
}