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