Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zeitounator/fd7841bf22a2f1ad5483d7ea6c2cfcf3 to your computer and use it in GitHub Desktop.
Save zeitounator/fd7841bf22a2f1ad5483d7ea6c2cfcf3 to your computer and use it in GitHub Desktop.
$ tree
.
├── library
│   └── Script.py
└── project
└── test.yml
2 directories, 2 files
$ cat library/Script.py
print('youpi!')
$ cat project/test.yml
---
- name: ZOP network allow
hosts: localhost
gather_facts: false
vars:
ACCESS: toto
BUSINESSUNIT: pipo
ENVIRONMENT: bingo
DESTINATION: bla
tasks:
- name: Execute python
ansible.builtin.script: ../library/Script.py -ac {{ ACCESS }} -bu {{BUSINESSUNIT }} -e {{ ENVIRONMENT }} -d {{ DESTINATION }}
args:
executable: python3
$ cd project/
$ ansible-playbook -v test.yml
No config file found; using defaults
PLAY [ZOP network allow] ********************************************************************************************************************************************
TASK [Execute python] ***********************************************************************************************************************************************
changed: [localhost] => {"changed": true, "rc": 0, "stderr": "", "stderr_lines": [], "stdout": "youpi!\n", "stdout_lines": ["youpi!"]}
PLAY RECAP **********************************************************************************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment