Chore: Update common-packer to latest v0.14.0
[releng/builder.git] / packer / templates / devstack-pre-pip-queens.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 "ansible_roles_path" {
11   type    = string
12   default = ".galaxy"
13 }
14
15 variable "arch" {
16   type    = string
17   default = "x86_64"
18 }
19
20 variable "base_image" {
21   type = string
22   default = null
23 }
24
25 variable "cloud_network" {
26   type = string
27   default = null
28 }
29
30 variable "cloud_region" {
31   type    = string
32   default = "ca-ymq-1"
33 }
34
35 variable "cloud_auth_url" {
36   type    = string
37   default = null
38 }
39
40 variable "cloud_tenant" {
41   type    = string
42   default = null
43 }
44
45 variable "cloud_user" {
46   type    = string
47   default = null
48 }
49
50 variable "cloud_pass" {
51   type    = string
52   default = null
53 }
54
55 variable "cloud_user_data" {
56   type = string
57   default = null
58 }
59
60 variable "distro" {
61   type = string
62   default = null
63 }
64
65 variable "docker_source_image" {
66   type = string
67   default = null
68 }
69
70 variable "flavor" {
71   type    = string
72   default = "v3-standard-2"
73 }
74
75 variable "ssh_proxy_host" {
76   type    = string
77   default = ""
78 }
79
80 variable "source_ami_filter_name" {
81   type    = string
82   default = null
83 }
84
85 variable "source_ami_filter_product_code" {
86   type    = string
87   default = null
88 }
89
90 variable "source_ami_filter_owner" {
91   type    = string
92   default = null
93 }
94
95 variable "ssh_user" {
96   type = string
97 }
98
99 variable "vm_image_disk_format" {
100   type    = string
101   default = ""
102 }
103
104 variable "vm_use_block_storage" {
105   type    = string
106   default = "true"
107 }
108
109 variable "vm_volume_size" {
110   type    = string
111   default = "20"
112 }
113
114 source "docker" "devstack-pre-pip-queens" {
115   changes = ["ENTRYPOINT [\"\"]", "CMD [\"\"]"]
116   commit  = true
117   image   = "${var.docker_source_image}"
118 }
119
120 source "openstack" "devstack-pre-pip-queens" {
121   flavor            = "${var.flavor}"
122   image_disk_format = "${var.vm_image_disk_format}"
123   image_name        = "ZZCI - ${var.distro} - devstack-queens - ${var.arch} - ${legacy_isotime("20060102-150405.000")}"
124   instance_name     = "${var.distro}-devstack-queens-${uuidv4()}"
125   metadata = {
126     ci_managed = "yes"
127   }
128   networks                = ["${var.cloud_network}"]
129   region                  = "${var.cloud_region}"
130   source_image_name       = "${var.base_image}"
131   ssh_proxy_host          = "${var.ssh_proxy_host}"
132   ssh_username            = "${var.ssh_user}"
133   use_blockstorage_volume = "${var.vm_use_block_storage}"
134   user_data_file          = "${var.cloud_user_data}"
135   volume_size             = "${var.vm_volume_size}"
136 }
137
138 build {
139   sources = ["source.docker.devstack-pre-pip-queens", "source.openstack.devstack-pre-pip-queens"]
140
141   provisioner "shell" {
142     execute_command = "chmod +x {{ .Path }}; if [ \"$UID\" == \"0\" ]; then {{ .Vars }} '{{ .Path }}'; else {{ .Vars }} sudo -E '{{ .Path }}'; fi"
143     scripts         = ["common-packer/provision/install-python.sh"]
144   }
145
146   provisioner "shell-local" {
147     command = "./common-packer/ansible-galaxy.sh ${var.ansible_roles_path}"
148   }
149
150   provisioner "ansible" {
151     ansible_env_vars   = [
152       "ANSIBLE_DEBUG=False",
153       "ANSIBLE_NOCOWS=1",
154       "ANSIBLE_PIPELINING=True",
155       "ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
156       "ANSIBLE_CALLBACK_WHITELIST=profile_tasks",
157       "ANSIBLE_STDOUT_CALLBACK=debug"
158     ]
159     command            = "./common-packer/ansible-playbook.sh"
160     extra_arguments    = [
161       "--extra-vars", "os_branch=stable/queens rdo_branch=queens",
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/devstack-pre-pip-centos.yaml"
166     skip_version_check = true
167   }
168 }