blob: cd1a6104ac4b48a82c91f21fc7f0a5022982d46f [file] [log] [blame]
Anil Belur36677022023-07-05 21:49:06 +10001packer {
2 required_plugins {
3 openstack = {
4 version = ">= 1.0.0"
5 source = "github.com/hashicorp/openstack"
6 }
7 }
8}
9
10variable "cloud_auth_url" {
11 type = string
12 default = null
13}
14
15variable "cloud_tenant" {
16 type = string
17 default = null
18}
19
20variable "cloud_user" {
21 type = string
22 default = null
23}
24
25variable "cloud_pass" {
26 type = string
27 default = null
28}
29
30variable "source_ami_filter_name" {
31 type = string
32 default = null
33}
34
35variable "source_ami_filter_product_code" {
36 type = string
37 default = null
38}
39
40variable "source_ami_filter_owner" {
41 type = string
42 default = null
43}
44
45variable "ansible_roles_path" {
46 type = string
47 default = ".galaxy"
48}
49
50variable "arch" {
51 type = string
52 default = "x86_64"
53}
54
55variable "base_image" {
56 type = string
57 default = null
58}
59
60variable "cloud_network" {
61 type = string
62 default = null
63}
64
65variable "cloud_region" {
66 type = string
67 default = "ca-ymq-1"
68}
69
70variable "cloud_user_data" {
71 type = string
72 default = null
73}
74
75variable "distro" {
76 type = string
77 default = null
78}
79
80variable "docker_source_image" {
81 type = string
82 default = null
83}
84
85variable "flavor" {
86 type = string
87 default = "v2-highcpu-1"
88}
89
90variable "ssh_proxy_host" {
91 type = string
92 default = ""
93}
94
95variable "ssh_user" {
96 type = string
97 default = null
98}
99
100variable "vm_image_disk_format" {
101 type = string
102 default = ""
103}
104
105variable "vm_use_block_storage" {
106 type = string
107 default = "true"
108}
109
110variable "vm_volume_size" {
111 type = string
112 default = "20"
113}
114
115source "docker" "memcached" {
116 changes = ["ENTRYPOINT [\"\"]", "CMD [\"\"]"]
117 commit = true
118 image = "${var.docker_source_image}"
119}
120
121source "openstack" "memcached" {
122 domain_name = "Default"
123 flavor = "${var.flavor}"
124 identity_endpoint = "${var.cloud_auth_url}"
125 image_name = "${var.distro} - memcached - ${var.arch} - ${legacy_isotime("20180101-1003")}"
126 metadata = {
127 ci_managed = "yes"
128 }
129 networks = ["${var.cloud_network}"]
130 password = "${var.cloud_pass}"
131 region = "ca-ymq-1"
132 source_image_name = "${var.base_image}"
133 ssh_proxy_host = "${var.ssh_proxy_host}"
134 ssh_username = "${var.ssh_user}"
135 tenant_name = "${var.cloud_tenant}"
136 user_data_file = "${var.cloud_user_data}"
137 username = "${var.cloud_user}"
138}
139
140build {
141 sources = ["source.docker.memcached", "source.openstack.memcached"]
142
143 provisioner "shell" {
144 execute_command = "chmod +x {{ .Path }}; if [ \"$UID\" == \"0\" ]; then {{ .Vars }} '{{ .Path }}'; else {{ .Vars }} sudo -E '{{ .Path }}'; fi"
145 scripts = ["common-packer/provision/install-python.sh"]
146 }
147
148 provisioner "shell-local" {
149 command = "./common-packer/ansible-galaxy.sh ${var.ansible_roles_path}"
150 }
151
152 provisioner "ansible" {
153 ansible_env_vars = [
154 "ANSIBLE_NOCOWS=1",
155 "ANSIBLE_PIPELINING=True",
156 "ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
157 "ANSIBLE_CALLBACK_WHITELIST=profile_tasks",
158 "ANSIBLE_STDOUT_CALLBACK=debug"
159 ]
160 command = "./common-packer/ansible-playbook.sh"
161 extra_arguments = [
162 "--scp-extra-args", "'-O'",
163 "--ssh-extra-args", "-o IdentitiesOnly=yes -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa"
164 ]
165 playbook_file = "provision/memcached.yaml"
166 skip_version_check = true
167 }
168}