From fba685488ab5531d108ed9a4f460c673661be0a1 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 17 Nov 2023 22:44:04 -0500 Subject: [PATCH] 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