From c0e107641fdfe0399e65809df73c74a44a620d69 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 12:13:40 -0500 Subject: [PATCH 01/16] update .drone.yml --- .drone.yml | 62 ++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/.drone.yml b/.drone.yml index 21e8c5a..0d17c74 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,44 +23,38 @@ steps: ############################################################################### - # - name: "Ansible-Galaxy: Install from requirements.yml" - # image: gitea.thezengarden.net/podman/images/ansible-dev:latest - # commands: - # - ansible-galaxy install -r $DRONE_WORKSPACE/requirements.yml - # when: - # branch: - # - development - # event: - # exclude: - # - pull_request + - name: "Ansible-Galaxy: Install from requirements.yml" + image: gitea.thezengarden.net/podman/images/ansible-dev:latest + commands: + - ansible-galaxy install -r $DRONE_WORKSPACE/requirements.yml + when: + branch: + - development + event: [push] - # - name: "Syntax check and Ansible Lint" - # image: gitea.thezengarden.net/podman/images/ansible-dev:latest - # commands: - # - ansible-lint --offline $DRONE_WORKSPACE - # - ansible-playbook --syntax-check $DRONE_WORKSPACE/hello.yml - # when: - # branch: - # - development - # event: - # exclude: - # - pull_request + - name: "Syntax check and Ansible Lint" + image: gitea.thezengarden.net/podman/images/ansible-dev:latest + commands: + - ansible-lint --offline $DRONE_WORKSPACE + - ansible-playbook --syntax-check $DRONE_WORKSPACE/hello.yml + when: + branch: + - development + event: [push] - # - name: "Test playbook execution" - # image: gitea.thezengarden.net/podman/images/ansible-dev:latest - # environment: - # ANSIBLE_INVENTORY: - # from_secret: ansible_inventory - # commands: - # - ansible-playbook -v -i 127.0.0.1, --connection=local $DRONE_WORKSPACE/hello.yml - # when: - # branch: - # - development - # event: - # exclude: - # - pull_request + - name: "Test playbook execution" + image: gitea.thezengarden.net/podman/images/ansible-dev:latest + environment: + ANSIBLE_INVENTORY: + from_secret: ansible_inventory + commands: + - ansible-playbook -v -i 127.0.0.1, --connection=local $DRONE_WORKSPACE/hello.yml + when: + branch: + - development + event: [push] ############################################################################### From c3d223f289fd954efe7d2c2c9dcd312d449e5f0c Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 12:19:13 -0500 Subject: [PATCH 02/16] remove empty line --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 0d17c74..80f4565 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,7 +17,6 @@ steps: event: [push] - ############################################################################### ############################################################################### ############################################################################### From 8186d8d4ae0bfc32d9e15ab06d521e3917a6c607 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:17:45 -0500 Subject: [PATCH 03/16] re-order tests --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 80f4565..dd74b32 100644 --- a/.drone.yml +++ b/.drone.yml @@ -35,8 +35,8 @@ steps: - name: "Syntax check and Ansible Lint" image: gitea.thezengarden.net/podman/images/ansible-dev:latest commands: - - ansible-lint --offline $DRONE_WORKSPACE - ansible-playbook --syntax-check $DRONE_WORKSPACE/hello.yml + - ansible-lint --offline $DRONE_WORKSPACE when: branch: - development From c6c3bf23d703ad4245c9023efbfdce1b678ded2a Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:19:31 -0500 Subject: [PATCH 04/16] create syntax error for testing --- hello.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hello.yml b/hello.yml index 3ee6e41..b43e454 100644 --- a/hello.yml +++ b/hello.yml @@ -8,3 +8,8 @@ - name: Say Hello world ansible.builtin.debug: msg: Hello world! + + + - name: This should generate a syntax error but pass ansible-lint + ansible.builtin.debug: + mg: "this is incorrect, and should be `msg` instead!" From 3a02d1d9bdecf54b88812c79dee85f9ab958ceae Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:26:42 -0500 Subject: [PATCH 05/16] remove syntax check as ansible-lint already does this; see: https://ansible.readthedocs.io/projects/lint/rules/syntax-check/ --- .drone.yml | 1 - hello.yml | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index dd74b32..754efc7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -35,7 +35,6 @@ steps: - name: "Syntax check and Ansible Lint" image: gitea.thezengarden.net/podman/images/ansible-dev:latest commands: - - ansible-playbook --syntax-check $DRONE_WORKSPACE/hello.yml - ansible-lint --offline $DRONE_WORKSPACE when: branch: diff --git a/hello.yml b/hello.yml index b43e454..a7bb415 100644 --- a/hello.yml +++ b/hello.yml @@ -4,12 +4,10 @@ become: false gather_facts: false + bob: + - is great + tasks: - name: Say Hello world ansible.builtin.debug: msg: Hello world! - - - - name: This should generate a syntax error but pass ansible-lint - ansible.builtin.debug: - mg: "this is incorrect, and should be `msg` instead!" From 2ed92a0edae7f7d54a34b465a6879f79ae199f1d Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:34:20 -0500 Subject: [PATCH 06/16] fix hello.yml; .drone-ci.yml refinements --- .drone.yml | 31 ++++++++++++++++--------------- hello.yml | 5 +---- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.drone.yml b/.drone.yml index 754efc7..a4f66d8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,12 +1,18 @@ --- -name: Ansible Playbook Lint and Test Execution +name: run_ansible_tests kind: pipeline type: docker +environment: + ANSIBLE_DOCKER_IMAGE : gitea.thezengarden.net/podman/images/ansible-dev:latest + ANSIBLE_INVENTORY : "-i 127.0.0.1, --connection=local" + ANSIBLE_PLAYBOOK : hello.yml + + steps: - - name: "Verify environment" - image: gitea.thezengarden.net/podman/images/ansible-dev:latest + - name: "ansible_environment_verify" + image: "$ANSIBLE_DOCKER_IMAGE" commands: - git log -1 - ansible --version @@ -17,13 +23,8 @@ steps: event: [push] -############################################################################### -############################################################################### -############################################################################### - - - - name: "Ansible-Galaxy: Install from requirements.yml" - image: gitea.thezengarden.net/podman/images/ansible-dev:latest + - name: "ansible_galaxy_requirements" + image: "$ANSIBLE_DOCKER_IMAGE" commands: - ansible-galaxy install -r $DRONE_WORKSPACE/requirements.yml when: @@ -32,8 +33,8 @@ steps: event: [push] - - name: "Syntax check and Ansible Lint" - image: gitea.thezengarden.net/podman/images/ansible-dev:latest + - name: "ansible_lint" + image: "$ANSIBLE_DOCKER_IMAGE" commands: - ansible-lint --offline $DRONE_WORKSPACE when: @@ -42,13 +43,13 @@ steps: event: [push] - - name: "Test playbook execution" - image: gitea.thezengarden.net/podman/images/ansible-dev:latest + - name: "ansible_playbook_execution" + image: "$ANSIBLE_DOCKER_IMAGE" environment: ANSIBLE_INVENTORY: from_secret: ansible_inventory commands: - - ansible-playbook -v -i 127.0.0.1, --connection=local $DRONE_WORKSPACE/hello.yml + - ansible-playbook -v $ANSIBLE_INVENTORY $DRONE_WORKSPACE/$ANSIBLE_PLAYBOOK when: branch: - development diff --git a/hello.yml b/hello.yml index a7bb415..a90c638 100644 --- a/hello.yml +++ b/hello.yml @@ -1,11 +1,8 @@ - name: Hello world - hosts: localhost - connection: local + hosts: all become: false gather_facts: false - bob: - - is great tasks: - name: Say Hello world From af2c35003c24914437d04917c9dde198a1bb3994 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:35:53 -0500 Subject: [PATCH 07/16] add debug test to check environment --- .drone.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.drone.yml b/.drone.yml index a4f66d8..9d8a448 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,6 +11,16 @@ environment: steps: + - name: "debug" + image: gitea.thezengarden.net/podman/images/ansible-dev:latest + commands: + - echo "$ANSIBLE_DOCKER_IMAGE - $ANSIBLE_INVENTORY - $ANSIBLE_PLAYBOOK" + when: + branch: + - development + event: [push] + + - name: "ansible_environment_verify" image: "$ANSIBLE_DOCKER_IMAGE" commands: From c689cd19bd1d0d2622ae44fd06429adbd8e28fb4 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:40:00 -0500 Subject: [PATCH 08/16] add content to echo --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 9d8a448..dbae5d0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,7 @@ steps: - name: "debug" image: gitea.thezengarden.net/podman/images/ansible-dev:latest commands: - - echo "$ANSIBLE_DOCKER_IMAGE - $ANSIBLE_INVENTORY - $ANSIBLE_PLAYBOOK" + - echo "image: $ANSIBLE_DOCKER_IMAGE - inventory: $ANSIBLE_INVENTORY - playbook: $ANSIBLE_PLAYBOOK" when: branch: - development From 7a60623201082447e265c3045a7bc03b536eb45c Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:40:49 -0500 Subject: [PATCH 09/16] fix L#15 mapping values are not allowed in this context --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index dbae5d0..931a45b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,7 @@ steps: - name: "debug" image: gitea.thezengarden.net/podman/images/ansible-dev:latest commands: - - echo "image: $ANSIBLE_DOCKER_IMAGE - inventory: $ANSIBLE_INVENTORY - playbook: $ANSIBLE_PLAYBOOK" + - "echo 'image: $ANSIBLE_DOCKER_IMAGE - inventory: $ANSIBLE_INVENTORY - playbook: $ANSIBLE_PLAYBOOK'" when: branch: - development From 2321723c09715e6985e327ca3bd112e1e4c9c16f Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:41:15 -0500 Subject: [PATCH 10/16] syntax changes --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 931a45b..bd7d237 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,7 @@ steps: - name: "debug" image: gitea.thezengarden.net/podman/images/ansible-dev:latest commands: - - "echo 'image: $ANSIBLE_DOCKER_IMAGE - inventory: $ANSIBLE_INVENTORY - playbook: $ANSIBLE_PLAYBOOK'" + - "echo \"image: $ANSIBLE_DOCKER_IMAGE - inventory: $ANSIBLE_INVENTORY - playbook: $ANSIBLE_PLAYBOOK\"" when: branch: - development From d49c00ceb589f7ca6a37213eb4384db3960fedf3 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:41:56 -0500 Subject: [PATCH 11/16] re-add image to test --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index bd7d237..fc66e5a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -22,7 +22,7 @@ steps: - name: "ansible_environment_verify" - image: "$ANSIBLE_DOCKER_IMAGE" + image: gitea.thezengarden.net/podman/images/ansible-dev:latest commands: - git log -1 - ansible --version From cbbeaa4af9b084608611cf734078c1bba2914032 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:44:33 -0500 Subject: [PATCH 12/16] add globals --- .drone.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index fc66e5a..43d7d14 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,3 +1,6 @@ +global-variables: + ansible_docker_image: &ansible_docker_image gitea.thezengarden.net/podman/images/ansible-dev:latest + --- name: run_ansible_tests kind: pipeline @@ -22,7 +25,7 @@ steps: - name: "ansible_environment_verify" - image: gitea.thezengarden.net/podman/images/ansible-dev:latest + image: *ansible_docker_image commands: - git log -1 - ansible --version From 3a260ac16b84ae36f092f143cfb8c5628a2a3a5b Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:45:35 -0500 Subject: [PATCH 13/16] reorder and rename --- .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 43d7d14..e619f87 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,7 +1,7 @@ -global-variables: - ansible_docker_image: &ansible_docker_image gitea.thezengarden.net/podman/images/ansible-dev:latest - --- +global-variables: + ansible_image: &ansible_image gitea.thezengarden.net/podman/images/ansible-dev:latest + name: run_ansible_tests kind: pipeline type: docker @@ -25,7 +25,7 @@ steps: - name: "ansible_environment_verify" - image: *ansible_docker_image + image: *ansible_image commands: - git log -1 - ansible --version From 59bfbf0c2b756cf9d3c669b3aae3ccc97009e1f5 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:50:29 -0500 Subject: [PATCH 14/16] trying stuff --- .drone.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index e619f87..6e1c4c5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,20 +2,21 @@ global-variables: ansible_image: &ansible_image gitea.thezengarden.net/podman/images/ansible-dev:latest + name: run_ansible_tests kind: pipeline type: docker environment: - ANSIBLE_DOCKER_IMAGE : gitea.thezengarden.net/podman/images/ansible-dev:latest ANSIBLE_INVENTORY : "-i 127.0.0.1, --connection=local" ANSIBLE_PLAYBOOK : hello.yml + ANSIBLE_DOCKER_IMAGE : *ansible_image steps: - name: "debug" - image: gitea.thezengarden.net/podman/images/ansible-dev:latest + image: *ansible_image commands: - "echo \"image: $ANSIBLE_DOCKER_IMAGE - inventory: $ANSIBLE_INVENTORY - playbook: $ANSIBLE_PLAYBOOK\"" when: @@ -37,7 +38,7 @@ steps: - name: "ansible_galaxy_requirements" - image: "$ANSIBLE_DOCKER_IMAGE" + image: *ansible_image commands: - ansible-galaxy install -r $DRONE_WORKSPACE/requirements.yml when: @@ -47,7 +48,7 @@ steps: - name: "ansible_lint" - image: "$ANSIBLE_DOCKER_IMAGE" + image: *ansible_image commands: - ansible-lint --offline $DRONE_WORKSPACE when: @@ -57,10 +58,7 @@ steps: - name: "ansible_playbook_execution" - image: "$ANSIBLE_DOCKER_IMAGE" - environment: - ANSIBLE_INVENTORY: - from_secret: ansible_inventory + image: *ansible_image commands: - ansible-playbook -v $ANSIBLE_INVENTORY $DRONE_WORKSPACE/$ANSIBLE_PLAYBOOK when: From 31b7fe0accc2b9730e83556dc644c8ec182dbf0d Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:53:13 -0500 Subject: [PATCH 15/16] remove debug; fix globals --- .drone.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6e1c4c5..95104f6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,8 @@ --- global-variables: - ansible_image: &ansible_image gitea.thezengarden.net/podman/images/ansible-dev:latest + ansible_image: &ansible_image "gitea.thezengarden.net/podman/images/ansible-dev:latest" + ansible_inventory: &ansible_inventory "-i 127.0.0.1, --connection=local" + ansible_playbook: &ansible_playbook "hello.yml" name: run_ansible_tests @@ -9,22 +11,12 @@ type: docker environment: - ANSIBLE_INVENTORY : "-i 127.0.0.1, --connection=local" - ANSIBLE_PLAYBOOK : hello.yml + ANSIBLE_INVENTORY : *ansible_inventory + ANSIBLE_PLAYBOOK : *ansible_playbook ANSIBLE_DOCKER_IMAGE : *ansible_image steps: - - name: "debug" - image: *ansible_image - commands: - - "echo \"image: $ANSIBLE_DOCKER_IMAGE - inventory: $ANSIBLE_INVENTORY - playbook: $ANSIBLE_PLAYBOOK\"" - when: - branch: - - development - event: [push] - - - name: "ansible_environment_verify" image: *ansible_image commands: From 185d47b0e4c1de5f04854978cfd666d4ec11cbea Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 15:54:12 -0500 Subject: [PATCH 16/16] update .ansible-lint to allow for colon tidiness --- .ansible-lint | 1 + 1 file changed, 1 insertion(+) diff --git a/.ansible-lint b/.ansible-lint index 5719c8e..fdaff88 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,2 +1,3 @@ skip_list: - yaml[line-length] + - yaml[colons]