---
- name: Create tasks runner EC2 instance
  hosts: localhost
  gather_facts: false
  vars_files: aws_defaults.yml

  tasks:
    - name: Create EC2 instance
      ec2:
        key_name: "{{ aws_key_name }}"
        region: "{{ aws_region }}"
        image: "{{ aws_rhel_ami }}"
        instance_type: c5.metal
        monitoring: true
        # ARR-US-East-1 (Red Hat internal VPN) InternalB
        vpc_subnet_id: subnet-05dd25fba5582bb6a
        volumes:
          - device_name: /dev/sda1
            volume_size: 200
            delete_on_termination: true
        wait: true
        instance_tags:
          Name: cockpit-tasks
          ServiceOwner: FrontDoorSST
          ServiceName: FrontDoorCI
          ServiceComponent: Tasks
          ServicePhase: Prod
          AppCode: ARR-001
      register: ec2

    - name: Add new instance to host group
      add_host:
        hostname: "{{ item.private_ip }}"
        groupname: launched
      loop: "{{ ec2.instances }}"

    - name: Wait for SSH to come up
      delegate_to: "{{ item.private_ip }}"
      wait_for_connection:
        # metal instances take a long time to initialize
        delay: 120
        sleep: 30
        timeout: 1800
      loop: "{{ ec2.instances }}"

- name: Configure instances
  hosts: launched
  become: true
  gather_facts: true
  tasks:
    - name: Set useful host name
      hostname:
        name: aws-tasks

---
- name: Create tasks runner EC2 instance
  hosts: localhost
  gather_facts: false
  vars_files: aws_defaults.yml

  tasks:
    - name: Create EC2 instance
      ec2:
        key_name: "{{ aws_key_name }}"
        region: "{{ aws_region }}"
        image: "{{ aws_rhel_ami }}"
        instance_type: c5.metal
        monitoring: true
        # ARR-US-East-1 (Red Hat internal VPN) InternalB
        vpc_subnet_id: subnet-05dd25fba5582bb6a
        volumes:
          - device_name: /dev/sda1
            volume_size: 800
            delete_on_termination: true
        wait: true
        instance_tags:
          Name: cockpit-tasks
          ServiceOwner: FrontDoorSST
          ServiceName: FrontDoorCI
          ServiceComponent: Tasks
          ServicePhase: Prod
          AppCode: ARR-001
      register: ec2

    - name: Add new instance to host group
      add_host:
        hostname: "{{ item.private_ip }}"
        groupname: launched
      loop: "{{ ec2.instances }}"

    - name: Wait for SSH to come up
      delegate_to: "{{ item.private_ip }}"
      wait_for_connection:
        # metal instances take a long time to initialize
        delay: 120
        sleep: 30
        timeout: 1800
      loop: "{{ ec2.instances }}"

- name: Configure instances
  hosts: launched
  become: true
  gather_facts: true
  tasks:
    - name: Set useful host name
      hostname:
        name: aws-tasks

Increase disk size of tasks runner
aws: Increase disk size of tasks runner

200 GB was not enough for the number of tasks containers that the CPU
and RAM are capable of sustaining, so they kept running into ENOSPC.
