Executing python script on ansible master once playbook finishes
2,013 views
Skip to first unread message
Martin Schenk
unread,
Feb 22, 2016, 8:41:15 AM2/22/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Dear all,
i am new to the awesomeness of ansible. i've done some playbooks for now an am amazed of the capability of ansible. :) great product.
Now i got to a certain point where i could need some help.
My Setup: The ansible version i am using is: Anisble 1.9.4 I am running ansible on a Red Hat Enterprise Linux Server release 6.7 (Santiago) i am controlling Linux nodes with Ansible from the same system distribution
My Problem/Question: I've created a Playbook that is going to copy a template towards my node. while doing this it inserts some facts information via the template plugin. After that i am going to fetch that file back to my Ansible master.
Now i want to execute a local python script on my ansible master to parse those files into a database. But i don't have any idea how to do that. I would be so happy if anyone could give me a hint :)
Thanks in advance.
Best regards, Martin
Playbook --- # instance facts linux - hosts: Linux become: yes become_method: sudo roles: - nodeInfoLinux
Role tasks: --- # tasks file for nodeInfo - name: Fill template with server information template: src=setup.j2 dest=/tmp/facts-{{ansible_hostname}}
- name: Gather Facts to Local repository fetch: src=/tmp/facts-{{ansible_hostname}} dest=/srv/ansible/inventory-facts/facts-{{ansible_hostname}} flat=yes
Brian Coca
unread,
Feb 22, 2016, 8:56:43 AM2/22/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
something like this:
- name: run script locally # can also use the script module
shell: /path/to/script
delegate_to: localhost
run_once: True
----------
Brian Coca
Martin Schenk
unread,
Feb 22, 2016, 9:39:47 AM2/22/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
DUDE! thank you so much! ^^ it is exactly what i was looking for!