From b5b4c3a93277ac65cf95a657087907672344d020 Mon Sep 17 00:00:00 2001 From: John Hensley Date: Fri, 17 Apr 2020 14:08:27 -0400 Subject: [PATCH] Fix tor restart handler naming Apparently Ansible used to inexact matching when looking for handlers. That changed in the 2.8 series. See: https://github.com/ansible/ansible/issues/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. --- .../handlers/restart-tor-carefully.yml | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/install_files/ansible-base/roles/tor-hidden-services/handlers/restart-tor-carefully.yml b/install_files/ansible-base/roles/tor-hidden-services/handlers/restart-tor-carefully.yml index 8be5bc89e6e..6d6df437e63 100644 --- a/install_files/ansible-base/roles/tor-hidden-services/handlers/restart-tor-carefully.yml +++ b/install_files/ansible-base/roles/tor-hidden-services/handlers/restart-tor-carefully.yml @@ -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 @@ -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