Add a dummy playbook with a debugging script

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2018-06-18 11:25:31 +02:00
parent 98b57b4886
commit aad701b4dd
2 changed files with 52 additions and 0 deletions

25
playbooks/files/debug.py Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/python3
import json
import os
import sys
print(os.environ.get('TEST_VARIABLE'))
msg = sys.argv[1]
msg = json.loads(msg)
user = msg['owner']
name = msg['name']
epoch = msg['epoch']
version = msg['version']
release = msg['release']
instance = msg['instance']
print(
'{0} built: {1}:{2}-{3}-{4} in {5}'.format(
user, name, epoch, version, release, instance)
)
print('Plugin done')

View file

@ -0,0 +1,27 @@
---
- name: buildsys.build.state.change
hosts: localhost
gather_facts: false
tasks:
- debug: var=msg
- name: run my own script
hosts: localhost
gather_facts: false
tasks:
- name: Install my own script
copy:
src: files/debug.py
dest: /usr/local/bin/debug.py
mode: 0755
- name: Run the script
command: /usr/local/bin/debug.py msg '{{ msg | tojson }}'
register: output
environment:
TEST_VARIABLE: \ó/
- name: Show the output of the script
debug:
msg: "Output of the script: {{ output }}"