| 1 |
--- |
| 2 |
# Various ways users want to use binary data |
| 3 |
# Could integrate into individual modules but currently these don't all work. |
| 4 |
# Probably easier to see them all in a single block to know what we're testing. |
| 5 |
# When we can start testing v2 we should test that all of these work. |
| 6 |
|
| 7 |
# In v1: The following line will traceback if it's the first task in the role. |
| 8 |
# Does not traceback if it's the second or third etc task. |
| 9 |
- debug: msg="{{ utf8_simple_accents|b64decode}}" |
| 10 |
|
| 11 |
# Expected values of the written files |
| 12 |
- name: get checksums that we expect later files to have |
| 13 |
copy: |
| 14 |
src: from_playbook |
| 15 |
dest: "{{ remote_tmp_dir }}" |
| 16 |
|
| 17 |
- copy: |
| 18 |
src: b64_utf8 |
| 19 |
dest: "{{ remote_tmp_dir }}" |
| 20 |
|
| 21 |
- copy: |
| 22 |
src: b64_latin1 |
| 23 |
dest: "{{ remote_tmp_dir }}" |
| 24 |
|
| 25 |
- stat: |
| 26 |
path: "{{ remote_tmp_dir }}/from_playbook" |
| 27 |
register: from_playbook |
| 28 |
|
| 29 |
- stat: |
| 30 |
path: "{{ remote_tmp_dir }}/b64_utf8" |
| 31 |
register: b64_utf8 |
| 32 |
|
| 33 |
- stat: |
| 34 |
path: "{{ remote_tmp_dir }}/b64_latin1" |
| 35 |
register: b64_latin1 |
| 36 |
|
| 37 |
# Tests themselves |
| 38 |
- name: copy with utf-8 content in a playbook |
| 39 |
copy: |
| 40 |
content: "{{ simple_accents }}\n" |
| 41 |
dest: "{{ remote_tmp_dir }}/from_playbook.txt" |
| 42 |
|
| 43 |
- name: Check that copying utf-8 content matches |
| 44 |
stat: |
| 45 |
path: "{{ remote_tmp_dir }}/from_playbook.txt" |
| 46 |
register: results |
| 47 |
|
| 48 |
- assert: |
| 49 |
that: |
| 50 |
- 'results.stat.checksum == from_playbook.stat.checksum' |
| 51 |
|
| 52 |
- name: copy with utf8 in a base64 encoded string |
| 53 |
copy: |
| 54 |
content: "{{ utf8_simple_accents|b64decode }}\n" |
| 55 |
dest: "{{ remote_tmp_dir }}/b64_utf8.txt" |
| 56 |
|
| 57 |
- name: Check that utf8 in a base64 string matches |
| 58 |
stat: |
| 59 |
path: "{{ remote_tmp_dir }}/b64_utf8.txt" |
| 60 |
register: results |
| 61 |
|
| 62 |
- assert: |
| 63 |
that: |
| 64 |
- 'results.stat.checksum == b64_utf8.stat.checksum' |
| 65 |
|
| 66 |
- name: copy with latin1 in a base64 encoded string |
| 67 |
copy: |
| 68 |
content: "{{ latin1_simple_accents|b64decode }}\n" |
| 69 |
dest: "{{ remote_tmp_dir }}/b64_latin1.txt" |
| 70 |
|
| 71 |
- name: Check that latin1 in a base64 string matches |
| 72 |
stat: |
| 73 |
path: "{{ remote_tmp_dir }}/b64_latin1.txt" |
| 74 |
register: results |
| 75 |
|
| 76 |
- assert: |
| 77 |
that: |
| 78 |
- 'results.stat.checksum == b64_latin1.stat.checksum' |
| 79 |
# This one depends on being able to pass binary data through |
| 80 |
# Might be a while before we find a solution for this |
| 81 |
ignore_errors: True |
| 82 |
|
| 83 |
- name: Template with a unicode string from the playbook |
| 84 |
template: |
| 85 |
src: "from_playbook_template.j2" |
| 86 |
dest: "{{ remote_tmp_dir }}/from_playbook_template.txt" |
| 87 |
|
| 88 |
- name: Check that writing a template from a playbook var matches |
| 89 |
stat: |
| 90 |
path: "{{ remote_tmp_dir }}/from_playbook_template.txt" |
| 91 |
register: results |
| 92 |
|
| 93 |
- assert: |
| 94 |
that: |
| 95 |
- 'results.stat.checksum == from_playbook.stat.checksum' |
| 96 |
|
| 97 |
- name: Template with utf8 in a base64 encoded string |
| 98 |
template: |
| 99 |
src: "b64_utf8_template.j2" |
| 100 |
dest: "{{ remote_tmp_dir }}/b64_utf8_template.txt" |
| 101 |
|
| 102 |
- name: Check that writing a template from a base64 encoded utf8 string matches |
| 103 |
stat: |
| 104 |
path: "{{ remote_tmp_dir }}/b64_utf8_template.txt" |
| 105 |
register: results |
| 106 |
|
| 107 |
- assert: |
| 108 |
that: |
| 109 |
- 'results.stat.checksum == b64_utf8.stat.checksum' |
| 110 |
|
| 111 |
- name: Template with latin1 in a base64 encoded string |
| 112 |
template: |
| 113 |
src: "b64_latin1_template.j2" |
| 114 |
dest: "{{ remote_tmp_dir }}/b64_latin1_template.txt" |
| 115 |
|
| 116 |
- name: Check that writing a template from a base64 encoded latin1 string matches |
| 117 |
stat: |
| 118 |
path: "{{ remote_tmp_dir }}/b64_latin1_template.txt" |
| 119 |
register: results |
| 120 |
|
| 121 |
- assert: |
| 122 |
that: |
| 123 |
- 'results.stat.checksum == b64_latin1.stat.checksum' |
| 124 |
# This one depends on being able to pass binary data through |
| 125 |
# Might be a while before we find a solution for this |
| 126 |
ignore_errors: True |
| 127 |
|
| 128 |
# These might give garbled output but none of them should traceback |
| 129 |
- debug: var=simple_accents |
| 130 |
- debug: msg="{{ utf8_simple_accents|b64decode}}" |
| 131 |
- debug: msg="{{ latin1_simple_accents|b64decode}}" |