feat(Packer): Introduce AMI packer images
[csit.git] / fdio.infra.packer / 3n_aws_c5n / ubuntu_focal.pkr.hcl
1 packer {
2   required_plugins {
3     amazon = {
4       version = ">= 1.0.1"
5       source  = "github.com/hashicorp/amazon"
6     }
7   }
8 }
9
10 variable "first_run_commands" {
11   description = "Commands to run after deployment via remote-exec"
12   type        = list(string)
13   default     = [
14     ""
15   ]
16 }
17
18 variable "ansible_file_path" {
19   description = "Path to Ansible playbook"
20   type        = string
21   default     = "../../fdio.infra.ansible/site.yaml"
22 }
23
24 variable "ansible_python_executable" {
25   description = "Path to Python interpreter"
26   type        = string
27   default     = "/usr/bin/python3"
28 }
29
30 variable "ansible_topology_path" {
31   description = "Path to Ansible playbook which creates a topology file"
32   type        = string
33   default     = "../../fdio.infra.ansible/cloud_topology.yaml"
34 }
35
36 variable "ansible_provision_pwd" {
37   description = "Password used for ansible provisioning (ansible_ssh_pass)"
38   type        = string
39   default     = "Csit1234"
40 }
41
42 source "amazon-ebs" "csit_c5n_ubuntu_focal_sut" {
43   ami_name         = "csit_c5n_ubuntu_focal_sut"
44   ami_description  = "CSIT SUT image based on Ubuntu Focal"
45   ena_support      = true
46   instance_type    = "c5n.9xlarge"
47   launch_block_device_mappings {
48     device_name = "/dev/sda1"
49     volume_size = 40
50     volume_type = "gp2"
51   }
52   force_deregister = true
53   region           = "eu-central-1"
54   skip_create_ami  = false
55   source_ami       = "ami-0a875db8a031a9efb"
56   ssh_username     = "ubuntu"
57 }
58
59 source "amazon-ebs" "csit_c5n_ubuntu_focal_tg" {
60   ami_name         = "csit_c5n_ubuntu_focal_tg"
61   ami_description  = "CSIT TG image based on Ubuntu Focal"
62   ena_support      = true
63   instance_type    = "c5n.9xlarge"
64   launch_block_device_mappings {
65     device_name = "/dev/sda1"
66     volume_size = 40
67     volume_type = "gp2"
68   }
69   force_deregister = true
70   region           = "eu-central-1"
71   skip_create_ami  = false
72   source_ami       = "ami-0a875db8a031a9efb"
73   ssh_username     = "ubuntu"
74 }
75
76 build {
77   name = "csit_c5n_ubuntu_focal_sut-packer"
78   sources = [
79     "source.amazon-ebs.csit_c5n_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 }
95
96 build {
97   name = "csit_c5n_ubuntu_focal_tg-packer"
98   sources = [
99     "source.amazon-ebs.csit_c5n_ubuntu_focal_tg"
100   ]
101   provisioner "shell" {
102     inline = var.first_run_commands
103   }
104   provisioner "ansible" {
105     playbook_file = var.ansible_file_path
106     user          = "ubuntu"
107     groups        = ["tg_aws"]
108     extra_arguments = [
109       "--extra-vars", "ansible_ssh_pass=${var.ansible_provision_pwd}",
110       "--extra-vars", "ansible_python_interpreter=${var.ansible_python_executable}",
111       "--extra-vars", "aws=true"
112     ]
113   }
114 }