From 3c5a7d5c1c9f9fcc20b341899c16f33f5c5c01b8 Mon Sep 17 00:00:00 2001 From: ScriptAutomate Date: Fri, 9 Feb 2024 11:14:40 -0600 Subject: [PATCH] Del CentOS Stream, Photon 3, Fedora; Add Fedora 39 --- .github/workflows/ci.yml | 18 -- .../centosstream-8-arm64.pkrvars.hcl | 3 - .../centosstream-8-x86_64.pkrvars.hcl | 3 - .../centosstream-9-arm64.pkrvars.hcl | 2 - .../centosstream-9-x86_64.pkrvars.hcl | 2 - .../AWS/centosstream/centosstream.pkr.hcl | 297 ----------------- .../AWS/fedora/fedora-37-arm64.pkrvars.hcl | 2 - .../AWS/fedora/fedora-37-x86_64.pkrvars.hcl | 2 - .../AWS/fedora/fedora-38-arm64.pkrvars.hcl | 2 - .../AWS/fedora/fedora-38-x86_64.pkrvars.hcl | 2 - .../AWS/fedora/fedora-39-arm64.pkrvars.hcl | 2 + .../AWS/fedora/fedora-39-x86_64.pkrvars.hcl | 2 + .../freebsd/freebsd-131-amd64-us-west-2.json | 17 - os-images/AWS/freebsd/freebsd.json | 162 ---------- os-images/AWS/photon/photon-3-arm64.pkr.hcl | 294 ----------------- .../AWS/photon/photon-3-arm64.pkrvars.hcl | 4 - os-images/AWS/photon/photon-3-x86_64.pkr.hcl | 301 ------------------ .../AWS/photon/photon-3-x86_64.pkrvars.hcl | 4 - 18 files changed, 4 insertions(+), 1115 deletions(-) delete mode 100644 os-images/AWS/centosstream/centosstream-8-arm64.pkrvars.hcl delete mode 100644 os-images/AWS/centosstream/centosstream-8-x86_64.pkrvars.hcl delete mode 100644 os-images/AWS/centosstream/centosstream-9-arm64.pkrvars.hcl delete mode 100644 os-images/AWS/centosstream/centosstream-9-x86_64.pkrvars.hcl delete mode 100644 os-images/AWS/centosstream/centosstream.pkr.hcl delete mode 100644 os-images/AWS/fedora/fedora-37-arm64.pkrvars.hcl delete mode 100644 os-images/AWS/fedora/fedora-37-x86_64.pkrvars.hcl delete mode 100644 os-images/AWS/fedora/fedora-38-arm64.pkrvars.hcl delete mode 100644 os-images/AWS/fedora/fedora-38-x86_64.pkrvars.hcl create mode 100644 os-images/AWS/fedora/fedora-39-arm64.pkrvars.hcl create mode 100644 os-images/AWS/fedora/fedora-39-x86_64.pkrvars.hcl delete mode 100644 os-images/AWS/freebsd/freebsd-131-amd64-us-west-2.json delete mode 100644 os-images/AWS/freebsd/freebsd.json delete mode 100644 os-images/AWS/photon/photon-3-arm64.pkr.hcl delete mode 100644 os-images/AWS/photon/photon-3-arm64.pkrvars.hcl delete mode 100644 os-images/AWS/photon/photon-3-x86_64.pkr.hcl delete mode 100644 os-images/AWS/photon/photon-3-x86_64.pkrvars.hcl diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66386b08f..4715ebe39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,11 +71,6 @@ jobs: - *state_tree_added_modified - *os_images_scripts - os-images/AWS/centos/*.hcl - os-images-centosstream: - - added|modified: - - *state_tree_added_modified - - *os_images_scripts - - os-images/AWS/centosstream/*.hcl os-images-debian: - added|modified: - *state_tree_added_modified @@ -240,18 +235,6 @@ jobs: changed-files: ${{ needs.get-changed-files.outputs.changed-files }} runner-version: ${{ needs.collect-jobs.outputs.runner-version }} - centosstream: - name: CentOS Stream - needs: - - collect-jobs - - get-changed-files - if: ${{ fromJSON(needs.collect-jobs.outputs.jobs)['os-images-centosstream'] }} - uses: ./.github/workflows/build-image-action.yml - with: - distro-name: centosstream - changed-files: ${{ needs.get-changed-files.outputs.changed-files }} - runner-version: ${{ needs.collect-jobs.outputs.runner-version }} - debian: name: Debian needs: @@ -336,7 +319,6 @@ jobs: - amazonlinux2000 - archlinux - centos - - centosstream - debian - fedora - opensuse diff --git a/os-images/AWS/centosstream/centosstream-8-arm64.pkrvars.hcl b/os-images/AWS/centosstream/centosstream-8-arm64.pkrvars.hcl deleted file mode 100644 index 5190d050b..000000000 --- a/os-images/AWS/centosstream/centosstream-8-arm64.pkrvars.hcl +++ /dev/null @@ -1,3 +0,0 @@ -ami_filter = "CentOS Stream 8*aarch64*" -instance_type = "m6g.large" -ssh_username = "centos" diff --git a/os-images/AWS/centosstream/centosstream-8-x86_64.pkrvars.hcl b/os-images/AWS/centosstream/centosstream-8-x86_64.pkrvars.hcl deleted file mode 100644 index 0451af7e4..000000000 --- a/os-images/AWS/centosstream/centosstream-8-x86_64.pkrvars.hcl +++ /dev/null @@ -1,3 +0,0 @@ -ami_filter = "CentOS Stream 8*x86_64*" -instance_type = "t3a.large" -ssh_username = "centos" diff --git a/os-images/AWS/centosstream/centosstream-9-arm64.pkrvars.hcl b/os-images/AWS/centosstream/centosstream-9-arm64.pkrvars.hcl deleted file mode 100644 index 8664db928..000000000 --- a/os-images/AWS/centosstream/centosstream-9-arm64.pkrvars.hcl +++ /dev/null @@ -1,2 +0,0 @@ -ami_filter = "CentOS Stream 9*aarch64*" -instance_type = "m6g.large" diff --git a/os-images/AWS/centosstream/centosstream-9-x86_64.pkrvars.hcl b/os-images/AWS/centosstream/centosstream-9-x86_64.pkrvars.hcl deleted file mode 100644 index 2289e1d3e..000000000 --- a/os-images/AWS/centosstream/centosstream-9-x86_64.pkrvars.hcl +++ /dev/null @@ -1,2 +0,0 @@ -ami_filter = "CentOS Stream 9*x86_64*" -instance_type = "t3a.large" diff --git a/os-images/AWS/centosstream/centosstream.pkr.hcl b/os-images/AWS/centosstream/centosstream.pkr.hcl deleted file mode 100644 index ddfb677ee..000000000 --- a/os-images/AWS/centosstream/centosstream.pkr.hcl +++ /dev/null @@ -1,297 +0,0 @@ -# CLI Variables -variable "ci_build" { type = bool } -variable "aws_region" { type = string } -variable "ssh_keypair_name" { type = string } -variable "ssh_private_key_file" { type = string } -variable "distro_arch" { type = string } -variable "distro_version" { type = string } -variable "skip_create_ami" { - type = bool - default = false -} -variable "runner_version" { - description = "The version (no v prefix) of the GitHub Actions Runner software to install https://github.com/actions/runner/releases" - type = string - default = "2.300.2" -} -variable "install_github_actions_runner" { - description = "Create a user to run the GitHub Actions Runner under." - type = bool - default = false -} - -# Variables set by pkrvars file -variable "instance_type" { - type = string - default = "c5a.large" -} -variable "ssh_username" { - type = string - default = "ec2-user" -} - -# Remaining variables -variable "build_type" { - type = string - default = "ci" -} -variable "ami_owner" { - type = string - default = "125523088429" -} - -variable "distro_name" { - type = string - default = "CentOSStream" -} - -variable "ami_filter" { - type = string -} - -variable "ami_name_prefix" { - type = string - default = "salt-project" -} - -variable "state_name" { - type = string - default = "provision" -} - -variable "salt_provision_type" { - type = string - default = "stable" -} - -variable "salt_provision_version" { - type = string - default = "3006.0" -} - -variable "salt_provision_root_dir" { - type = string - default = "/tmp/salt-provision" -} - -locals { - build_timestamp = timestamp() - ami_name = "${var.ami_name_prefix}/${var.build_type}/${lower(var.distro_name)}/${var.distro_version}/${var.distro_arch}/${formatdate("YYYYMMDD.hhmm", local.build_timestamp)}" - ami_description = "${upper(var.build_type)} Image of ${var.distro_name} ${var.distro_version} ${var.distro_arch}" - distro_slug = "${lower(var.distro_name)}-${var.distro_version}-${var.distro_arch}" -} - -data "amazon-ami" "image" { - filters = { - name = var.ami_filter - root-device-type = "ebs" - state = "available" - virtualization-type = "hvm" - architecture = var.distro_arch - } - most_recent = true - owners = [ - var.ami_owner - ] - region = var.aws_region -} - -source "amazon-ebs" "image" { - ami_description = local.ami_description - ami_name = local.ami_name - instance_type = var.instance_type - - ebs_optimized = true - shutdown_behavior = "terminate" - - skip_create_ami = var.skip_create_ami - - ami_users = [ - "178480506716", - "540082622920" - ] - - # ami_groups = [ - # "all" - # ] - - launch_block_device_mappings { - delete_on_termination = true - device_name = "/dev/sda1" - volume_size = 40 - volume_type = "gp3" - } - - region = var.aws_region - - run_tags = { - Name = "Packer {{ upper `${var.build_type}` }} ${var.distro_name} ${var.distro_version} ${var.distro_arch} Builder" - Owner = "SRE" - Salt-Golden-Image = true - create-salt-golden-image = true - created-by = "packer" - } - security_group_filter { - filters = { - group-name = "*-prod-*-golden-images-provision-${var.ci_build ? "private" : "public"}-*" - } - } - source_ami = data.amazon-ami.image.id - ssh_interface = "${var.ci_build ? "private" : "public"}_ip" - ssh_keypair_name = var.ssh_keypair_name - ssh_private_key_file = var.ssh_private_key_file - ssh_username = var.ssh_username - associate_public_ip_address = var.ci_build == false - subnet_filter { - filters = { - "tag:Name" = "*-prod-vpc-${var.ci_build ? "private" : "public"}-*" - } - most_free = true - random = false - } - tags = { - Build-Date = "${local.build_timestamp}" - Build-Type = var.build_type - Name = "Salt Project // ${upper(var.build_type)} // ${var.distro_name} ${var.distro_version} ${var.distro_arch}" - OS-Arch = "${var.distro_arch}" - OS-Name = "${var.distro_name}" - OS-Version = "${var.distro_version}" - Owner = "SRE" - Provision-State-Name = "${var.state_name}" - Salt-Golden-Image = true - created-by = "packer" - no-delete = false - ssh-username = var.ssh_username - "spb:start-github-runner" = false - } -} - -build { - sources = [ - "source.amazon-ebs.image" - ] - - provisioner "shell" { - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline = [ - "yum install -y dnf || true", - "dnf install -y centos-gpg-keys centos-stream-release centos-stream-repos", - "dnf update -y", - "dnf install -y git vim sudo openssh-server dbus curl tar unzip" - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell" { - # The above 'dnf update' call will upgrade cloud-init which defines a new - # username as the default user for the image. - # Make sure that user exists while running the remaining steps. - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline = [ - "cloud-init single --name cc_users_groups" - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell" { - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline = [ - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/assets/amazon-cloudwatch-agent.gpg -o /tmp/amazon-cloudwatch-agent.gpg", - "gpg --import /tmp/amazon-cloudwatch-agent.gpg", - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/${var.distro_arch == "x86_64" ? "centos" : "redhat"}/${var.distro_arch == "x86_64" ? "amd64" : "arm64"}/latest/amazon-cloudwatch-agent.rpm -o /tmp/amazon-cloudwatch-agent.rpm", - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/${var.distro_arch == "x86_64" ? "centos" : "redhat"}/${var.distro_arch == "x86_64" ? "amd64" : "arm64"}/latest/amazon-cloudwatch-agent.rpm.sig -o /tmp/amazon-cloudwatch-agent.rpm.sig", - "gpg --verify /tmp/amazon-cloudwatch-agent.rpm.sig /tmp/amazon-cloudwatch-agent.rpm", - "rpm -U /tmp/amazon-cloudwatch-agent.rpm", - "systemctl restart amazon-cloudwatch-agent", - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell" { - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline = [ - "curl -f https://awscli.amazonaws.com/awscli-exe-linux-${var.distro_arch == "x86_64" ? "x86_64" : "aarch64"}.zip -o /tmp/awscliv2.zip", - "cd /tmp; unzip awscliv2.zip", - "cd /tmp; ./aws/install", - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell-local" { - environment_vars = [ - "DISTRO_SLUG=${local.distro_slug}", - "SALT_ROOT_DIR=${var.salt_provision_root_dir}", - "INSTALL_GITHUB_ACTIONS_RUNNER=${var.install_github_actions_runner ? "yes" : "no"}", - "INSTALL_GITHUB_ACTIONS_RUNNER_DEPENDENCIES=true", - "GITHUB_ACTIONS_RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${var.runner_version}/actions-runner-linux-${var.distro_arch == "x86_64" ? "x64" : "arm64"}-${var.runner_version}.tar.gz" - ] - script = "os-images/AWS/files/prep-linux.sh" - } - - provisioner "shell" { - environment_vars = [ - "OS_ARCH=${var.distro_arch == "arm64" ? "aarch64" : "x86_64"}", - "SALT_VERSION=${var.salt_provision_version}", - "SALT_PROVISION_TYPE=${var.salt_provision_type}" - ] - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - script = "os-images/files/provision-salt.sh" - } - - provisioner "file" { - destination = "${var.salt_provision_root_dir}/" - direction = "upload" - generated = true - source = ".tmp/${local.distro_slug}" - } - - provisioner "shell" { - environment_vars = [ - "SALT_ROOT_DIR=${var.salt_provision_root_dir}", - "SALT_STATE=${var.state_name}" - ] - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - pause_after = "5s" - script = "os-images/files/provision-system.sh" - } - - provisioner "shell" { - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline_shebang = "/bin/sh -ex" - inline = [ - "dnf clean all", - "rm -rf /var/cache/yum" - ] - } - - provisioner "shell" { - environment_vars = [ - "SALT_ROOT_DIR=${var.salt_provision_root_dir}" - ] - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - script = "os-images/files/cleanup-salt.sh" - } - - provisioner "shell" { - environment_vars = [ - "SSH_USERNAME=${var.ssh_username}" - ] - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - script = "os-images/AWS/files/cleanup-linux.sh" - } - - post-processor "manifest" { - custom_data = { - arch = var.distro_arch - ami_name = local.ami_name - ami_description = local.ami_description - ssh_username = var.ssh_username - instance_type = var.instance_type - is_windows = false - cloudwatch-agent-available = true - slug = "${lower(var.distro_name)}-${var.distro_version}${var.distro_arch == "arm64" ? "-${var.distro_arch}" : ""}" - } - output = "manifest.json" - strip_path = true - } -} diff --git a/os-images/AWS/fedora/fedora-37-arm64.pkrvars.hcl b/os-images/AWS/fedora/fedora-37-arm64.pkrvars.hcl deleted file mode 100644 index 3d24e666f..000000000 --- a/os-images/AWS/fedora/fedora-37-arm64.pkrvars.hcl +++ /dev/null @@ -1,2 +0,0 @@ -ami_filter = "Fedora-Cloud-Base-37-*.aarch64-hvm-*-gp2-0" -instance_type = "m6g.large" diff --git a/os-images/AWS/fedora/fedora-37-x86_64.pkrvars.hcl b/os-images/AWS/fedora/fedora-37-x86_64.pkrvars.hcl deleted file mode 100644 index 9ee618b06..000000000 --- a/os-images/AWS/fedora/fedora-37-x86_64.pkrvars.hcl +++ /dev/null @@ -1,2 +0,0 @@ -ami_filter = "Fedora-Cloud-Base-37-*.x86_64-hvm-*-gp2-0" -instance_type = "t3a.large" diff --git a/os-images/AWS/fedora/fedora-38-arm64.pkrvars.hcl b/os-images/AWS/fedora/fedora-38-arm64.pkrvars.hcl deleted file mode 100644 index 79f1e225b..000000000 --- a/os-images/AWS/fedora/fedora-38-arm64.pkrvars.hcl +++ /dev/null @@ -1,2 +0,0 @@ -ami_filter = "Fedora-Cloud-Base-38-*.aarch64-hvm-*-gp2-0" -instance_type = "m6g.large" diff --git a/os-images/AWS/fedora/fedora-38-x86_64.pkrvars.hcl b/os-images/AWS/fedora/fedora-38-x86_64.pkrvars.hcl deleted file mode 100644 index 0f44f9c89..000000000 --- a/os-images/AWS/fedora/fedora-38-x86_64.pkrvars.hcl +++ /dev/null @@ -1,2 +0,0 @@ -ami_filter = "Fedora-Cloud-Base-38-*.x86_64-hvm-*-gp2-0" -instance_type = "t3a.large" diff --git a/os-images/AWS/fedora/fedora-39-arm64.pkrvars.hcl b/os-images/AWS/fedora/fedora-39-arm64.pkrvars.hcl new file mode 100644 index 000000000..52cb5116b --- /dev/null +++ b/os-images/AWS/fedora/fedora-39-arm64.pkrvars.hcl @@ -0,0 +1,2 @@ +ami_filter = "Fedora-Cloud-Base-39-*.aarch64-hvm-*-gp3-0" +instance_type = "m6g.large" diff --git a/os-images/AWS/fedora/fedora-39-x86_64.pkrvars.hcl b/os-images/AWS/fedora/fedora-39-x86_64.pkrvars.hcl new file mode 100644 index 000000000..dc91c3192 --- /dev/null +++ b/os-images/AWS/fedora/fedora-39-x86_64.pkrvars.hcl @@ -0,0 +1,2 @@ +ami_filter = "Fedora-Cloud-Base-39-*.x86_64-hvm-*-gp3-0" +instance_type = "t3a.large" diff --git a/os-images/AWS/freebsd/freebsd-131-amd64-us-west-2.json b/os-images/AWS/freebsd/freebsd-131-amd64-us-west-2.json deleted file mode 100644 index 6f8d7d173..000000000 --- a/os-images/AWS/freebsd/freebsd-131-amd64-us-west-2.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "_comment": "Build with `packer build -var-file=freebsd-131-amd64-us-west-2.json freebsd.json`", - "ssh_username": "ec2-user", - "os_name": "FreeBSD", - "os_version": "131", - "os_arch": "amd64", - "salt_provision_version": "3004.2", - "salt_provision_root_dir": "/tmp/salt-provision", - "salt_provision_python_version": "3.9.12", - "salt_provision_pyenv_deps": "", - "state_name": "provision", - "ami_filter": "FreeBSD 13.1-RELEASE-amd64 UEFI", - "ami_owner": "782442783595", - "ami_name_prefix": "saltstack", - "ami_name_suffix": "freebsd/131/amd64", - "instance_type": "r5d.large" -} diff --git a/os-images/AWS/freebsd/freebsd.json b/os-images/AWS/freebsd/freebsd.json deleted file mode 100644 index cf72e32ad..000000000 --- a/os-images/AWS/freebsd/freebsd.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "_comment": "Build with `packer build freebsd.json`", - "builders": [ - { - "type": "amazon-ebs", - "region": "{{ user `aws_region` }}", - "source_ami_filter": { - "filters": { - "virtualization-type": "hvm", - "name": "{{ user `ami_filter` }}", - "root-device-type": "ebs", - "state": "available" - }, - "owners": [ - "{{ user `ami_owner` }}" - ], - "most_recent": true - }, - "subnet_filter": { - "filters": { - "tag:Name": "*-public-*" - }, - "most_free": true, - "random": false - }, - "vpc_filter": { - "filters": { - "tag:Name": "test" - } - }, - "security_group_filter": { - "filters": { - "group-name": "kitchen-slave-auto-delete-test" - } - }, - "user_data": "#!/bin/sh\nASSUME_ALWAYS_YES=yes DEFAULT_ALWAYS_YES=yes pkg install bash sudo\necho 'ec2-user ALL=(ALL) NOPASSWD: ALL'>>/usr/local/etc/sudoers\necho 'firstboot_freebsd_update_enable=NO'>>/etc/rc.conf", - "instance_type": "{{ user `instance_type` }}", - "ssh_interface": "private_ip", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_keypair_name": "kitchen", - "ssh_private_key_file": "~/.ssh/kitchen.pem", - "ami_name": "{{ user `ami_name_prefix` }}/{{ user `build_type` }}/{{ user `ami_name_suffix` }}/{{ isotime \"2006-01-02-15-04-05\" }}", - "ami_groups": [ - "all" - ], - "ami_description": "{{ user `build_type` | upper }} Image of {{ user `os_name` }} {{ user `os_version` }} {{ user `os_arch` }}", - "tags": { - "Name": "{{ user `build_type` | upper }} // {{ user `os_name` }} {{ user `os_version` }} {{ user `os_arch` }}", - "OS-Name": "{{ user `os_name` }}", - "OS-Version": "{{ user `os_version` }}", - "OS-Arch": "{{ user `os_arch` }}", - "Build-Date": "{{ isotime }}", - "Build-Type": "{{ user `build_type` | upper }}", - "created-by": "packer", - "Owner": "SRE", - "Provision-State-Name": "{{ user `state_name` }}", - "Promoted": false, - "Salt-Golden-Image": true - }, - "run_tags": { - "Name": "Packer {{ user `build_type` | upper }} {{ user `os_name` }} {{ user `os_version` }} {{ user `os_arch` }} Builder", - "created-by": "packer", - "Owner": "SRE", - "Salt-Golden-Image": true - }, - "launch_block_device_mappings": [ - { - "device_name": "/dev/sda1", - "volume_size": 40, - "volume_type": "gp3", - "delete_on_termination": true - } - ] - } - ], - "provisioners": [ - { - "type": "shell", - "inline_shebang": "/bin/sh", - "inline": [ - "ASSUME_ALWAYS_YES=yes DEFAULT_ALWAYS_YES=yes", - "pkg install -y bash curl ec2-scripts git libxml2 libxslt libgit2 py39-Jinja2 py39-pygit2 py39-sqlite3 libzmq4 libunwind sudo", - "echo 'ec2-user ALL=(ALL) NOPASSWD: ALL'>>/usr/local/etc/sudoers", - "gpart show", - "df -h", - "df -h|grep '/$'|grep '39G\\|40G'" - ], - "execute_command": "sudo -E -H bash -ec '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell-local", - "script": "os-images/AWS/files/prep-linux.sh", - "environment_vars": [ - "SALT_PR={{ user `salt_pr` }}", - "DISTRO_SLUG={{ user `distro_slug` }}", - "SALT_ROOT_DIR={{ user `salt_provision_root_dir` }}" - ] - }, - { - "type": "shell", - "inline_shebang": "/usr/local/bin/bash -ex", - "inline": [ - "# Install PyEnv", - "curl https://pyenv.run | bash" - ], - "execute_command": "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "script": "os-images/files/install-salt.sh", - "environment_vars": [ - "LANG=en_US.UTF-8", - "OS_ARCH={{ user `os_arch` }}", - "SALT_VERSION={{ user `salt_provision_version` }}", - "SALT_PY_VERSION={{ user `salt_provision_python_version` }}" - ], - "execute_command": "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "file", - "generated": true, - "source": ".tmp/{{ user `distro_slug` }}", - "destination": "{{ user `salt_provision_root_dir` }}/", - "direction": "upload" - }, - { - "type": "shell", - "script": "os-images/files/provision-system.sh", - "environment_vars": [ - "LANG=en_US.UTF-8", - "SALT_PY_VERSION={{ user `salt_provision_python_version` }}", - "SALT_ROOT_DIR={{ user `salt_provision_root_dir` }}", - "SALT_STATE={{ user `state_name` }}" - ], - "pause_after": "5s", - "execute_command": "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "script": "os-images/files/cleanup-salt.sh", - "environment_vars": [ - "SALT_ROOT_DIR={{ user `salt_provision_root_dir` }}" - ], - "execute_command": "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "script": "os-images/AWS/files/cleanup-linux.sh", - "execute_command": "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - } - ], - "post-processors": [ - { - "type": "manifest", - "output": "manifest.json", - "strip_path": true, - "custom_data": { - "ami_name": "{{ user `ami_name_prefix` }}/{{ user `build_type` }}/{{ user `ami_name_suffix` }}" - } - } - ] -} diff --git a/os-images/AWS/photon/photon-3-arm64.pkr.hcl b/os-images/AWS/photon/photon-3-arm64.pkr.hcl deleted file mode 100644 index b82db8103..000000000 --- a/os-images/AWS/photon/photon-3-arm64.pkr.hcl +++ /dev/null @@ -1,294 +0,0 @@ -# CLI Variables -variable "ci_build" { type = bool } -variable "aws_region" { type = string } -variable "ssh_keypair_name" { type = string } -variable "ssh_private_key_file" { type = string } -variable "distro_arch" { type = string } -variable "distro_version" { type = string } -variable "skip_create_ami" { - type = bool - default = false -} -variable "runner_version" { - description = "The version (no v prefix) of the GitHub Actions Runner software to install https://github.com/actions/runner/releases" - type = string - default = "2.300.2" -} -variable "install_github_actions_runner" { - description = "Create a user to run the GitHub Actions Runner under." - type = bool - default = false -} - -# Variables set by pkrvars file -variable "instance_type" { - type = string - default = "c5a.large" -} -variable "ssh_username" { - type = string - default = "root" -} - -# Remaining variables -variable "build_type" { - type = string - default = "ci" -} -variable "ami_owner" { - type = string - default = "937850989293" -} - -variable "distro_name" { - type = string - default = "PhotonOS" -} - -variable "ami_filter" { - type = string -} - -variable "ami_name_prefix" { - type = string - default = "salt-project" -} - -variable "state_name" { - type = string - default = "provision" -} - -variable "salt_provision_type" { - type = string - default = "stable" -} - -variable "salt_provision_version" { - type = string - default = "3006.0" -} - -variable "salt_provision_root_dir" { - type = string - default = "/tmp/salt-provision" -} - -locals { - build_timestamp = timestamp() - ami_name = "${var.ami_name_prefix}/${var.build_type}/${lower(var.distro_name)}/${var.distro_version}/${var.distro_arch}/${formatdate("YYYYMMDD.hhmm", local.build_timestamp)}" - ami_description = "${upper(var.build_type)} Image of ${var.distro_name} ${var.distro_version} ${var.distro_arch}" - distro_slug = "${lower(var.distro_name)}-${var.distro_version}-${var.distro_arch}" -} - -data "amazon-ami" "image" { - filters = { - name = var.ami_filter - root-device-type = "ebs" - state = "available" - virtualization-type = "hvm" - architecture = var.distro_arch - } - most_recent = true - owners = [ - var.ami_owner - ] - region = var.aws_region -} - -source "amazon-ebs" "image" { - ami_description = local.ami_description - ami_name = local.ami_name - instance_type = var.instance_type - - ebs_optimized = true - shutdown_behavior = "terminate" - - skip_create_ami = var.skip_create_ami - - ami_users = [ - "178480506716", - "540082622920" - ] - - # ami_groups = [ - # "all" - # ] - - launch_block_device_mappings { - delete_on_termination = true - device_name = "/dev/xvda" - volume_size = 40 - volume_type = "gp3" - } - - region = var.aws_region - - run_tags = { - Name = "Packer {{ upper `${var.build_type}` }} ${var.distro_name} ${var.distro_version} ${var.distro_arch} Builder" - Owner = "SRE" - Salt-Golden-Image = true - create-salt-golden-image = true - created-by = "packer" - } - security_group_filter { - filters = { - group-name = "*-prod-*-golden-images-provision-${var.ci_build ? "private" : "public"}-*" - } - } - source_ami = data.amazon-ami.image.id - ssh_interface = "${var.ci_build ? "private" : "public"}_ip" - ssh_keypair_name = var.ssh_keypair_name - ssh_private_key_file = var.ssh_private_key_file - ssh_username = var.ssh_username - associate_public_ip_address = var.ci_build == false - subnet_filter { - filters = { - "tag:Name" = "*-prod-vpc-${var.ci_build ? "private" : "public"}-*" - } - most_free = true - random = false - } - tags = { - Build-Date = "${local.build_timestamp}" - Build-Type = var.build_type - Name = "Salt Project // ${upper(var.build_type)} // ${var.distro_name} ${var.distro_version} ${var.distro_arch}" - OS-Arch = "${var.distro_arch}" - OS-Name = "${var.distro_name}" - OS-Version = "${var.distro_version}" - Owner = "SRE" - Provision-State-Name = "${var.state_name}" - Salt-Golden-Image = true - created-by = "packer" - no-delete = false - ssh-username = var.ssh_username - "spb:start-github-runner" = false - } -} - -build { - sources = [ - "source.amazon-ebs.image" - ] - - provisioner "shell" { - inline = [ - "df -h" - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell" { - inline = [ - "systemctl mask tmp.mount", - "tdnf makecache", - "tdnf update -y", - "tdnf install -y linux" - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell" { - inline_shebang = "/bin/sh -ex" - inline = [ - "tdnf install -y git vim sudo openssh-server dbus curl rpm tar unzip gnupg" - ] - } - - provisioner "shell" { - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline = [ - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/assets/amazon-cloudwatch-agent.gpg -o /tmp/amazon-cloudwatch-agent.gpg", - "gpg --import /tmp/amazon-cloudwatch-agent.gpg", - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/${var.distro_arch == "x86_64" ? "centos" : "redhat"}/${var.distro_arch == "x86_64" ? "amd64" : "arm64"}/latest/amazon-cloudwatch-agent.rpm -o /tmp/amazon-cloudwatch-agent.rpm", - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/${var.distro_arch == "x86_64" ? "centos" : "redhat"}/${var.distro_arch == "x86_64" ? "amd64" : "arm64"}/latest/amazon-cloudwatch-agent.rpm.sig -o /tmp/amazon-cloudwatch-agent.rpm.sig", - "gpg --verify /tmp/amazon-cloudwatch-agent.rpm.sig /tmp/amazon-cloudwatch-agent.rpm", - "rpm -U /tmp/amazon-cloudwatch-agent.rpm", - "systemctl restart amazon-cloudwatch-agent", - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell" { - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline = [ - "curl -f https://awscli.amazonaws.com/awscli-exe-linux-${var.distro_arch == "x86_64" ? "x86_64" : "aarch64"}.zip -o /tmp/awscliv2.zip", - "cd /tmp; unzip awscliv2.zip", - "cd /tmp; ./aws/install", - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell-local" { - environment_vars = [ - "DISTRO_SLUG=${local.distro_slug}", - "SALT_ROOT_DIR=${var.salt_provision_root_dir}", - "INSTALL_GITHUB_ACTIONS_RUNNER=${var.install_github_actions_runner ? "yes" : "no"}", - "INSTALL_GITHUB_ACTIONS_RUNNER_DEPENDENCIES=false", - "GITHUB_ACTIONS_RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${var.runner_version}/actions-runner-linux-${var.distro_arch == "x86_64" ? "x64" : "arm64"}-${var.runner_version}.tar.gz" - ] - script = "os-images/AWS/files/prep-linux.sh" - } - - provisioner "shell" { - environment_vars = [ - "OS_ARCH=${var.distro_arch == "arm64" ? "aarch64" : "x86_64"}", - "SALT_VERSION=${var.salt_provision_version}", - "SALT_PROVISION_TYPE=${var.salt_provision_type}" - ] - script = "os-images/files/provision-salt.sh" - } - - provisioner "file" { - destination = "${var.salt_provision_root_dir}/" - direction = "upload" - generated = true - source = ".tmp/${local.distro_slug}" - } - - provisioner "shell" { - environment_vars = [ - "SALT_ROOT_DIR=${var.salt_provision_root_dir}", - "SALT_STATE=${var.state_name}" - ] - pause_after = "5s" - script = "os-images/files/provision-system.sh" - } - - provisioner "shell" { - inline_shebang = "/bin/sh -ex" - inline = [ - "tdnf clean all", - "rm -rf /var/cache/tdnf" - ] - } - - provisioner "shell" { - environment_vars = [ - "SALT_ROOT_DIR=${var.salt_provision_root_dir}" - ] - script = "os-images/files/cleanup-salt.sh" - } - - provisioner "shell" { - environment_vars = [ - "SSH_USERNAME=${var.ssh_username}" - ] - script = "os-images/AWS/files/cleanup-linux.sh" - } - - post-processor "manifest" { - custom_data = { - arch = var.distro_arch - ami_name = local.ami_name - ami_description = local.ami_description - ssh_username = var.ssh_username - instance_type = var.instance_type - is_windows = false - cloudwatch-agent-available = true - slug = "${lower(var.distro_name)}-${var.distro_version}${var.distro_arch == "arm64" ? "-${var.distro_arch}" : ""}" - } - output = "manifest.json" - strip_path = true - } -} diff --git a/os-images/AWS/photon/photon-3-arm64.pkrvars.hcl b/os-images/AWS/photon/photon-3-arm64.pkrvars.hcl deleted file mode 100644 index a5af5a666..000000000 --- a/os-images/AWS/photon/photon-3-arm64.pkrvars.hcl +++ /dev/null @@ -1,4 +0,0 @@ -ami_filter = "photon-ami-3.*" -ami_owner = "937850989293" -distro_arch = "arm64" -instance_type = "m6g.large" diff --git a/os-images/AWS/photon/photon-3-x86_64.pkr.hcl b/os-images/AWS/photon/photon-3-x86_64.pkr.hcl deleted file mode 100644 index 0a3803e9b..000000000 --- a/os-images/AWS/photon/photon-3-x86_64.pkr.hcl +++ /dev/null @@ -1,301 +0,0 @@ -# CLI Variables -variable "ci_build" { type = bool } -variable "aws_region" { type = string } -variable "ssh_keypair_name" { type = string } -variable "ssh_private_key_file" { type = string } -variable "distro_arch" { type = string } -variable "distro_version" { type = string } -variable "skip_create_ami" { - type = bool - default = false -} -variable "runner_version" { - description = "The version (no v prefix) of the GitHub Actions Runner software to install https://github.com/actions/runner/releases" - type = string - default = "2.300.2" -} -variable "install_github_actions_runner" { - description = "Create a user to run the GitHub Actions Runner under." - type = bool - default = false -} - -# Variables set by pkrvars file -variable "instance_type" { - type = string - default = "c5a.large" -} -variable "ssh_username" { - type = string - default = "root" -} - -# Remaining variables -variable "build_type" { - type = string - default = "ci" -} -variable "ami_owner" { - type = string - default = "937850989293" -} - -variable "distro_name" { - type = string - default = "PhotonOS" -} - -variable "ami_filter" { - type = string -} - -variable "ami_name_prefix" { - type = string - default = "salt-project" -} - -variable "state_name" { - type = string - default = "provision" -} - -variable "salt_provision_type" { - type = string - default = "stable" -} - -variable "salt_provision_version" { - type = string - default = "3006.0" -} - -variable "salt_provision_root_dir" { - type = string - default = "/tmp/salt-provision" -} - -locals { - build_timestamp = timestamp() - ami_name = "${var.ami_name_prefix}/${var.build_type}/${lower(var.distro_name)}/${var.distro_version}/${var.distro_arch}/${formatdate("YYYYMMDD.hhmm", local.build_timestamp)}" - ami_description = "${upper(var.build_type)} Image of ${var.distro_name} ${var.distro_version} ${var.distro_arch}" - distro_slug = "${lower(var.distro_name)}-${var.distro_version}-${var.distro_arch}" -} - -data "amazon-ami" "image" { - filters = { - name = var.ami_filter - root-device-type = "ebs" - state = "available" - virtualization-type = "hvm" - architecture = var.distro_arch - } - most_recent = true - owners = [ - var.ami_owner - ] - region = var.aws_region -} - -source "amazon-ebs" "image" { - ami_description = local.ami_description - ami_name = local.ami_name - instance_type = var.instance_type - - ebs_optimized = true - shutdown_behavior = "terminate" - - skip_create_ami = var.skip_create_ami - - ami_users = [ - "178480506716", - "540082622920" - ] - - # ami_groups = [ - # "all" - # ] - - launch_block_device_mappings { - delete_on_termination = true - device_name = "/dev/xvda" - volume_size = 40 - volume_type = "gp3" - } - - region = var.aws_region - - run_tags = { - Name = "Packer {{ upper `${var.build_type}` }} ${var.distro_name} ${var.distro_version} ${var.distro_arch} Builder" - Owner = "SRE" - Salt-Golden-Image = true - create-salt-golden-image = true - created-by = "packer" - } - security_group_filter { - filters = { - group-name = "*-prod-*-golden-images-provision-${var.ci_build ? "private" : "public"}-*" - } - } - source_ami = data.amazon-ami.image.id - ssh_interface = "${var.ci_build ? "private" : "public"}_ip" - ssh_keypair_name = var.ssh_keypair_name - ssh_private_key_file = var.ssh_private_key_file - ssh_username = var.ssh_username - associate_public_ip_address = var.ci_build == false - subnet_filter { - filters = { - "tag:Name" = "*-prod-vpc-${var.ci_build ? "private" : "public"}-*" - } - most_free = true - random = false - } - tags = { - Build-Date = "${local.build_timestamp}" - Build-Type = var.build_type - Name = "Salt Project // ${upper(var.build_type)} // ${var.distro_name} ${var.distro_version} ${var.distro_arch}" - OS-Arch = "${var.distro_arch}" - OS-Name = "${var.distro_name}" - OS-Version = "${var.distro_version}" - Owner = "SRE" - Provision-State-Name = "${var.state_name}" - Salt-Golden-Image = true - created-by = "packer" - no-delete = false - ssh-username = var.ssh_username - "spb:start-github-runner" = false - } -} - -build { - sources = [ - "source.amazon-ebs.image" - ] - - provisioner "shell" { - inline = [ - "df -h" - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell" { - inline = [ - "systemctl mask tmp.mount", - "find /etc/yum.repos.d -type f -exec sed -i 's!dl.bintray.com/vmware!packages.vmware.com/photon/$releasever!' {} ';'", - "tdnf update -y", - "tdnf install -y linux", - "tdnf remove -y linux-aws", - "tdnf install -y fipsify linux-hmacgen", - "if ! grep -q fips=1 /boot/systemd.cfg; then sed -i 's/^systemd_cmdline=.*/& fips=1/' /boot/systemd.cfg; fi", - "if ! grep -q 'FipsMode yes' /etc/ssh/sshd_config; then echo 'FipsMode yes' >> /etc/ssh/sshd_config; fi", - "reboot" - ] - inline_shebang = "/bin/sh -ex" - expect_disconnect = true - pause_after = "10s" - } - - provisioner "shell" { - inline_shebang = "/bin/sh -ex" - inline = [ - "tdnf install -y git vim sudo openssh-server dbus curl rpm tar unzip gnupg" - ] - } - - provisioner "shell" { - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline = [ - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/assets/amazon-cloudwatch-agent.gpg -o /tmp/amazon-cloudwatch-agent.gpg", - "gpg --import /tmp/amazon-cloudwatch-agent.gpg", - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/${var.distro_arch == "x86_64" ? "centos" : "redhat"}/${var.distro_arch == "x86_64" ? "amd64" : "arm64"}/latest/amazon-cloudwatch-agent.rpm -o /tmp/amazon-cloudwatch-agent.rpm", - "curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/${var.distro_arch == "x86_64" ? "centos" : "redhat"}/${var.distro_arch == "x86_64" ? "amd64" : "arm64"}/latest/amazon-cloudwatch-agent.rpm.sig -o /tmp/amazon-cloudwatch-agent.rpm.sig", - "gpg --verify /tmp/amazon-cloudwatch-agent.rpm.sig /tmp/amazon-cloudwatch-agent.rpm", - "rpm -U /tmp/amazon-cloudwatch-agent.rpm", - "systemctl restart amazon-cloudwatch-agent", - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell" { - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" - inline = [ - "curl -f https://awscli.amazonaws.com/awscli-exe-linux-${var.distro_arch == "x86_64" ? "x86_64" : "aarch64"}.zip -o /tmp/awscliv2.zip", - "cd /tmp; unzip awscliv2.zip", - "cd /tmp; ./aws/install", - ] - inline_shebang = "/bin/sh -ex" - } - - provisioner "shell-local" { - environment_vars = [ - "DISTRO_SLUG=${local.distro_slug}", - "SALT_ROOT_DIR=${var.salt_provision_root_dir}", - "INSTALL_GITHUB_ACTIONS_RUNNER=${var.install_github_actions_runner ? "yes" : "no"}", - "INSTALL_GITHUB_ACTIONS_RUNNER_DEPENDENCIES=false", - "GITHUB_ACTIONS_RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${var.runner_version}/actions-runner-linux-${var.distro_arch == "x86_64" ? "x64" : "arm64"}-${var.runner_version}.tar.gz" - ] - script = "os-images/AWS/files/prep-linux.sh" - } - - provisioner "shell" { - environment_vars = [ - "OS_ARCH=${var.distro_arch == "arm64" ? "aarch64" : "x86_64"}", - "SALT_VERSION=${var.salt_provision_version}", - "SALT_PROVISION_TYPE=${var.salt_provision_type}" - ] - script = "os-images/files/provision-salt.sh" - } - - provisioner "file" { - destination = "${var.salt_provision_root_dir}/" - direction = "upload" - generated = true - source = ".tmp/${local.distro_slug}" - } - - provisioner "shell" { - environment_vars = [ - "SALT_ROOT_DIR=${var.salt_provision_root_dir}", - "SALT_STATE=${var.state_name}" - ] - pause_after = "5s" - script = "os-images/files/provision-system.sh" - } - - provisioner "shell" { - inline_shebang = "/bin/sh -ex" - inline = [ - "tdnf clean all", - "rm -rf /var/cache/tdnf" - ] - } - - provisioner "shell" { - environment_vars = [ - "SALT_ROOT_DIR=${var.salt_provision_root_dir}" - ] - script = "os-images/files/cleanup-salt.sh" - } - - provisioner "shell" { - environment_vars = [ - "SSH_USERNAME=${var.ssh_username}" - ] - script = "os-images/AWS/files/cleanup-linux.sh" - } - - post-processor "manifest" { - custom_data = { - arch = var.distro_arch - ami_name = local.ami_name - ami_description = local.ami_description - ssh_username = var.ssh_username - instance_type = var.instance_type - is_windows = false - cloudwatch-agent-available = true - slug = "${lower(var.distro_name)}-${var.distro_version}${var.distro_arch == "arm64" ? "-${var.distro_arch}" : ""}" - } - output = "manifest.json" - strip_path = true - } -} diff --git a/os-images/AWS/photon/photon-3-x86_64.pkrvars.hcl b/os-images/AWS/photon/photon-3-x86_64.pkrvars.hcl deleted file mode 100644 index 24d32b93b..000000000 --- a/os-images/AWS/photon/photon-3-x86_64.pkrvars.hcl +++ /dev/null @@ -1,4 +0,0 @@ -ami_filter = "photon-ami-3.*" -ami_owner = "937850989293" -distro_arch = "x86_64" -instance_type = "t3a.large"