- set_fact:
    hs_dir: "/var/lib//tor/hidden_service_www_{{ _website_domain }}"
  name: Set hs_dir

- name: Add the HiddenServiceDir config to torrc
  blockinfile:
    dest: /etc/tor/torrc
    block: |
      HiddenServiceDir {{ hs_dir }}
      HiddenServicePort 443 127.0.0.1:443
      HiddenServicePort 80 127.0.0.1:80
    notify: restart tor

- name: Flush handlers
  meta: flush_handlers

- name: Get the onion hostname
  shell: cat {{ hs_dir }}/hostname
  register: onion_hostname
  changed_when: False

- name: Deploy the httpd config for onion
  copy:
    dest: "/etc/httpd/conf.d/{{ _website_domain }}.conf.d/hidden_service.conf"
    content: "ServerAlias {{ onion_hostname }}"
  notify: verify config and restart httpd

- set_fact:
    hs_dir: "/var/lib//tor/hidden_service_www_{{ _website_domain }}"
  name: Set hs_dir

- name: Add the HiddenServiceDir config to torrc
  blockinfile:
    dest: "{{ torrc }}"
    block: |
      HiddenServiceDir {{ hs_dir }}
      HiddenServicePort 443 127.0.0.1:443
      HiddenServicePort 80 127.0.0.1:80
    notify: restart tor

- name: Flush handlers
  meta: flush_handlers

- name: Get the onion hostname
  shell: cat {{ hs_dir }}/hostname
  register: onion_hostname
  changed_when: False

- name: Deploy the httpd config for onion
  copy:
    dest: "/etc/httpd/conf.d/{{ _website_domain }}.conf.d/hidden_service.conf"
    content: "ServerAlias {{ onion_hostname }}"
  notify: verify config and restart httpd

Use torrc var for portability
Use torrc var for portability

As of https://gitlab.com/osas/ansible-role-tor/merge_requests/3,
we use a variable for the torrc location for portability (mostly
on FreeBSD ports).
