From d5b52b9b738fc502e92ac38d6d369e9ab0e5ee9b Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 24 Nov 2023 02:02:09 -0500 Subject: [PATCH 1/7] initial ci implementation; centos/fedora only --- .drone.yml | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..fb15365 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,87 @@ +--- +kind: pipeline +type: docker +name: run_ansible_tests_fedora39 + +global-variables: + 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 "gitea.yml" + +environment: + ANSIBLE_INVENTORY : *ansible_inventory + ANSIBLE_PLAYBOOK : *ansible_playbook + +trigger: + branch: + exclude: + - main + event: [push] + +steps: + - name: "ansible_environment_verify" + image: *ansible_image + commands: + - git log -1 + - ansible --version + - ansible-lint --version + + - name: "ansible_galaxy_requirements" + image: *ansible_image + commands: + - ansible-galaxy install -r requirements.yml + + - name: "ansible_lint" + image: *ansible_image + commands: + - ansible-lint --offline + + - name: "ansible_playbook_execution" + image: *ansible_image + commands: + - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK + + +--- +kind: pipeline +type: docker +name: run_ansible_tests_centos9 + +global-variables: + ansible_image : &ansible_image "gitea.thezengarden.net/podman/images/ansible-dev:centos-stream9" + ansible_inventory : &ansible_inventory "-i 127.0.0.1, --connection=local" + ansible_playbook : &ansible_playbook "gitea.yml" + +environment: + ANSIBLE_INVENTORY : *ansible_inventory + ANSIBLE_PLAYBOOK : *ansible_playbook + +trigger: + branch: + exclude: + - main + event: [push] + +steps: + - name: "ansible_environment_verify" + image: *ansible_image + commands: + - git log -1 + - ansible --version + - ansible-lint --version + + - name: "ansible_galaxy_requirements" + image: *ansible_image + commands: + - ansible-galaxy install -r requirements.yml + + - name: "ansible_lint" + image: *ansible_image + commands: + - ansible-lint --offline + + - name: "ansible_playbook_execution" + image: *ansible_image + commands: + - ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK + -- 2.47.1 From 9247acf2d2e666d68c306043a61246bd26724c45 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 24 Nov 2023 10:45:39 -0500 Subject: [PATCH 2/7] change to hosts: all --- gitea.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitea.yml b/gitea.yml index efec2a4..6520c3a 100644 --- a/gitea.yml +++ b/gitea.yml @@ -1,6 +1,6 @@ --- - name: Deploy Gitea - hosts: gitea + hosts: all become: true gather_facts: false -- 2.47.1 From 9a54413b9185c48bbcc39720afa04da174162e3c Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 25 Nov 2023 00:32:31 -0500 Subject: [PATCH 3/7] re-worked some stuff; testing ci --- gitea.yml | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/gitea.yml b/gitea.yml index 6520c3a..c183250 100644 --- a/gitea.yml +++ b/gitea.yml @@ -2,7 +2,7 @@ - name: Deploy Gitea hosts: all become: true - gather_facts: false + gather_facts: true vars: @@ -73,25 +73,26 @@ - /etc/gitea - - name: Deploy unit file for Gitea - ansible.builtin.template: - src : templates/gitea.service.j2 - dest : /etc/systemd/system/gitea.service - owner : root - group : root - mode : "0644" + - name: Manage Gitea service + when: ansible_virtualization_type != "container" + block: + - name: Deploy unit file for Gitea + ansible.builtin.template: + src : templates/gitea.service.j2 + dest : /etc/systemd/system/gitea.service + owner : root + group : root + mode : "0644" + - name: Reload Systemd + ansible.builtin.systemd: + daemon_reload: true - - name: Reload Systemd - ansible.builtin.systemd: - daemon_reload: true - - - - name: Start Gitea - ansible.builtin.service: - name : gitea - state : started - enabled : true + - name: Start Gitea + ansible.builtin.service: + name : gitea + state : started + enabled : true handlers: @@ -99,6 +100,7 @@ ansible.builtin.service: name : gitea state : restarted + when: ansible_virtualization_type != "container" ... -- 2.47.1 From 52e7aa80e2e00d73054c7ea9313289291f145e81 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 25 Nov 2023 00:32:50 -0500 Subject: [PATCH 4/7] re-added fact gather stuff --- ansible.cfg | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ansible.cfg b/ansible.cfg index f678b47..33a3267 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -2,13 +2,12 @@ inventory = hosts roles_path = roles collections_path = collections -#remote_tmp = /tmp/.ansible-${USER}/tmp -#gathering = smart -#gather_timeout = 300 -#fact_path = facts.d -#fact_caching = jsonfile -#fact_caching_connection = facts.d -#fact_caching_timeout = 300 +gathering = smart +gather_timeout = 300 +fact_path = facts.d +fact_caching = jsonfile +fact_caching_connection = facts.d +fact_caching_timeout = 300 retry_files_enabled = False forks = 40 timeout = 30 -- 2.47.1 From b22026b7f7fd1b193e52522604a2c25cf14cdae3 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 25 Nov 2023 00:35:08 -0500 Subject: [PATCH 5/7] add debug for ansible_virtualization_type --- gitea.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gitea.yml b/gitea.yml index c183250..25d4b64 100644 --- a/gitea.yml +++ b/gitea.yml @@ -73,6 +73,11 @@ - /etc/gitea + - name: Debug ansible_virtualization_type + ansible.builtin.debug: + var: ansible_virtualization_type + + - name: Manage Gitea service when: ansible_virtualization_type != "container" block: -- 2.47.1 From b0e3fd8d44b03880998084a232a0432d6751c12a Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 25 Nov 2023 00:50:42 -0500 Subject: [PATCH 6/7] change exception to docker; this will work but not for podman --- gitea.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitea.yml b/gitea.yml index 25d4b64..50449d5 100644 --- a/gitea.yml +++ b/gitea.yml @@ -79,7 +79,7 @@ - name: Manage Gitea service - when: ansible_virtualization_type != "container" + when: ansible_virtualization_type != "docker" block: - name: Deploy unit file for Gitea ansible.builtin.template: @@ -105,7 +105,7 @@ ansible.builtin.service: name : gitea state : restarted - when: ansible_virtualization_type != "container" + when: ansible_virtualization_type != "docker" ... -- 2.47.1 From 38fa45dda2821ad5f75c480acd8c3c55578b9bc6 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sun, 26 Nov 2023 19:20:21 -0500 Subject: [PATCH 7/7] testing fix for issue #1 --- .gitignore | 1 + gitea.yml | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 2bfceae..fd579d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ facts.d/ hosts collections/ +.vscode \ No newline at end of file diff --git a/gitea.yml b/gitea.yml index 50449d5..913c93b 100644 --- a/gitea.yml +++ b/gitea.yml @@ -73,13 +73,9 @@ - /etc/gitea - - name: Debug ansible_virtualization_type - ansible.builtin.debug: - var: ansible_virtualization_type - - - name: Manage Gitea service - when: ansible_virtualization_type != "docker" + when: + - ansible_virtualization_type | select('match', '(?:podman|docker|container)') block: - name: Deploy unit file for Gitea ansible.builtin.template: @@ -105,7 +101,8 @@ ansible.builtin.service: name : gitea state : restarted - when: ansible_virtualization_type != "docker" + when: + - ansible_virtualization_type | select('match', '(?:podman|docker|container)') ... -- 2.47.1