From 6063e98ef07563783a6864550d13fc00139dbad1 Mon Sep 17 00:00:00 2001
From: SuperQ <superq@gmail.com>
Date: Mon, 27 Dec 2021 13:18:51 +0100
Subject: [PATCH] Update CI

* Update to latest CI config.
* Fix up molecule.

Signed-off-by: SuperQ <superq@gmail.com>
---
 .circleci/config.yml              | 35 ++++++++++++++++---------------
 molecule/alternative/playbook.yml |  2 +-
 molecule/default/playbook.yml     |  2 +-
 molecule/latest/playbook.yml      |  2 +-
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index c7391e8..1c7ecb5 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -4,7 +4,7 @@ version: 2.1
 executors:
   python:
     docker:
-      - image: cimg/python:3.9
+      - image: cimg/python:3.10
   publisher:
     docker:
       - image: quay.io/cloudalchemy/publisher:latest
@@ -15,7 +15,6 @@ jobs:
     steps:
       - checkout
       - run: pip install ansible ansible-lint yamllint flake8
-      - run: mkdir -p ~/.ansible/roles && ln -s ~/project ~/.ansible/roles/${CIRCLE_PROJECT_REPONAME}
       - run: ansible-lint
       - run: yamllint .
       - run: flake8
@@ -25,25 +24,21 @@ jobs:
     parameters:
       ansible:
         type: string
+      scenario:
+        type: string
     steps:
       - checkout
       - setup_remote_docker
-      - run: mkdir -p ~/.ansible/roles && ln -s ~/project ~/.ansible/roles/${CIRCLE_PROJECT_REPONAME}
-      - run: pip install "ansible~=<<parameters.ansible >>.0"
+      - run: pip install "ansible~=<< parameters.ansible >>.0"
       - run: pip install -r test-requirements.txt
-      - run: molecule test -s default --destroy always
-      - run: |
-         if [[ -d 'molecule/alternative' ]]; then
-           molecule test -s alternative --destroy always
-         else
-           echo 'No alternative test'
-         fi
-      - run: |
-         if [[ -z "${CIRCLE_PULL_REQUEST}" ]] && [[ -d 'molecule/latest' ]]; then
-           molecule test -s latest --destroy always
-         else
-           echo 'Not running latest on PR'
-         fi
+      - run:
+          no_output_timeout: 60m
+          command: |
+            if [[ -n "${CIRCLE_PULL_REQUEST}" ]] && [[ '<< parameters.scenario >>' == 'latest' ]]; then
+              echo 'Not running latest on PR'
+            else
+              molecule test -s '<< parameters.scenario >>' --destroy always
+            fi
   release:
     executor: publisher
     steps:
@@ -74,6 +69,12 @@ workflows:
               ansible:
                 - "2.9"
                 - "2.10"
+                - "4.10"
+                - "5.1"
+              scenario:
+                - default
+                - alternative
+                - latest
           filters:
             tags:
               only: /.*/
diff --git a/molecule/alternative/playbook.yml b/molecule/alternative/playbook.yml
index ce050ec..ed59c80 100644
--- a/molecule/alternative/playbook.yml
+++ b/molecule/alternative/playbook.yml
@@ -3,7 +3,7 @@
   hosts: all
   any_errors_fatal: true
   roles:
-    - ansible-node-exporter
+    - cloudalchemy.node_exporter
   pre_tasks:
     - name: Create node_exporter cert dir
       file:
diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml
index 1e92855..0411e1a 100644
--- a/molecule/default/playbook.yml
+++ b/molecule/default/playbook.yml
@@ -2,6 +2,6 @@
 - hosts: all
   any_errors_fatal: true
   roles:
-    - ansible-node-exporter
+    - cloudalchemy.node_exporter
   vars:
     node_exporter_web_listen_address: "127.0.0.1:9100"
diff --git a/molecule/latest/playbook.yml b/molecule/latest/playbook.yml
index cafcd8d..7bd28bd 100644
--- a/molecule/latest/playbook.yml
+++ b/molecule/latest/playbook.yml
@@ -3,6 +3,6 @@
   hosts: all
   any_errors_fatal: true
   roles:
-    - ansible-node-exporter
+    - cloudalchemy.node_exporter
   vars:
     node_exporter_version: latest
-- 
GitLab