Debian Codegraph @

test/integration/targets/connection/test_connection.yml

raw
1 - hosts: "{{ target_hosts }}"
2 gather_facts: no
3 serial: 1
4 tasks:
5
6 # SSH with scp has troubles with using complex filenames that require quoting
7 # or escaping. The more complex filename scenario is skipped in this mode.
8 # The default of sftp has no problems with these filenames.
9 - name: check if ssh with the scp file transfer is being tested
10 set_fact:
11 skip_complex_filename: >-
12 {{
13 ansible_connection == "ssh" and
14 lookup("ansible.builtin.config",
15 "ssh_transfer_method",
16 plugin_name=ansible_connection,
17 plugin_type="connection",
18 ) == "scp"
19 }}
20 echo_string: 汉语
21
22 - name: set test filename
23 set_fact:
24 test_filename: 汉语-{{ skip_complex_filename | ternary("file", "['foo bar']") }}.txt
25
26 ### raw with unicode arg and output
27
28 - name: raw with unicode arg and output
29 raw: "{{ echo_commands[action_prefix ~ ansible_connection ~ '_' ~ (ansible_shell_type|default(''))] | default(echo_commands['default']) }}"
30 vars:
31 # Windows over SSH does not have a way to set the console codepage to allow UTF-8. We need to
32 # wrap the commands we send to the remote host to get it working.
33 echo_commands:
34 win_ssh_powershell: '[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; echo {{ echo_string }}'
35 win_ssh_cmd: 'powershell.exe -Command "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; echo {{ echo_string }}"'
36 default: echo {{ echo_string }}
37 register: command
38 - name: check output of raw with unicode arg and output
39 assert:
40 that:
41 - echo_string in command.stdout
42 - command is changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules
43
44 ### copy local file with unicode filename and content
45
46 - name: create local file with unicode filename and content
47 local_action: lineinfile dest={{ local_tmp }}-汉语/{{ test_filename }} create=true line=汉语
48 - name: remove remote file with unicode filename and content
49 action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语/{{ test_filename }} state=absent"
50 - name: create remote directory with unicode name
51 action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=directory"
52 - name: copy local file with unicode filename and content
53 action: "{{ action_prefix }}copy src={{ local_tmp }}-汉语/{{ test_filename }} dest={{ remote_tmp }}-汉语/{{ test_filename }}"
54
55 ### fetch remote file with unicode filename and content
56
57 - name: remove local file with unicode filename and content
58 local_action: file path={{ local_tmp }}-汉语/{{ test_filename }} state=absent
59 - name: fetch remote file with unicode filename and content
60 fetch: src={{ remote_tmp }}-汉语/{{ test_filename }} dest={{ local_tmp }}-汉语/{{ test_filename }} fail_on_missing=true validate_checksum=true flat=true
61
62 ### remove local and remote temp files
63
64 - name: remove local temp file
65 local_action: file path={{ local_tmp }}-汉语 state=absent
66 - name: remove remote temp file
67 action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=absent"
68
69 ### test wait_for_connection plugin
70 - wait_for_connection: