---
stages:
- ansible lint
- x86 Systems

Ansible Lint:
  stage: ansible lint
  image: 
    name: fedora:latest
  before_script:
    - dnf install -y git ansible python3-ansible-lint
    - export ANSIBLE_CONFIG=$(pwd)/ansible.cfg
    - ./install-ansible-modules.sh
    - ansible-lint --version
  script:
    - ansible-lint --force-color . &> lint-output.txt
    - cat lint-output.txt
    - if [ ! -z "$(cat lint-output.txt)" ]; then echo "Lint returned with warnings/fails"; exit 1; fi

Run Workstation playbook on fedora:
  stage: x86 Systems
  image: 
    name: fedora:latest
  script:
  - dnf install -y ansible python3-pip
  - pip3 install -r ci-requirements.txt
  - mkdir /tmp/artifacts
  - ./run_play.sh workstation
  - mv /tmp/artifacts/workstation-*.xml report.xml
  artifacts:
    when: always
    reports:
      junit: report.xml

Run cli-tools playbook on centos:
  stage: x86 Systems
  image: 
    name: quay.io/centos/centos:stream8
  script:
  - dnf install -y epel-release dnf-plugins-core
  - dnf install -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
  - dnf makecache
  - dnf install -y ansible python3-pip
  - pip3 install -r ci-requirements.txt
  - mkdir /tmp/artifacts
  - ./run_play.sh cli-tools
  - mv /tmp/artifacts/cli-tools-*.xml report.xml
  artifacts:
    when: always
    reports:
      junit: report.xml

Run Workstation playbook on ubuntu:
  stage: x86 Systems
  image: 
    name: ubuntu:latest
  script:
  - export DEBIAN_FRONTEND=noninteractive
  - apt-get update
  - apt install -y software-properties-common
  - add-apt-repository -y --update ppa:ansible/ansible
  - apt-get install -y ansible python3-pip python3-apt
  - pip3 install -r ci-requirements.txt
  - mkdir /tmp/artifacts
  - ./run_play.sh workstation
  - mv /tmp/artifacts/workstation-*.xml report.xml
  artifacts:
    when: always
    reports:
      junit: report.xml

Run cli-tools playbook on debian:
  stage: x86 Systems
  image: 
    name: debian:latest
  script:
  - apt-get update
  - apt-get install -y ansible python3-pip python3-apt
  - pip3 install -r ci-requirements.txt
  - mkdir /tmp/artifacts
  - ./run_play.sh cli-tools
  - mv /tmp/artifacts/cli-tools-*.xml report.xml
  artifacts:
    when: always
    reports:
      junit: report.xml

