---
- 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: "{{ hostname | default('cockpit-aws-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:
      loop: "{{ ec2.instances }}"

- name: Configure instances
  hosts: launched
  become: true
  gather_facts: true
  roles:
    - role: users
      vars:
        user: ec2-user
    - ci-data-cache
    - nested-kvm
    - required-packages
    - install-secrets-dir
    - role: tasks-systemd
      vars:
        # fill up the 96 CPUs/188 GiB RAM
        instances: 18
  tasks:
    - name: Set useful host name
      hostname:
        name: "{{ hostname | default('cockpit-aws-tasks') }}"

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

  tasks:
    - import_tasks: tasks/launch-coreos.yml
      vars:
        tag_name: "{{ hostname | default('cockpit-aws-tasks') }}"
        tag_service_component: Tasks
        instance_type: c5.metal
        # ARR-US-East-1 (Red Hat internal VPN) InternalB
        vpc_subnet_id: subnet-05dd25fba5582bb6a
        volumes:
          - device_name: /dev/xvda
            ebs:
              volume_size: 800
              delete_on_termination: true

- name: Configure instances
  hosts: launched
  vars_files: aws_defaults.yml
  roles:
    - role: users
      vars:
        user: "{{ aws_coreos_defaultuser }}"
    - ci-data-cache
    - nested-kvm
    - install-secrets-dir
    - role: tasks-systemd
      vars:
        # fill up the 96 CPUs/188 GiB RAM
        instances: 18
  tasks:
    - name: Set useful host name
      hostname:
        name: "{{ hostname | default('cockpit-aws-tasks') }}"

Use Fedora CoreOS for tasks
ansible: Use Fedora CoreOS for tasks

Similarly to commit 9cccfd9, move launch-tasks.yml to launch-coreos.

Adjust the device name, as the root volume is now called /dev/xvda instead of
/dev/sda1 with CoreOS and the new ec2_instance API.
