---
- name: Ensure Tor proxy settings are configured # noqa 301
  become: true
  become_user: "{{ user.username }}"
  shell: |
    gsettings set org.gnome.system.proxy.http host 'localhost'
    gsettings set org.gnome.system.proxy.http port 8118
    gsettings set org.gnome.system.proxy.https host 'localhost'
    gsettings set org.gnome.system.proxy.https port 8118
    gsettings set org.gnome.system.proxy.ftp host 'localhost'
    gsettings set org.gnome.system.proxy.ftp port 8118
    gsettings set org.gnome.system.proxy.socks host 'localhost'
    gsettings set org.gnome.system.proxy.socks port 8118

# TODO: Swap out the command module above for an Ansible module designed for this like below.
# When I tested using community.general.dconf, I was unable to update the NetworkManager
# settings. When I opened the keys in dconf-editor, it said the schema was missing. When
# I opened the NetworkManager proxy settings, the changes made by the code below did not
# show any changes.
# - name: Ensure Tor proxy settings are configured
#   community.general.dconf:
#     key: "{{ item.key }}"
#     value: "{{ item.value }}"
#   loop:
#     - key: /system/proxy/ftp/host
#       value: "'localhost'"
#     - key: /system/proxy/ftp/port
#       value: "8118"
#     - key: /system/proxy/http/host
#       value: "'localhost'"
#     - key: /system/proxy/http/port
#       value: "8118"
#     - key: /system/proxy/https/host
#       value: "'localhost'"
#     - key: /system/proxy/https/port
#       value: "8118"
#     - key: /system/proxy/socks/host
#       value: "'localhost'"
#     - key: /system/proxy/socks/port
#       value: "8118"
