- Ansible 2.6.1
-
-
Save YumaInaura/3902607dddac246ca15395b5aedcc2fb to your computer and use it in GitHub Desktop.
Ansible — How to remote machine file body? ( Slurp module VS Shell module cat )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example Text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [example] **************************************************************************************************************************** | |
TASK [Gathering Facts] ******************************************************************************************************************** | |
ok: [localhost] | |
TASK [copy] ******************************************************************************************************************************* | |
ok: [localhost] | |
TASK [slurp file] ************************************************************************************************************************* | |
ok: [localhost] | |
TASK [echo file body] ********************************************************************************************************************* | |
ok: [localhost] => { | |
"msg": "Example Text\n" | |
} | |
TASK [cat file] *************************************************************************************************************************** | |
changed: [localhost] | |
TASK [echo file body] ********************************************************************************************************************* | |
ok: [localhost] => { | |
"msg": "Example Text" | |
} | |
PLAY RECAP ******************************************************************************************************************************** | |
localhost : ok=6 changed=1 unreachable=0 failed=0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: | |
- example | |
tasks: | |
- name: copy | |
copy: | |
src: example.txt | |
dest: ./ | |
- name: slurp file | |
slurp: | |
path: example.txt | |
register: slurp_file | |
- name: echo file body | |
debug: | |
msg: "{{ slurp_file.content | b64decode }}" | |
- name: cat file | |
shell: cat example.txt | |
register: cat_file | |
- name: echo file body | |
debug: | |
msg: "{{ cat_file.stdout }}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment