Hi!
I would like to load Tasks or Playbooks from file.
I created a setup using http://docs.ansible.com/ansible/developing_api.html for ansible 2.0 python-api.
Currently I have this: https://gist.github.com/catmin/cd51dda473ebeb3e99e8
Aim is to have a File (instead of the dict) containing Ansible tasks and and run them via Play() and TaskQueueManager() - as stated in the following example.
task-file:
tasks:
- copy: src=files/foo dest=/tmp/foo owner=root group=root mode=0644
- sysctl: name=net.ipv4.ip_forward value=1 state=present
- apt: name=wget state=absent
I’m looking for something like this:
f = open('task_file','r')
play_source = dict(
name = "Ansible Play",
hosts = '192.168.56.212',
gather_facts = 'no',
tasks = read_tasks_from_file(f.read())
)
Is there a method or Class to do that?
Thank you!
- Reinhard
Ansible Version:
ansible 2.0.0.2