Chore: Update common-packer to v0.14.2
[ci-management.git] / packer / templates / memcached.pkr.hcl
1 packer {
2   required_plugins {
3     openstack = {
4       version = ">= 1.0.0"
5       source  = "github.com/hashicorp/openstack"
6     }
7   }
8 }
9
10 variable "cloud_auth_url" {
11   type    = string
12   default = null
13 }
14
15 variable "cloud_tenant" {
16   type    = string
17   default = null
18 }
19
20 variable "cloud_user" {
21   type    = string
22   default = null
23 }
24
25 variable "cloud_pass" {
26   type    = string
27   default = null
28 }
29
30 variable "source_ami_filter_name" {
31   type    = string
32   default = null
33 }
34
35 variable "source_ami_filter_product_code" {
36   type    = string
37   default = null
38 }
39
40 variable "source_ami_filter_owner" {
41   type    = string
42   default = null
43 }
44
45 variable "ansible_roles_path" {
46   type    = string
47   default = ".galaxy"
48 }
49
50 variable "arch" {
51   type    = string
52   default = "x86_64"
53 }
54
55 variable "base_image" {
56   type = string
57   default = null
58 }
59
60 variable "cloud_network" {
61   type = string
62   default = null
63 }
64
65 variable "cloud_region" {
66   type    = string
67   default = "ca-ymq-1"
68 }
69
70 variable "cloud_user_data" {
71   type = string
72   default = null
73 }
74
75 variable "distro" {
76   type = string
77   default = null
78 }
79
80 variable "docker_source_image" {
81   type = string
82   default = null
83 }
84
85 variable "flavor" {
86   type    = string
87   default = "v2-highcpu-1"
88 }
89
90 variable "ssh_proxy_host" {
91   type    = string
92   default = ""
93 }
94
95 variable "ssh_user" {
96   type = string
97   default = null
98 }
99
100 variable "vm_image_disk_format" {
101   type    = string
102   default = ""
103 }
104
105 variable "vm_use_block_storage" {
106   type    = string
107   default = "true"
108 }
109
110 variable "vm_volume_size" {
111   type    = string
112   default = "20"
113 }
114
115 source "docker" "memcached" {
116   changes = ["ENTRYPOINT [\"\"]", "CMD [\"\"]"]
117   commit  = true
118   image   = "${var.docker_source_image}"
119 }
120
121 source "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
140 build {
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 }