Skip to content
Snippets Groups Projects
squid.yaml 1.37 KiB
Newer Older
---
- name: Gather facts on all nodes
  hosts: allnodes
  become: true
  tasks:
    - name: Gather facts on the node
      debug:
        msg: "IPv4: {{ansible_default_ipv4.address }}, IPv6: {{ansible_default_ipv6.address }}"
- name: Squid proxy deployment
  hosts: ingress[0]
  become: true
  tasks:
    - name: Install squid
      package:
        name: squid
      # full-fledge restart needed to build cache
      notify: Restart squid
    # https://cvmfs.readthedocs.io/en/stable/cpt-squid.html
    - name: Configure squid
      lineinfile:
        regexp: '^\s*{{ item.key }}\s+.*'
        line: "{{ item.key }} {{ item.value }}"
        path: /etc/squid/squid.conf
      loop: "{{ config | dict2items }}"
      vars:
        config:
          collapsed_forwarding: "on"
          minimum_expiry_time: 0
          maximum_object_size: 1024 MB
          cache_mem: 128 MB
          maximum_object_size_in_memory: 128 KB
          cache_dir: ufs /var/spool/squid 81920 16 256
      notify: Reload squid
    - name: Configure squid - ACL allcluster
      template:
        src: templates/etc/squid/conf.d/allcluster.conf
        dest: /etc/squid/conf.d/allcluster.conf
        mode: 0644
      notify: Reload squid

  handlers:
    - name: Restart squid
      service:
        name: squid
        state: restarted
    - name: Reload squid
      service:
        name: squid
        state: reloaded