---
- name: Install squid
  ansible.builtin.apt:
    name:
      - squid

- name: Disable squid
  ansible.builtin.systemd:
    name: squid
    enabled: false
    state: stopped

- name: Deploy squid user mode configuration
  ansible.builtin.template:
    src: "{{ item }}.j2"
    dest: "/etc/squid/{{ item }}"
    mode: '0644'
  loop:
    - squid-usermode.conf
    - squid-usermode-external.conf

- name: Deploy startusersquid script
  ansible.builtin.template:
    src: startusersquid.sh.j2
    dest: /usr/local/bin/startusersquid.sh
    mode: '0755'

- name: Provide usersquid service
  ansible.builtin.copy:
    src: usersquid.service
    dest: /etc/systemd/user/usersquid.service
    mode: '0644'

- name: Enable usersquid service
  ansible.builtin.systemd:
    name: usersquid.service
    scope: global
    enabled: true

- name: Deploy http proxy config
  ansible.builtin.copy:
    dest: /etc/environment.d/10-lmn-proxy.conf
    mode: '0644'
    content: |
      http_proxy="http://localhost:3128"
      https_proxy="http://localhost:3128"
      ftp_proxy="http://localhost:3128"
      no_proxy="{{ no_proxy }}"
