From bcdfc914dbacb81c3e62b48b1a1254fc9aaa9230 Mon Sep 17 00:00:00 2001 From: shnee Date: Mon, 2 May 2022 16:16:12 -0400 Subject: [PATCH] Added GitHub actions. Added missing template. - Added a Github actions ci file. - Added a template that was accidentally left out. This template is required for the cli_parse module to work. --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++ molecule/default/molecule.yml | 6 +++++ tasks/main.yml | 2 +- templates/linux_cat_os-release.yaml | 5 ++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 templates/linux_cat_os-release.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7ebe6c9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +--- +name: ci +'on': + push: + #branches: + # - master + +jobs: + + test: + name: molecule + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install pypi dep. + run: pip3 install molecule molecule-docker docker yamllint ansible-lint + + # The ansible.netcommon is needed for the native parser of cli_parse. + # TODO Add these to a requirements.yml + - name: Install ansible deps. + run: | + ansible-galaxy collection install \ + ansible.utils \ + ansible.netcommon \ + community.docker + + - name: Run molecule. + run: molecule test + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 52c4cd9..3bc7c82 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -1,4 +1,10 @@ --- + +# TODO Consider adding Makefile. The Makefile can add the color vars and +# potentially have a single way of doing things for different CI pipelines. In +# addition a Makefile could be used to script running this on N distros if we +# get too many. + dependency: name: galaxy driver: diff --git a/tasks/main.yml b/tasks/main.yml index 3ca979c..78a6932 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Retrieve and parse the contents of /etc/os-release - ansible.netcommon.cli_parse: + ansible.utils.cli_parse: command: cat /etc/os-release parser: name: ansible.netcommon.native diff --git a/templates/linux_cat_os-release.yaml b/templates/linux_cat_os-release.yaml new file mode 100644 index 0000000..590635f --- /dev/null +++ b/templates/linux_cat_os-release.yaml @@ -0,0 +1,5 @@ +--- +- example: ID=manjaro + getval: '^\s*(?P\S+)\s*=\s*(?P.*)$' + result: + "{{ key }}": "{{ val }}"