Skip to content

Commit

Permalink
Fix tor restart handler naming
Browse files Browse the repository at this point in the history
Apparently Ansible used to inexact matching when looking for
handlers. That changed in the 2.8 series. See:

  ansible/ansible#55575

That broke the fuzzy name matching relied upon in the
restart-tor-naming handler, causing Tor not to be restarted
properly. We could also specify a consistent topic to monitor with
"listen", but I think this restart logic can be simplified to one task
anyway.
  • Loading branch information
rmol committed Apr 20, 2020
1 parent 3ac6ca3 commit b5b4c3a
Showing 1 changed file with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
---
# Meta handler to bounce tor service sanely. If the SSH connection
# for the remote host is over Tor (i.e. host ends in `.onion`), then
# bounce the tor service via fire-and-forget, wait, then reestablish
# the connection after polling for the service to come back up.

# Registering a concise variable for use in conditionals, essentially
# deciding "Are we connected via SSH over Tor or not?"
- name: Register host name to wait for.
set_fact:
_hostname_to_wait_for: "{{ remote_host_ref|default(ansible_host) }}"

# If we're not connected over Tor, bounce the service as usual.
- name: restart tor (simple)
service:
name: tor
state: restarted
when: not _hostname_to_wait_for.endswith('.onion')

# As of Ansible v2.2, the `service` module is not compatible with the `async`
# parameter. This was changed in 2.3.
- name: restart tor (async)
- name: restart tor
shell: sleep 5 && service tor restart
async: 3000
poll: 0
when: _hostname_to_wait_for.endswith('.onion')


# It's critical that we eliminate existing SSH connections, otherwise Ansible
# will try to reuse the stale ControlPersist files, which no longer have an
Expand All @@ -37,7 +18,6 @@
state: absent
run_once: yes
become: no
when: _hostname_to_wait_for.endswith('.onion')

- name: Waiting for SSH connection (slow)...
local_action: wait_for
Expand Down

0 comments on commit b5b4c3a

Please sign in to comment.