From f55d35ffb47cd8dbab1f015aa879ae9eea1e9d6a Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Sun, 13 Mar 2022 21:53:44 +1300 Subject: [PATCH 01/24] Use first found - Skipping if file not found --- tasks/main.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index ed12d9c..db13e1e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,8 @@ --- -- include: "{{ ansible_os_family }}.yml" \ No newline at end of file +- name: Include tasks only if one of the files exist, otherwise skip the task + include_tasks: + file: "{{ item }}" + with_first_found: + files: + - "{{ ansible_os_family }}.yml" + skip: True From 630c999fe45e40e45f601a6cccf90903ab88d4fc Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Sun, 13 Mar 2022 21:59:29 +1300 Subject: [PATCH 02/24] Ateempt alternate way to load os family tasks --- tasks/main.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index db13e1e..badeccc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,8 +1,9 @@ --- - name: Include tasks only if one of the files exist, otherwise skip the task - include_tasks: - file: "{{ item }}" - with_first_found: - files: - - "{{ ansible_os_family }}.yml" - skip: True + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - '{{ ansible_os_family }}.yml' + paths: + - 'vars' From c59b7d4c30679cb67adc56241573e4159392285c Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Sun, 13 Mar 2022 22:03:37 +1300 Subject: [PATCH 03/24] Oops, trying to include tasks not vars :( --- tasks/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index badeccc..8001a23 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,9 +1,7 @@ --- - name: Include tasks only if one of the files exist, otherwise skip the task - include_vars: "{{ lookup('first_found', params) }}" + include_tasks: "{{ lookup('first_found', params) }}" vars: params: files: - '{{ ansible_os_family }}.yml' - paths: - - 'vars' From 78e8cff430dbfea265f6c3cc625d6eb6291888cd Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Sun, 13 Mar 2022 22:07:49 +1300 Subject: [PATCH 04/24] return empty list if not found --- tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/main.yml b/tasks/main.yml index 8001a23..f204af3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,3 +5,4 @@ params: files: - '{{ ansible_os_family }}.yml' + skip: true From 6fbdb54e7e1be2191af91bd175762e75ba06b3ae Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Sun, 13 Mar 2022 22:12:20 +1300 Subject: [PATCH 05/24] This time --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index f204af3..8ee4233 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,8 +1,8 @@ --- - name: Include tasks only if one of the files exist, otherwise skip the task - include_tasks: "{{ lookup('first_found', params) }}" + include_tasks: '{{ item }}' vars: params: files: - '{{ ansible_os_family }}.yml' - skip: true + loop: "{{ q('first_found', params, errors='ignore') }}" From 3b0e72a3c39a0173c4bf0c1d0d21d000dd874ada Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 12:18:38 +1300 Subject: [PATCH 06/24] JSONNET configuration added --- .drone.jsonnet | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .drone.jsonnet diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000..53be428 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,55 @@ +local docker_service() = + { + name: 'docker', + image: 'docker:dind', + privileged: 'true', + volumes: { name: 'dockersock', path: '/var/run' }, + }; + +local email_notification() = + { + name: 'notify by email', + image: 'drillster/drone-email', + settings: + { host: 'mail.guise.net.nz', + username: + { from_secret: 'EMAIL_USER' }, + password: + { from_secret: 'EMAIL_PASS' }, + from: 'drone@guise.net.nz' + }, + when: + { status: [ 'changed', 'failure' ] }, + }; + +local test_distro(distribution) = + { + name: 'Test on %(distribution)s' % { distribution: distribution }, + volumes: { name: 'dockersock', path: '/var/run' }, + image: 'guisea/ansible-molecule:latest', + commands: [ + 'sleep 10', // give docker enough time to start + 'mkdir ${DRONE_REPO_NAME}', + 'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}', + 'cd ${DRONE_REPO_NAME}', + 'molecule test' + ], + environment: + { MOLECULE_DISTRO: '%(distribution)s' % { distribution: distribution } + }, + }; + +// Run the steps +{ + steps: [ + [test_distro('centos7'), + email_notification()], + [test_distro('debian10'), + email_notification()], + [test_distro('debian11'), + email_notification()], + ], + services: [ + docker_service(), + ] +} \ No newline at end of file From 93fd1531cb1867f5b1677454ef5ccaa80d842cb9 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 12:21:32 +1300 Subject: [PATCH 07/24] Privileged flag fix --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 53be428..f9e6fdf 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -2,7 +2,7 @@ local docker_service() = { name: 'docker', image: 'docker:dind', - privileged: 'true', + privileged: true, volumes: { name: 'dockersock', path: '/var/run' }, }; From 27e97ea40a7a21f7543e805610a349c5716fa209 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 14:18:48 +1300 Subject: [PATCH 08/24] Update JSONNET --- .drone.jsonnet | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index f9e6fdf..f4ccd85 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,3 +1,7 @@ +local distros = ['centos7', + 'debian10', + 'debian11']; + local docker_service() = { name: 'docker', @@ -6,6 +10,12 @@ local docker_service() = volumes: { name: 'dockersock', path: '/var/run' }, }; + local pipeline(distribution) = { + kind: "pipeline", + type: "docker", + name: "%(distribution)" % { distribution: distribution } +}; + local email_notification() = { name: 'notify by email', @@ -39,17 +49,29 @@ local test_distro(distribution) = }, }; -// Run the steps -{ - steps: [ +local gen_pipeline() = + [{kind: 'pipeline', + type: 'docker', + name: 'Test on %(distro)s' % { distro: distro }, + steps: [ [test_distro('centos7'), email_notification()], [test_distro('debian10'), email_notification()], [test_distro('debian11'), email_notification()], - ], - services: [ - docker_service(), - ] -} \ No newline at end of file + ], + services: [ + docker_service(), + ], + volumes: + { + name: 'dockersock', + temp: {}, + }, + } + for distro in distros]; + +[ + gen_pipeline(), +] From cc3fc78afc4ef48e9915d3ff138e979c569b5e92 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 14:26:47 +1300 Subject: [PATCH 09/24] Use generated output from JSONNET --- .drone.yml | 203 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 117 insertions(+), 86 deletions(-) diff --git a/.drone.yml b/.drone.yml index dc63366..d9b7ddf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,90 +1,121 @@ --- -kind: pipeline -name: centos7 - - -matrix: - DISTRO: - - centos7 - - debian10 - - debian11 - -services: -- name: docker - image: docker:dind - privileged: true +- kind: pipeline + name: Test on centos7 + services: + - image: docker:dind + name: docker + privileged: true + volumes: + name: dockersock + path: /var/run + steps: + - - commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: centos7 + image: guisea/ansible-molecule:latest + name: Test on centos7 + volumes: + name: dockersock + path: /var/run + - image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure + type: docker volumes: - - name: dockersock - path: /var/run - -volumes: -- name: dockersock - temp: {} - -steps: -- name: Test with Molecule centos7 - image: guisea/ansible-molecule:latest + name: dockersock + temp: {} +- kind: pipeline + name: Test on debian10 + services: + - image: docker:dind + name: docker + privileged: true + volumes: + name: dockersock + path: /var/run + steps: + - - commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: debian10 + image: guisea/ansible-molecule:latest + name: Test on debian10 + volumes: + name: dockersock + path: /var/run + - image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure + type: docker volumes: - - name: dockersock - path: /var/run - commands: - - sleep 10 # give docker enough time to start - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: centos7 -- name: notify by email - image: drillster/drone-email - settings: - host: mail.guise.net.nz - username: - from_secret: EMAIL_USER - password: - from_secret: EMAIL_PASS - from: drone@guise.net.nz - when: - status: [ changed, failure ] - ---- -kind: pipeline -name: debian10 - -services: -- name: docker - image: docker:dind - privileged: true + name: dockersock + temp: {} +- kind: pipeline + name: Test on debian11 + services: + - image: docker:dind + name: docker + privileged: true + volumes: + name: dockersock + path: /var/run + steps: + - - commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: debian11 + image: guisea/ansible-molecule:latest + name: Test on debian11 + volumes: + name: dockersock + path: /var/run + - image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure + type: docker volumes: - - name: dockersock - path: /var/run - -volumes: -- name: dockersock - temp: {} - -steps: -- name: Test with Molecule debian10 - image: guisea/ansible-molecule:latest - volumes: - - name: dockersock - path: /var/run - commands: - - sleep 10 # give docker enough time to start - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: debian10 -- name: notify by email - image: drillster/drone-email - settings: - host: mail.guise.net.nz - username: - from_secret: EMAIL_USER - password: - from_secret: EMAIL_PASS - from: drone@guise.net.nz - when: - status: [ changed, failure ] + name: dockersock + temp: {} \ No newline at end of file From 07af26120598cb9006058681d5db45a049b181d1 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 14:35:54 +1300 Subject: [PATCH 10/24] Try again --- .drone.yml | 253 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 148 insertions(+), 105 deletions(-) diff --git a/.drone.yml b/.drone.yml index d9b7ddf..7797a2b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,121 +1,164 @@ --- -- kind: pipeline - name: Test on centos7 - services: - - image: docker:dind - name: docker - privileged: true +kind: pipeline +name: Test on centos7 +services: +- image: docker:dind + name: docker + privileged: true + volumes: + name: dockersock + path: /var/run +steps: +- - commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: centos7 + image: guisea/ansible-molecule:latest + name: Test on centos7 volumes: name: dockersock path: /var/run - steps: - - - commands: - - sleep 10 - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: centos7 - image: guisea/ansible-molecule:latest - name: Test on centos7 - volumes: - name: dockersock - path: /var/run - - image: drillster/drone-email - name: notify by email - settings: - from: drone@guise.net.nz - host: mail.guise.net.nz - password: - from_secret: EMAIL_PASS - username: - from_secret: EMAIL_USER - when: - status: - - changed - - failure - type: docker + - image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure +type: docker +volumes: + name: dockersock + temp: {} +--- +kind: pipeline +name: Test on centos8 +services: +- image: docker:dind + name: docker + privileged: true volumes: name: dockersock - temp: {} -- kind: pipeline - name: Test on debian10 - services: - - image: docker:dind - name: docker - privileged: true + path: /var/run +steps: +- - commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: centos8 + image: guisea/ansible-molecule:latest + name: Test on centos8 volumes: name: dockersock path: /var/run - steps: - - - commands: - - sleep 10 - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: debian10 - image: guisea/ansible-molecule:latest - name: Test on debian10 - volumes: - name: dockersock - path: /var/run - - image: drillster/drone-email - name: notify by email - settings: - from: drone@guise.net.nz - host: mail.guise.net.nz - password: - from_secret: EMAIL_PASS - username: - from_secret: EMAIL_USER - when: - status: - - changed - - failure - type: docker + - image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure +type: docker +volumes: + name: dockersock + temp: {} +--- +kind: pipeline +name: Test on debian10 +services: +- image: docker:dind + name: docker + privileged: true volumes: name: dockersock - temp: {} -- kind: pipeline - name: Test on debian11 - services: - - image: docker:dind - name: docker - privileged: true + path: /var/run +steps: +- - commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: debian10 + image: guisea/ansible-molecule:latest + name: Test on debian10 volumes: name: dockersock path: /var/run - steps: - - - commands: - - sleep 10 - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: debian11 - image: guisea/ansible-molecule:latest - name: Test on debian11 - volumes: - name: dockersock - path: /var/run - - image: drillster/drone-email - name: notify by email - settings: - from: drone@guise.net.nz - host: mail.guise.net.nz - password: - from_secret: EMAIL_PASS - username: - from_secret: EMAIL_USER - when: - status: - - changed - - failure - type: docker + - image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure +type: docker +volumes: + name: dockersock + temp: {} +--- +kind: pipeline +name: Test on debian11 +services: +- image: docker:dind + name: docker + privileged: true volumes: name: dockersock - temp: {} \ No newline at end of file + path: /var/run +steps: +- - commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: debian11 + image: guisea/ansible-molecule:latest + name: Test on debian11 + volumes: + name: dockersock + path: /var/run + - image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure +type: docker +volumes: + name: dockersock + temp: {} \ No newline at end of file From 92c0aec762b1aa9d9041e3717030c7e1466a46d9 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 14:42:46 +1300 Subject: [PATCH 11/24] .. --- .drone.yml | 208 ++++++++++++++++++++++++++--------------------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7797a2b..1aa83dc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,32 +9,32 @@ services: name: dockersock path: /var/run steps: -- - commands: - - sleep 10 - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: centos7 - image: guisea/ansible-molecule:latest - name: Test on centos7 - volumes: - name: dockersock - path: /var/run - - image: drillster/drone-email - name: notify by email - settings: - from: drone@guise.net.nz - host: mail.guise.net.nz - password: - from_secret: EMAIL_PASS - username: - from_secret: EMAIL_USER - when: - status: - - changed - - failure +- commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: centos7 + image: guisea/ansible-molecule:latest + name: Test on centos7 + volumes: + name: dockersock + path: /var/run +- image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure type: docker volumes: name: dockersock @@ -50,32 +50,32 @@ services: name: dockersock path: /var/run steps: -- - commands: - - sleep 10 - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: centos8 - image: guisea/ansible-molecule:latest - name: Test on centos8 - volumes: - name: dockersock - path: /var/run - - image: drillster/drone-email - name: notify by email - settings: - from: drone@guise.net.nz - host: mail.guise.net.nz - password: - from_secret: EMAIL_PASS - username: - from_secret: EMAIL_USER - when: - status: - - changed - - failure +- commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: centos8 + image: guisea/ansible-molecule:latest + name: Test on centos8 + volumes: + name: dockersock + path: /var/run +- image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure type: docker volumes: name: dockersock @@ -91,32 +91,32 @@ services: name: dockersock path: /var/run steps: -- - commands: - - sleep 10 - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: debian10 - image: guisea/ansible-molecule:latest - name: Test on debian10 - volumes: - name: dockersock - path: /var/run - - image: drillster/drone-email - name: notify by email - settings: - from: drone@guise.net.nz - host: mail.guise.net.nz - password: - from_secret: EMAIL_PASS - username: - from_secret: EMAIL_USER - when: - status: - - changed - - failure +- commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: debian10 + image: guisea/ansible-molecule:latest + name: Test on debian10 + volumes: + name: dockersock + path: /var/run +- image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure type: docker volumes: name: dockersock @@ -132,32 +132,32 @@ services: name: dockersock path: /var/run steps: -- - commands: - - sleep 10 - - mkdir ${DRONE_REPO_NAME} - - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} - - cd ${DRONE_REPO_NAME} - - molecule test - environment: - MOLECULE_DISTRO: debian11 - image: guisea/ansible-molecule:latest - name: Test on debian11 - volumes: - name: dockersock - path: /var/run - - image: drillster/drone-email - name: notify by email - settings: - from: drone@guise.net.nz - host: mail.guise.net.nz - password: - from_secret: EMAIL_PASS - username: - from_secret: EMAIL_USER - when: - status: - - changed - - failure +- commands: + - sleep 10 + - mkdir ${DRONE_REPO_NAME} + - rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME} + - cd ${DRONE_REPO_NAME} + - molecule test + environment: + MOLECULE_DISTRO: debian11 + image: guisea/ansible-molecule:latest + name: Test on debian11 + volumes: + name: dockersock + path: /var/run +- image: drillster/drone-email + name: notify by email + settings: + from: drone@guise.net.nz + host: mail.guise.net.nz + password: + from_secret: EMAIL_PASS + username: + from_secret: EMAIL_USER + when: + status: + - changed + - failure type: docker volumes: name: dockersock From cc436f4fb150fe43901e30c4e264e8852d9ca09a Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 14:45:23 +1300 Subject: [PATCH 12/24] ... --- .drone.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.drone.yml b/.drone.yml index 1aa83dc..038d3ae 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,7 +6,7 @@ services: name: docker privileged: true volumes: - name: dockersock + - name: dockersock path: /var/run steps: - commands: @@ -20,7 +20,7 @@ steps: image: guisea/ansible-molecule:latest name: Test on centos7 volumes: - name: dockersock + - name: dockersock path: /var/run - image: drillster/drone-email name: notify by email @@ -37,7 +37,7 @@ steps: - failure type: docker volumes: - name: dockersock +- name: dockersock temp: {} --- kind: pipeline @@ -47,7 +47,7 @@ services: name: docker privileged: true volumes: - name: dockersock + - name: dockersock path: /var/run steps: - commands: @@ -61,7 +61,7 @@ steps: image: guisea/ansible-molecule:latest name: Test on centos8 volumes: - name: dockersock + - name: dockersock path: /var/run - image: drillster/drone-email name: notify by email @@ -78,7 +78,7 @@ steps: - failure type: docker volumes: - name: dockersock +- name: dockersock temp: {} --- kind: pipeline @@ -88,7 +88,7 @@ services: name: docker privileged: true volumes: - name: dockersock + - name: dockersock path: /var/run steps: - commands: @@ -102,7 +102,7 @@ steps: image: guisea/ansible-molecule:latest name: Test on debian10 volumes: - name: dockersock + - name: dockersock path: /var/run - image: drillster/drone-email name: notify by email @@ -119,7 +119,7 @@ steps: - failure type: docker volumes: - name: dockersock +- name: dockersock temp: {} --- kind: pipeline @@ -129,7 +129,7 @@ services: name: docker privileged: true volumes: - name: dockersock + - name: dockersock path: /var/run steps: - commands: @@ -143,7 +143,7 @@ steps: image: guisea/ansible-molecule:latest name: Test on debian11 volumes: - name: dockersock + - name: dockersock path: /var/run - image: drillster/drone-email name: notify by email @@ -160,5 +160,5 @@ steps: - failure type: docker volumes: - name: dockersock +- name: dockersock temp: {} \ No newline at end of file From da6c85c5b1b5d7f06aa8e8ee05cdbdc53ca7eadb Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 14:58:20 +1300 Subject: [PATCH 13/24] JSONNET updated --- .drone.jsonnet | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index f4ccd85..5ece680 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,21 +1,19 @@ -local distros = ['centos7', +// Distros to Test on ;) +local distros = ['centos7', + 'centos8', 'debian10', 'debian11']; + +/* Configuration of DIND */ local docker_service() = { name: 'docker', image: 'docker:dind', privileged: true, - volumes: { name: 'dockersock', path: '/var/run' }, + volumes: [{ name: 'dockersock', path: '/var/run' },], }; - local pipeline(distribution) = { - kind: "pipeline", - type: "docker", - name: "%(distribution)" % { distribution: distribution } -}; - local email_notification() = { name: 'notify by email', @@ -35,7 +33,7 @@ local email_notification() = local test_distro(distribution) = { name: 'Test on %(distribution)s' % { distribution: distribution }, - volumes: { name: 'dockersock', path: '/var/run' }, + volumes: [{ name: 'dockersock', path: '/var/run' },], image: 'guisea/ansible-molecule:latest', commands: [ 'sleep 10', // give docker enough time to start @@ -49,29 +47,25 @@ local test_distro(distribution) = }, }; -local gen_pipeline() = - [{kind: 'pipeline', +local gen_pipeline(distro) = + {kind: 'pipeline', type: 'docker', name: 'Test on %(distro)s' % { distro: distro }, steps: [ - [test_distro('centos7'), + test_distro(distro), email_notification()], - [test_distro('debian10'), - email_notification()], - [test_distro('debian11'), - email_notification()], - ], services: [ docker_service(), ], volumes: - { + [{ name: 'dockersock', temp: {}, - }, - } - for distro in distros]; + },], + }; +// Generate the output [ - gen_pipeline(), -] + gen_pipeline(distro) + for distro in distros +] \ No newline at end of file From e6c7469fbc486d455cff612c62bd25a400443cf4 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 15:29:51 +1300 Subject: [PATCH 14/24] Add rocky8 --- .drone.jsonnet | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 5ece680..fe790a8 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,6 +1,7 @@ // Distros to Test on ;) local distros = ['centos7', - 'centos8', + 'centos8', + 'rocky8', 'debian10', 'debian11']; From f11daf186b587b85c07c8e622551b207718f9213 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 15:34:17 +1300 Subject: [PATCH 15/24] Corrected distro name --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index fe790a8..7ba520e 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,7 +1,7 @@ // Distros to Test on ;) local distros = ['centos7', 'centos8', - 'rocky8', + 'rockylinux8', 'debian10', 'debian11']; From b5d64505ea1491135189f0a9255da978eed0d68c Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 16:24:26 +1300 Subject: [PATCH 16/24] Include from external file. --- .drone.jsonnet | 48 ++++-------------------------------------- .drone/utils.libsonnet | 42 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 44 deletions(-) create mode 100644 .drone/utils.libsonnet diff --git a/.drone.jsonnet b/.drone.jsonnet index 7ba520e..70803ee 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,57 +6,17 @@ local distros = ['centos7', 'debian11']; -/* Configuration of DIND */ -local docker_service() = - { - name: 'docker', - image: 'docker:dind', - privileged: true, - volumes: [{ name: 'dockersock', path: '/var/run' },], - }; - -local email_notification() = - { - name: 'notify by email', - image: 'drillster/drone-email', - settings: - { host: 'mail.guise.net.nz', - username: - { from_secret: 'EMAIL_USER' }, - password: - { from_secret: 'EMAIL_PASS' }, - from: 'drone@guise.net.nz' - }, - when: - { status: [ 'changed', 'failure' ] }, - }; - -local test_distro(distribution) = - { - name: 'Test on %(distribution)s' % { distribution: distribution }, - volumes: [{ name: 'dockersock', path: '/var/run' },], - image: 'guisea/ansible-molecule:latest', - commands: [ - 'sleep 10', // give docker enough time to start - 'mkdir ${DRONE_REPO_NAME}', - 'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}', - 'cd ${DRONE_REPO_NAME}', - 'molecule test' - ], - environment: - { MOLECULE_DISTRO: '%(distribution)s' % { distribution: distribution } - }, - }; +local utils = import './.drone/docker_service.libsonnet'; local gen_pipeline(distro) = {kind: 'pipeline', type: 'docker', name: 'Test on %(distro)s' % { distro: distro }, steps: [ - test_distro(distro), - email_notification()], + utils.test_distro(distro), + utils.email_notification()], services: [ - docker_service(), + utils.docker_service(), ], volumes: [{ diff --git a/.drone/utils.libsonnet b/.drone/utils.libsonnet new file mode 100644 index 0000000..51becad --- /dev/null +++ b/.drone/utils.libsonnet @@ -0,0 +1,42 @@ +{ +docker_service():: + { + name: 'docker', + image: 'docker:dind', + privileged: true, + volumes: [{ name: 'dockersock', path: '/var/run' },], + }, + +email_notification():: + { + name: 'notify by email', + image: 'drillster/drone-email', + settings: + { host: 'mail.guise.net.nz', + username: + { from_secret: 'EMAIL_USER' }, + password: + { from_secret: 'EMAIL_PASS' }, + from: 'drone@guise.net.nz' + }, + when: + { status: [ 'changed', 'failure' ] }, + }, + +test_distro(distribution):: + { + name: 'Test on %(distribution)s' % { distribution: distribution }, + volumes: [{ name: 'dockersock', path: '/var/run' },], + image: 'guisea/ansible-molecule:latest', + commands: [ + 'sleep 10', // give docker enough time to start + 'mkdir ${DRONE_REPO_NAME}', + 'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}', + 'cd ${DRONE_REPO_NAME}', + 'molecule test' + ], + environment: + { MOLECULE_DISTRO: '%(distribution)s' % { distribution: distribution } + }, + }, +} From 493260028f51c48adda84b5e2093085a7aa96464 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 16:25:32 +1300 Subject: [PATCH 17/24] Corrected filename --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 70803ee..b697a9b 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,7 +6,7 @@ local distros = ['centos7', 'debian11']; -local utils = import './.drone/docker_service.libsonnet'; +local utils = import './.drone/utils.libsonnet'; local gen_pipeline(distro) = {kind: 'pipeline', From 499b2c3b2b9625d2e7ac8afb0ccba8e4051bb5e2 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 16:28:59 +1300 Subject: [PATCH 18/24] Unable to import from path --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index b697a9b..ffea564 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,7 +6,7 @@ local distros = ['centos7', 'debian11']; -local utils = import './.drone/utils.libsonnet'; +local utils = import '.drone/utils.libsonnet'; local gen_pipeline(distro) = {kind: 'pipeline', From 2339d13b1791b25f50c06829dbff1f9b91726bd9 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 16:31:23 +1300 Subject: [PATCH 19/24] include from project root --- .drone.jsonnet | 2 +- .drone/utils.libsonnet => .drone.utils.libsonnet | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .drone/utils.libsonnet => .drone.utils.libsonnet (100%) diff --git a/.drone.jsonnet b/.drone.jsonnet index ffea564..54839ac 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,7 +6,7 @@ local distros = ['centos7', 'debian11']; -local utils = import '.drone/utils.libsonnet'; +local utils = import '.drone.utils.libsonnet'; local gen_pipeline(distro) = {kind: 'pipeline', diff --git a/.drone/utils.libsonnet b/.drone.utils.libsonnet similarity index 100% rename from .drone/utils.libsonnet rename to .drone.utils.libsonnet From f6068fa5fab26e8634848ae9822e8e1f1069f95f Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 17:02:15 +1300 Subject: [PATCH 20/24] try import again --- .drone.jsonnet | 2 +- .drone.utils.libsonnet => utils.libsonnet | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .drone.utils.libsonnet => utils.libsonnet (100%) diff --git a/.drone.jsonnet b/.drone.jsonnet index 54839ac..5d632f4 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,7 +6,7 @@ local distros = ['centos7', 'debian11']; -local utils = import '.drone.utils.libsonnet'; +local utils = import 'utils.libsonnet'; local gen_pipeline(distro) = {kind: 'pipeline', diff --git a/.drone.utils.libsonnet b/utils.libsonnet similarity index 100% rename from .drone.utils.libsonnet rename to utils.libsonnet From 372d29435fbf9ecac0e21c793d7adf3d2456bf93 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 17:05:01 +1300 Subject: [PATCH 21/24] Revert .drone.jsonnet --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 5d632f4..b697a9b 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,7 +6,7 @@ local distros = ['centos7', 'debian11']; -local utils = import 'utils.libsonnet'; +local utils = import './.drone/utils.libsonnet'; local gen_pipeline(distro) = {kind: 'pipeline', From 96ea18daca78f9ad9db7e8ef64dc117b20aded27 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 17:08:34 +1300 Subject: [PATCH 22/24] Reverted jsonnet conf --- .drone.jsonnet | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index b697a9b..7ba520e 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,17 +6,57 @@ local distros = ['centos7', 'debian11']; -local utils = import './.drone/utils.libsonnet'; +/* Configuration of DIND */ +local docker_service() = + { + name: 'docker', + image: 'docker:dind', + privileged: true, + volumes: [{ name: 'dockersock', path: '/var/run' },], + }; + +local email_notification() = + { + name: 'notify by email', + image: 'drillster/drone-email', + settings: + { host: 'mail.guise.net.nz', + username: + { from_secret: 'EMAIL_USER' }, + password: + { from_secret: 'EMAIL_PASS' }, + from: 'drone@guise.net.nz' + }, + when: + { status: [ 'changed', 'failure' ] }, + }; + +local test_distro(distribution) = + { + name: 'Test on %(distribution)s' % { distribution: distribution }, + volumes: [{ name: 'dockersock', path: '/var/run' },], + image: 'guisea/ansible-molecule:latest', + commands: [ + 'sleep 10', // give docker enough time to start + 'mkdir ${DRONE_REPO_NAME}', + 'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}', + 'cd ${DRONE_REPO_NAME}', + 'molecule test' + ], + environment: + { MOLECULE_DISTRO: '%(distribution)s' % { distribution: distribution } + }, + }; local gen_pipeline(distro) = {kind: 'pipeline', type: 'docker', name: 'Test on %(distro)s' % { distro: distro }, steps: [ - utils.test_distro(distro), - utils.email_notification()], + test_distro(distro), + email_notification()], services: [ - utils.docker_service(), + docker_service(), ], volumes: [{ From fb48b04840f49cb4cfd5111b84c006b2183e26e1 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 22:24:49 +1300 Subject: [PATCH 23/24] Allow RHEL 8 installation --- defaults/main.yml | 1 - tasks/common.yml | 5 +++++ tasks/main.yml | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tasks/common.yml diff --git a/defaults/main.yml b/defaults/main.yml index 9c1bdd7..8893fe2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,7 +17,6 @@ postfix_configure: false common_packages: - libselinux-python - - MySQL-python - nano - git - htop diff --git a/tasks/common.yml b/tasks/common.yml new file mode 100644 index 0000000..8f43b50 --- /dev/null +++ b/tasks/common.yml @@ -0,0 +1,5 @@ +--- +- include_tasks: networking.yml +- include_tasks: communication.yml +- include_tasks: grub.yml +- include_tasks: motd.yml \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 8ee4233..31ef1b3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,4 +5,5 @@ params: files: - '{{ ansible_os_family }}.yml' + - 'common.yml' loop: "{{ q('first_found', params, errors='ignore') }}" From c40fc21029ecab08847bde69284e1214a7350082 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 14 Mar 2022 22:31:52 +1300 Subject: [PATCH 24/24] removed libeselinux-python (Not available RHEL8) --- defaults/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 8893fe2..a01da50 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -16,7 +16,6 @@ common_grub_timeout: 5 postfix_configure: false common_packages: - - libselinux-python - nano - git - htop