1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
- name: integration/action/transfer_data.yml, json
hosts: test-targets
tasks:
- meta: end_play
when:
# Ansible >= 12 (ansible-core >= 2.19) only allows bytes|str through
# `ansible.plugins.action.ActionBase._transfer_data()`.
- ansible_version_major_minor is version('2.19', '>=', strict=True)
- not is_mitogen
- name: Cleanup transfer data
file:
path: /tmp/transfer-data
state: absent
- name: Create JSON transfer data
action_passthrough:
method: _transfer_data
kwargs:
remote_path: /tmp/transfer-data
data: {
"I am JSON": true
}
- name: Slurp JSON transfer data
slurp:
src: /tmp/transfer-data
register: out
- assert:
that: |
out.content|b64decode == '{"I am JSON": true}'
fail_msg: |
out={{ out }}
- name: Cleanup transfer data
file:
path: /tmp/transfer-data
state: absent
tags:
- transfer_data
- name: integration/action/transfer_data.yml, text
hosts: test-targets
tasks:
- name: Create text transfer data
action_passthrough:
method: _transfer_data
kwargs:
remote_path: /tmp/transfer-data
data: "I am text."
- name: Slurp text transfer data
slurp:
src: /tmp/transfer-data
register: out
- assert:
that:
out.content|b64decode == 'I am text.'
fail_msg: |
out={{ out }}
- name: Cleanup transfer data
file:
path: /tmp/transfer-data
state: absent
tags:
- transfer_data
|