Closed R1sCh0 closed 1 year ago
I finally found that the output is send in BASE64 on purpose (even if it's not mentionned in the docs of the API)
So for the future people using this module: it works... You just have to decode base64 with something like this:
- name: Backup CHECKPOINT Firewalls
hosts: Checkpoint
connection: httpapi
gather_facts: false
collections:
- check_point.gaia
vars:
backup_folder: "{{ lookup('env', 'HOME') }}/Documents/ansible/BACKUPS"
ansible_network_os: check_point.gaia.checkpoint
tags:
- backup_cp
tasks:
- debug:
var: hostvars[inventory_hostname]
- name: SHOW VERSION
cp_gaia_version_facts:
- name: RUN-SCRIPT
cp_gaia_run_script:
script: "ls -la"
register: output_encode
- name: CONVERT BASE64 to string
set_fact:
output_decode: "{{ output_encode.run_script['tasks'][0]['task-details'][0].output | b64decode }}"
R1sCh0
Hi, I open this issue because i'm unable to read the output when I execute "scripts" using the run_script module.
first heres an extract of my inventory file:
Heres my playbook with a module to show CP version that works and the other to just do a "ls"
heres the ansible command that i run:
ansible-playbook -i inventory.yaml playbook_cp.yaml
And heres the output with verbose option:
The output is unreadable. Is it a bug ? Which command could work ? Should I be using a .sh script instead ? "output": "dG90YWwgMTg3MjQKZHJ3eHJ3eHJ3dCAgNiBhZG1pbiByb290ICAgICAgICAyMjYgQXVnIDI1IDE4OjUxIC4KZHJ3eHIteHIteCAyMCBhZG1pbiByb290ICAgICAgICAyNzMgSnVsIDI5IDE3OjU5IC4uCi1ydy1yLS1yLS0gIDEgYWRtaW4gcm9vdCAgICAgIDQ1MTI1IEF1ZyAyNSAxNTo1MCBOb25lCmRyd3hyd3gtLS0gIDMgYWRtaW4gcm9vdCAgICAgICAgIDI1IEp1bCAgNiAxNzoyNSBhcGkKZHJ3eC0tLS0tLSAgMiBhZG1pbiByb290ICAgICAgICAgIDYgSmFuIDI5ICAyMDIxIGNwcmlkCi1ydy1yLS1yLS0gIDEgYWRtaW4gcm9vdCAgICAgICA4NzU0IEF1ZyAyNSAxODo0NiBkdW1wLnJkYgotcnctci0tci0tICAxIGFkbWluIGNvbmZpZyAgICAgICA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