|
| 1 | +- name: integration/ssh/args_by_play_taskvar.yml |
| 2 | + hosts: tt_targets_bare |
| 3 | + gather_facts: false |
| 4 | + vars: |
| 5 | + ansible_password: "{{ 'has_sudo_nopw_password' | trim }}" |
| 6 | + ansible_port: "{{ hostvars[groups['test-targets'][0]].ansible_port | default(22) }}" |
| 7 | + ansible_ssh_common_args: >- |
| 8 | + -o PermitLocalCommand=yes |
| 9 | + -o LocalCommand="touch {{ ssh_args_canary_file }}" |
| 10 | + ansible_user: "{{ 'mitogen__has_sudo_nopw' | trim }}" |
| 11 | + ssh_args_canary_file: "/tmp/ssh_args_by_play_taskvar_{{ inventory_hostname }}" |
| 12 | + tasks: |
| 13 | + # Test that ansible_ssh_common_args are templated; ansible_ssh_args & |
| 14 | + # ansible_ssh_extra_args aren't directly tested, we assume they're similar. |
| 15 | + # TODO Replace LocalCommand canary with SetEnv canary, to simplify test. |
| 16 | + # Requires modification of sshd_config files to add AcceptEnv ... |
| 17 | + - name: Test templating of ansible_ssh_common_args et al, by play taskvars |
| 18 | + block: |
| 19 | + - name: Ensure no lingering canary files |
| 20 | + file: |
| 21 | + path: "{{ ssh_args_canary_file }}" |
| 22 | + state: absent |
| 23 | + delegate_to: localhost |
| 24 | + |
| 25 | + - name: Reset connections to force new ssh execution |
| 26 | + meta: reset_connection |
| 27 | + |
| 28 | + - name: Perform SSH connection, to trigger side effect |
| 29 | + ping: |
| 30 | + |
| 31 | + - name: Stat for canary file created by side effect |
| 32 | + stat: |
| 33 | + path: "{{ ssh_args_canary_file }}" |
| 34 | + delegate_to: localhost |
| 35 | + register: ssh_args_by_play_taskvar_canary_stat |
| 36 | + |
| 37 | + - assert: |
| 38 | + that: |
| 39 | + - ssh_args_by_play_taskvar_canary_stat.stat.exists == true |
| 40 | + quiet: true |
| 41 | + success_msg: "Canary found: {{ ssh_args_canary_file }}" |
| 42 | + fail_msg: | |
| 43 | + ssh_args_canary_file={{ ssh_args_canary_file }} |
| 44 | + ssh_args_by_play_taskvar_canary_stat={{ ssh_args_by_play_taskvar_canary_stat }} |
| 45 | + always: |
| 46 | + - name: Cleanup canary files |
| 47 | + file: |
| 48 | + path: "{{ ssh_args_canary_file }}" |
| 49 | + state: absent |
| 50 | + delegate_to: localhost |
| 51 | + tags: |
| 52 | + - issue_905 |
0 commit comments