2014-12-10 19:37:32 +00:00
|
|
|
---
|
|
|
|
# Various ways users want to use binary data
|
|
|
|
# Could integrate into individual modules but currently these don't all work.
|
|
|
|
# Probably easier to see them all in a single block to know what we're testing.
|
|
|
|
# When we can start testing v2 we should test that all of these work.
|
|
|
|
|
2014-12-10 19:50:48 +00:00
|
|
|
# In v1: The following line will traceback if it's the first task in the role.
|
|
|
|
# Does not traceback if it's the second or third etc task.
|
|
|
|
- debug: msg="{{ utf8_simple_accents|b64decode}}"
|
|
|
|
|
2014-12-10 19:37:32 +00:00
|
|
|
# Expected values of the written files
|
|
|
|
- name: get checksums that we expect later files to have
|
|
|
|
copy:
|
|
|
|
src: from_playbook
|
|
|
|
dest: "{{ output_dir }}"
|
|
|
|
|
|
|
|
- copy:
|
|
|
|
src: b64_utf8
|
|
|
|
dest: "{{ output_dir }}"
|
|
|
|
|
|
|
|
- copy:
|
|
|
|
src: b64_latin1
|
|
|
|
dest: "{{ output_dir }}"
|
|
|
|
|
|
|
|
- stat:
|
|
|
|
path: "{{ output_dir }}/from_playbook"
|
|
|
|
register: from_playbook
|
|
|
|
|
|
|
|
- stat:
|
|
|
|
path: "{{ output_dir }}/b64_utf8"
|
|
|
|
register: b64_utf8
|
|
|
|
|
|
|
|
- stat:
|
|
|
|
path: "{{ output_dir }}/b64_latin1"
|
|
|
|
register: b64_latin1
|
|
|
|
|
2014-12-10 19:40:33 +00:00
|
|
|
# Tests themselves
|
2014-12-10 19:37:32 +00:00
|
|
|
- name: copy with utf-8 content in a playbook
|
|
|
|
copy:
|
|
|
|
content: "{{ simple_accents }}\n"
|
|
|
|
dest: "{{ output_dir }}/from_playbook.txt"
|
|
|
|
|
2015-02-03 03:33:05 +00:00
|
|
|
- name: Check that copying utf-8 content matches
|
2014-12-10 19:37:32 +00:00
|
|
|
stat:
|
|
|
|
path: "{{ output_dir }}/from_playbook.txt"
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'results.stat.checksum == from_playbook.stat.checksum'
|
|
|
|
|
|
|
|
- name: copy with utf8 in a base64 encoded string
|
|
|
|
copy:
|
|
|
|
content: "{{ utf8_simple_accents|b64decode }}\n"
|
|
|
|
dest: "{{ output_dir }}/b64_utf8.txt"
|
|
|
|
|
2015-02-03 03:33:05 +00:00
|
|
|
- name: Check that utf8 in a base64 string matches
|
2014-12-10 19:37:32 +00:00
|
|
|
stat:
|
|
|
|
path: "{{ output_dir }}/b64_utf8.txt"
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'results.stat.checksum == b64_utf8.stat.checksum'
|
2014-12-10 19:40:33 +00:00
|
|
|
|
|
|
|
- name: copy with latin1 in a base64 encoded string
|
|
|
|
copy:
|
|
|
|
content: "{{ latin1_simple_accents|b64decode }}\n"
|
|
|
|
dest: "{{ output_dir }}/b64_latin1.txt"
|
|
|
|
|
2015-02-03 03:33:05 +00:00
|
|
|
- name: Check that latin1 in a base64 string matches
|
2014-12-10 19:40:33 +00:00
|
|
|
stat:
|
|
|
|
path: "{{ output_dir }}/b64_latin1.txt"
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'results.stat.checksum == b64_latin1.stat.checksum'
|
2015-02-03 03:33:05 +00:00
|
|
|
# This one depends on being able to pass binary data through
|
|
|
|
# Might be a while before we find a solution for this
|
|
|
|
ignore_errors: True
|
2014-12-10 19:37:32 +00:00
|
|
|
|
|
|
|
- name: Template with a unicode string from the playbook
|
|
|
|
template:
|
|
|
|
src: "from_playbook_template.j2"
|
|
|
|
dest: "{{ output_dir }}/from_playbook_template.txt"
|
|
|
|
|
2015-02-03 03:33:05 +00:00
|
|
|
- name: Check that writing a template from a playbook var matches
|
2014-12-10 19:37:32 +00:00
|
|
|
stat:
|
|
|
|
path: "{{ output_dir }}/from_playbook_template.txt"
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'results.stat.checksum == from_playbook.stat.checksum'
|
|
|
|
|
|
|
|
- name: Template with utf8 in a base64 encoded string
|
|
|
|
template:
|
|
|
|
src: "b64_utf8_template.j2"
|
|
|
|
dest: "{{ output_dir }}/b64_utf8_template.txt"
|
|
|
|
|
2015-02-03 03:33:05 +00:00
|
|
|
- name: Check that writing a template from a base64 encoded utf8 string matches
|
2014-12-10 19:37:32 +00:00
|
|
|
stat:
|
|
|
|
path: "{{ output_dir }}/b64_utf8_template.txt"
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'results.stat.checksum == b64_utf8.stat.checksum'
|
|
|
|
|
2014-12-10 19:40:33 +00:00
|
|
|
- name: Template with latin1 in a base64 encoded string
|
|
|
|
template:
|
|
|
|
src: "b64_latin1_template.j2"
|
|
|
|
dest: "{{ output_dir }}/b64_latin1_template.txt"
|
|
|
|
|
2015-02-03 03:33:05 +00:00
|
|
|
- name: Check that writing a template from a base64 encoded latin1 string matches
|
2014-12-10 19:40:33 +00:00
|
|
|
stat:
|
|
|
|
path: "{{ output_dir }}/b64_latin1_template.txt"
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'results.stat.checksum == b64_latin1.stat.checksum'
|
2015-02-03 03:33:05 +00:00
|
|
|
# This one depends on being able to pass binary data through
|
|
|
|
# Might be a while before we find a solution for this
|
|
|
|
ignore_errors: True
|
2014-12-10 19:37:32 +00:00
|
|
|
|
|
|
|
# These might give garbled output but none of them should traceback
|
|
|
|
- debug: var=simple_accents
|
2014-12-10 19:50:48 +00:00
|
|
|
- debug: msg="{{ utf8_simple_accents|b64decode}}"
|
|
|
|
- debug: msg="{{ latin1_simple_accents|b64decode}}"
|