Skip to content

Commit

Permalink
Merge pull request #3 from kysrpex/squid
Browse files Browse the repository at this point in the history
Squid cannot be launched if it is already running. If the role has been run at least once, then Squid will fail to execute during the "Create the cache directories for the first time" task, causing the whole role to fail.

This PR changes the behavior of the role so that it tries to create the cache directories only if they do not exist. In addition, it ensures Squid is not running before trying to do so.
  • Loading branch information
kysrpex authored Jun 27, 2023
2 parents 9252ae5 + f220483 commit 54f09b8
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tasks/squid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,28 @@
setype: squid_cache_t
when: cvmfs_stratum1_cache_dir is defined

- name: Create the cache directories for the first time
become: true
become_user: "{{ cvmfs_squid_user }}"
ansible.builtin.command: squid -z
args:
creates: "{{ cvmfs_stratum1_cache_dir }}/00"
- name: Check whether the cache directories exist
ansible.builtin.stat:
path: "{{ cvmfs_stratum1_cache_dir.dir }}/00"
register: cvmfs_stratum1_cache_dir_stat
when: cvmfs_stratum1_cache_dir is defined

- name: Create the cache directories for the first time
when: cvmfs_stratum1_cache_dir is defined and not cvmfs_stratum1_cache_dir_stat.stat.exists
block:

- name: Ensure squid is stopped
ansible.builtin.service:
name: "{{ cvmfs_squid_service_name }}"
state: stopped

- name: Create the cache directories
become: true
become_user: "{{ cvmfs_squid_user }}"
ansible.builtin.command: squid -z
args:
creates: "{{ cvmfs_stratum1_cache_dir.dir }}/00"

- name: Ensure squid is enabled and started
ansible.builtin.service:
name: "{{ cvmfs_squid_service_name }}"
Expand Down

0 comments on commit 54f09b8

Please sign in to comment.