From a6fa4ac5ff48c062a9d18f37645ff6545d124778 Mon Sep 17 00:00:00 2001 From: nazunalika Date: Thu, 3 Mar 2022 22:27:20 -0700 Subject: [PATCH] Add handler, prevent accidental upgrades --- handlers/main.yml | 5 +++++ init-gitea-update.yml | 38 ++++++++++++++++++++++++++++++++++++++ tasks/gitea/configure.yml | 14 ++++++++++++++ tasks/gitea/install.yml | 4 ++++ 4 files changed, 61 insertions(+) create mode 100644 init-gitea-update.yml diff --git a/handlers/main.yml b/handlers/main.yml index 03692d8..cf33e55 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,2 +1,7 @@ --- # Handlers +- name: restart_gitea + service: + name: gitea + state: restarted +... diff --git a/init-gitea-update.yml b/init-gitea-update.yml new file mode 100644 index 0000000..18672d7 --- /dev/null +++ b/init-gitea-update.yml @@ -0,0 +1,38 @@ +--- +- name: Update Gitea + hosts: all + become: true + + pre_tasks: + - name: Check if ansible cannot be run here + stat: + path: /etc/no-ansible + register: no_ansible + + - name: Verify if we can run ansible + assert: + that: + - "not no_ansible.stat.exists" + success_msg: "We are able to run on this node" + fail_msg: "/etc/no-ansible exists - skipping run on this node" + + - name: Enable the proper copr for gitea + command: "dnf copr enable nalika/gitea -y" + check_mode: false + changed_when: "1 != 1" + + tasks: + - name: Update Gitea + dnf: + name: gitea + state: latest + + post_tasks: + - name: Touching run file that ansible has ran here + file: + path: /var/log/ansible.run + state: touch + mode: '0644' + owner: root + group: root +... diff --git a/tasks/gitea/configure.yml b/tasks/gitea/configure.yml index d57b779..fd57711 100644 --- a/tasks/gitea/configure.yml +++ b/tasks/gitea/configure.yml @@ -1,3 +1,17 @@ --- # Configuration for gitea +- name: Enable Gitea + service: + name: gitea + state: started + enabled: true + +# - name: Deploy Gitea configuration +# template: +# src: "etc/gitea/conf/app.ini.j2" +# dest: "/etc/gitea/conf/app.ini" +# owner: git +# group: git +# mode: '0660' +# notify: restart_gitea ... diff --git a/tasks/gitea/install.yml b/tasks/gitea/install.yml index ac759ad..e23a259 100644 --- a/tasks/gitea/install.yml +++ b/tasks/gitea/install.yml @@ -3,11 +3,13 @@ - name: "Installing Gitea from COPR" dnf: name: gitea + state: present # Install web front end - name: "Installing httpd package and configuration" dnf: name: gitea-httpd + state: present when: - gitea_web_install == "httpd" - gitea_web_config @@ -15,6 +17,7 @@ - name: "Installing nginx package and configuration" dnf: name: gitea-nginx + state: present when: - gitea_web_install == "nginx" - gitea_web_config @@ -22,6 +25,7 @@ - name: "Installing caddy package and configuration" dnf: name: gitea-caddy + state: present when: - gitea_web_install == "caddy" - gitea_web_config