From 90c2ed03d0a842d04444e81a5c5c058511e5891b Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 20 Aug 2018 15:43:56 +0100 Subject: [PATCH] ansible: fix synchronize module Broken by recent connection delegation fixes. --- ansible_mitogen/connection.py | 9 ++++++ tests/ansible/integration/action/all.yml | 1 + .../integration/action/synchronize.yml | 28 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 tests/ansible/integration/action/synchronize.yml diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 966f86c1..71eb78e0 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -419,6 +419,12 @@ class Connection(ansible.plugins.connection.ConnectionBase): #: Only sudo, su, and doas are supported for now. become_methods = ['sudo', 'su', 'doas'] + # + # Note: any of the attributes below may be :data:`None` if the connection + # plugin was constructed directly by a non-cooperative action, such as in + # the case of the synchronize module. + # + #: Set to 'ansible_python_interpreter' by on_action_run(). python_path = None @@ -449,6 +455,9 @@ class Connection(ansible.plugins.connection.ConnectionBase): #: Set to 'hostvars' by on_action_run() host_vars = None + #: Set by on_action_run() + delegate_to_hostname = None + #: Set to '_loader.get_basedir()' by on_action_run(). Used by mitogen_local #: to change the working directory to that of the current playbook, #: matching vanilla Ansible behaviour. diff --git a/tests/ansible/integration/action/all.yml b/tests/ansible/integration/action/all.yml index 22904c23..c5cb80d7 100644 --- a/tests/ansible/integration/action/all.yml +++ b/tests/ansible/integration/action/all.yml @@ -3,4 +3,5 @@ - import_playbook: make_tmp_path.yml - import_playbook: remote_expand_user.yml - import_playbook: remote_file_exists.yml +- import_playbook: synchronize.yml - import_playbook: transfer_data.yml diff --git a/tests/ansible/integration/action/synchronize.yml b/tests/ansible/integration/action/synchronize.yml new file mode 100644 index 00000000..f9a8cb2c --- /dev/null +++ b/tests/ansible/integration/action/synchronize.yml @@ -0,0 +1,28 @@ +# Verify basic operation of the synchronize module. + +- name: integration/action/synchronize.yml + hosts: test-targets + any_errors_fatal: true + tasks: + - file: + path: /tmp/sync-test + state: directory + connection: local + + - copy: + dest: /tmp/sync-test/item + content: "item!" + connection: local + + - synchronize: + dest: /tmp/sync-test + src: /tmp/sync-test + + - slurp: + src: /tmp/sync-test/item + register: out + + - set_fact: outout="{{out.content|b64decode}}" + + - assert: + that: outout == "item!"