---
- name: Setup satellite configuration
  hosts: localhost
  gather_facts: false
  vars_files: setup.yml
  vars:
    refresh_satellite_manifest: true

  tasks:
    - name: Refresh manifest  # noqa: args[module] - required parameters provided with environment vars
      redhat.satellite.subscription_manifest:
        organization: "Default Organization"
        state: refreshed
      when: refresh_satellite_manifest

    - name: Setup CV
      ansible.builtin.include_role:
        name: redhat.satellite.content_views

    - name: Publish CV
      ansible.builtin.include_role:
        name: redhat.satellite.content_view_publish
      vars:  # noqa var-naming[no-role-prefix]
        satellite_content_views:
          - RHEL7
          - RHEL8

    - name: Setup Lifecycle Environment
      ansible.builtin.include_role:
        name: redhat.satellite.lifecycle_environments

    - name: Content view publish  # noqa: args[module] - required parameters provided with environment vars
      redhat.satellite.content_view_version:
        organization: "{{ satellite_organization }}"
        content_view: "{{ item }}"
        lifecycle_environments:
          - "{{ item }}_Dev"
          - "{{ item }}_QA"
          - "{{ item }}_Prod"
      loop:
        - RHEL7
        - RHEL8

    - name: Setup activation_keys
      ansible.builtin.include_role:
        name: redhat.satellite.activation_keys

    - name: Add SCAP Tailoring File  # noqa: args[module] - required parameters provided with environment vars
      redhat.satellite.scap_tailoring_file:
        name: RHEL7_STIG
        organizations: "{{ satellite_organization }}"
        scap_file: "{{ item }}"
      loop:
        - files/ssg-rhel7-ds-tailoring.xml
        - files/ssg-rhel8-ds-tailoring-stig-gui.xml
