From fba685488ab5531d108ed9a4f460c673661be0a1 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 22:44:04 -0500 Subject: [PATCH 1/7] add some additional tasks for testing --- hello.yml | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/hello.yml b/hello.yml index a90c638..4070dd4 100644 --- a/hello.yml +++ b/hello.yml @@ -4,7 +4,74 @@ gather_facts: false + vars: + __gitea_version : 1.20.5 + __gitea_arch : amd64 + __gitea_binary : "https://dl.gitea.io/gitea/{{ __gitea_version }}/\ + gitea-{{ __gitea_version }}-linux-{{ __gitea_arch }}" + + __gitea_user: + name : gitea + gecos : Git with a cup of tea + shell : /bin/bash + home : /home/gitea + + tasks: - name: Say Hello world ansible.builtin.debug: msg: Hello world! + + + - name: Install Git + ansible.builtin.package: + name : git + state : present + + + - name: Check if Gitea is present and is correct version + ansible.builtin.command : /usr/local/bin/gitea --version + ignore_errors : true + changed_when : false + register : r_check_gitea + + + - name: Fetch Gitea binary and notify user + when : + - (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version)) + block: + - name: Gitea binary not found or version mismatch + ansible.builtin.debug : + msg : "Gitea binary not found or version mismatch." + + - name: "Fetch Gitea {{ __gitea_version }}" + ansible.builtin.get_url : + url : "{{ __gitea_binary }}" + dest : /usr/local/bin/gitea + mode : "0755" + notify : Restart Gitea + + + - name: Create Gitea user + ansible.builtin.user: + name : "{{ __gitea_user.name }}" + comment : "{{ __gitea_user.gecos }}" + shell : "{{ __gitea_user.shell }}" + home : "{{ __gitea_user.home }}" + create_home : true + state : present + + + - name: Create required directories + ansible.builtin.file: + path : "{{ item }}" + state : directory + recurse : true + owner : "{{ __gitea_user.name }}" + group : "{{ __gitea_user.name }}" + mode : "0750" + loop: + - /var/lib/gitea/custom + - /var/lib/gitea/data + - /var/lib/gitea/log + - /etc/gitea From 5623c6186fdd9aaf248218c176d6a35bb420614f Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 22:45:34 -0500 Subject: [PATCH 2/7] remove handler --- hello.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/hello.yml b/hello.yml index 4070dd4..5aaa50a 100644 --- a/hello.yml +++ b/hello.yml @@ -49,7 +49,6 @@ url : "{{ __gitea_binary }}" dest : /usr/local/bin/gitea mode : "0755" - notify : Restart Gitea - name: Create Gitea user From 04d16e2111f7e62b3adfb21885b7a01ab3ec6bcc Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 22:48:31 -0500 Subject: [PATCH 3/7] revert hello.yml to a simple poc --- hello.yml | 66 ------------------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/hello.yml b/hello.yml index 5aaa50a..a90c638 100644 --- a/hello.yml +++ b/hello.yml @@ -4,73 +4,7 @@ gather_facts: false - vars: - __gitea_version : 1.20.5 - __gitea_arch : amd64 - __gitea_binary : "https://dl.gitea.io/gitea/{{ __gitea_version }}/\ - gitea-{{ __gitea_version }}-linux-{{ __gitea_arch }}" - - __gitea_user: - name : gitea - gecos : Git with a cup of tea - shell : /bin/bash - home : /home/gitea - - tasks: - name: Say Hello world ansible.builtin.debug: msg: Hello world! - - - - name: Install Git - ansible.builtin.package: - name : git - state : present - - - - name: Check if Gitea is present and is correct version - ansible.builtin.command : /usr/local/bin/gitea --version - ignore_errors : true - changed_when : false - register : r_check_gitea - - - - name: Fetch Gitea binary and notify user - when : - - (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version)) - block: - - name: Gitea binary not found or version mismatch - ansible.builtin.debug : - msg : "Gitea binary not found or version mismatch." - - - name: "Fetch Gitea {{ __gitea_version }}" - ansible.builtin.get_url : - url : "{{ __gitea_binary }}" - dest : /usr/local/bin/gitea - mode : "0755" - - - - name: Create Gitea user - ansible.builtin.user: - name : "{{ __gitea_user.name }}" - comment : "{{ __gitea_user.gecos }}" - shell : "{{ __gitea_user.shell }}" - home : "{{ __gitea_user.home }}" - create_home : true - state : present - - - - name: Create required directories - ansible.builtin.file: - path : "{{ item }}" - state : directory - recurse : true - owner : "{{ __gitea_user.name }}" - group : "{{ __gitea_user.name }}" - mode : "0750" - loop: - - /var/lib/gitea/custom - - /var/lib/gitea/data - - /var/lib/gitea/log - - /etc/gitea From 9282a0e0736ddc9a6961cfe56456ea3c1d048638 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 18 Nov 2023 00:13:50 -0500 Subject: [PATCH 4/7] add exclusions for .ansible-lint --- .ansible-lint | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.ansible-lint b/.ansible-lint index fdaff88..6234bf8 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,3 +1,7 @@ skip_list: - yaml[line-length] - yaml[colons] + +exclude_paths: + - .drone.yml + - requirements.yml From 75b4e173946d27950874ad0bf945c0ca08071331 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 18 Nov 2023 00:16:25 -0500 Subject: [PATCH 5/7] add 'pwd' to check entrypoint --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 95104f6..9685562 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,6 +20,7 @@ steps: - name: "ansible_environment_verify" image: *ansible_image commands: + - pwd - git log -1 - ansible --version - ansible-lint --version From 127f0e65ec1e4b4e518ddbe9df91c9a56b6beca6 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 18 Nov 2023 00:45:08 -0500 Subject: [PATCH 6/7] add 'fail' task --- hello.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hello.yml b/hello.yml index a90c638..8d67000 100644 --- a/hello.yml +++ b/hello.yml @@ -8,3 +8,7 @@ - name: Say Hello world ansible.builtin.debug: msg: Hello world! + + - name: Say goodbye world + ansible.builtin.fail: + msg: Goodbye...world. From a709bb30941d9bbeaf6e7cb04727c759a9d0a9aa Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 18 Nov 2023 01:31:16 -0500 Subject: [PATCH 7/7] remove 'fail' task --- hello.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hello.yml b/hello.yml index 8d67000..a90c638 100644 --- a/hello.yml +++ b/hello.yml @@ -8,7 +8,3 @@ - name: Say Hello world ansible.builtin.debug: msg: Hello world! - - - name: Say goodbye world - ansible.builtin.fail: - msg: Goodbye...world.