From 6e13065ea7ce208fd35072ad7d07413442211bba Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Wed, 1 Jan 2025 17:02:04 +0100 Subject: [PATCH] fixes: #32 do not always download bootstrap and cleanup --- roles/nginx/tasks/main.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index 04c1ef1..0530d83 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -39,13 +39,36 @@ owner: www-data group: www-data -- name: Dowload bootstrap +- name: Scan for old bootstrap folders + ansible.builtin.find: + paths: /var/www/gw-status + patterns: 'bootstrap-*' + file_type: directory + recurse: no + register: bootstrap_files + +- name: Remove old bootstrap folders + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: "{{ bootstrap_files.files }}" + loop_control: + loop_var: item + when: "'bootstrap-' + bootstrap_version + '-dist' not in item.path" + +- name: Check if bootstrap is already downloaded + ansible.builtin.stat: + path: /var/www/gw-status/bootstrap-{{ bootstrap_version }}-dist + register: bootstrap_zip + +- name: Download bootstrap ansible.builtin.get_url: url: "https://github.com/twbs/bootstrap/releases/download/v{{ bootstrap_version }}/bootstrap-{{ bootstrap_version }}-dist.zip" dest: /var/www/gw-status/bootstrap-{{ bootstrap_version }}-dist.zip mode: '0644' owner: root group: root + when: not bootstrap_zip.stat.exists - name: Unpack bootstrap ansible.builtin.unarchive: @@ -55,11 +78,13 @@ mode: '0744' owner: www-data group: www-data + when: not bootstrap_zip.stat.exists - name: Delete archive ansible.builtin.file: - dest: /var/www/gw-status/bootstrap-{{ bootstrap_version }}-dist.zip + path: /var/www/gw-status/bootstrap-{{ bootstrap_version }}-dist.zip state: absent + when: not bootstrap_zip.stat.exists - name: Copy info page ansible.builtin.template: