feat(terraform): c6gn
[csit.git] / fdio.infra.packer / aws_c6gn / ubuntu_focal.pkr.hcl
1
2 packer {
3   required_plugins {
4     amazon = {
5       version = ">= 1.0.1"
6       source  = "github.com/hashicorp/amazon"
7     }
8   }
9 }
10 variable "first_run_commands" {
11   description = "Commands to run before deployment via remote-exec"
12   type        = list(string)
13   default = [
14     ""
15   ]
16 }
17 variable "last_run_commands" {
18   description = "Commands to run after deployment via remote-exec"
19   type        = list(string)
20   default = [
21     "sudo sed -i 's/Unattended-Upgrade \"1\"/Unattended-Upgrade \"0\"/g' /etc/apt/apt.conf.d/20auto-upgrades"
22   ]
23 }
24 variable "ansible_file_path" {
25   description = "Path to Ansible playbook"
26   type        = string
27   default     = "../../fdio.infra.ansible/site.yaml"
28 }
29 variable "ansible_python_executable" {
30   description = "Path to Python interpreter"
31   type        = string
32   default     = "/usr/bin/python3"
33 }
34 variable "ansible_topology_path" {
35   description = "Path to Ansible playbook which creates a topology file"
36   type        = string
37   default     = "../../fdio.infra.ansible/cloud_topology.yaml"
38 }
39 variable "ansible_provision_pwd" {
40   description = "Password used for ansible provisioning (ansible_ssh_pass)"
41   type        = string
42   default     = "Csit1234"
43 }
44 source "amazon-ebs" "csit_c6gn_ubuntu_focal_sut" {
45   ami_name        = "csit_c6gn_ubuntu_focal_sut"
46   ami_description = "CSIT SUT image based on Ubuntu Focal"
47   ena_support     = true
48   instance_type   = "c6gn.4xlarge"
49   launch_block_device_mappings {
50     device_name = "/dev/sda1"
51     volume_size = 40
52     volume_type = "gp2"
53   }
54   force_deregister = true
55   region           = "eu-central-1"
56   skip_create_ami  = false
57   source_ami       = "ami-0a875db8a031a9efb"
58   ssh_username     = "ubuntu"
59 }
60 source "amazon-ebs" "csit_c6gn_ubuntu_focal_tg" {
61   ami_name        = "csit_c6gn_ubuntu_focal_tg"
62   ami_description = "CSIT TG image based on Ubuntu Focal"
63   ena_support     = true
64   instance_type   = "c6gn.4xlarge"
65   launch_block_device_mappings {
66     device_name = "/dev/sda1"
67     volume_size = 40
68     volume_type = "gp2"
69   }
70   force_deregister = true
71   region           = "eu-central-1"
72   skip_create_ami  = false
73   source_ami       = "ami-0a875db8a031a9efb"
74   ssh_username     = "ubuntu"
75 }
76 build {
77   name = "csit_c6gn_ubuntu_focal_sut-packer"
78   sources = [
79     "source.amazon-ebs.csit_c6gn_ubuntu_focal_sut"
80   ]
81   provisioner "shell" {
82     inline = var.first_run_commands
83   }
84   provisioner "ansible" {
85     playbook_file = var.ansible_file_path
86     user          = "ubuntu"
87     groups        = ["sut_aws"]
88     extra_arguments = [
89       "--extra-vars", "ansible_ssh_pass=${var.ansible_provision_pwd}",
90       "--extra-vars", "ansible_python_interpreter=${var.ansible_python_executable}",
91       "--extra-vars", "aws=true"
92     ]
93   }
94   provisioner "shell" {
95     inline = var.last_run_commands
96   }
97 }
98 build {
99   name = "csit_c6gn_ubuntu_focal_tg-packer"
100   sources = [
101     "source.amazon-ebs.csit_c6gn_ubuntu_focal_tg"
102   ]
103   provisioner "shell" {
104     inline = var.first_run_commands
105   }
106   provisioner "ansible" {
107     playbook_file = var.ansible_file_path
108     user          = "ubuntu"
109     groups        = ["tg_aws"]
110     extra_arguments = [
111       "--extra-vars", "ansible_ssh_pass=${var.ansible_provision_pwd}",
112       "--extra-vars", "ansible_python_interpreter=${var.ansible_python_executable}",
113       "--extra-vars", "aws=true"
114     ]
115   }
116   provisioner "shell" {
117     inline = var.last_run_commands
118   }
119 }