|
|
|
|
@ -1,11 +1,14 @@
|
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
from collections import namedtuple
|
|
|
|
|
from ansible.parsing.dataloader import DataLoader
|
|
|
|
|
from ansible.vars import VariableManager
|
|
|
|
|
|
|
|
|
|
from ansible.executor.task_queue_manager import TaskQueueManager
|
|
|
|
|
from ansible.inventory import Inventory
|
|
|
|
|
from ansible.parsing.dataloader import DataLoader
|
|
|
|
|
from ansible.playbook.play import Play
|
|
|
|
|
from ansible.executor.task_queue_manager import TaskQueueManager
|
|
|
|
|
from ansible.plugins.callback import CallbackBase
|
|
|
|
|
from ansible.vars import VariableManager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create a callback object so we can capture the output
|
|
|
|
|
class ResultsCollector(CallbackBase):
|
|
|
|
|
@ -28,7 +31,7 @@ class ResultsCollector(CallbackBase):
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
host_list = ['localhost', 'www.example.com', 'www.google.com']
|
|
|
|
|
Options = namedtuple('Options', ['connection','module_path', 'forks', 'remote_user',
|
|
|
|
|
Options = namedtuple('Options', ['connection', 'module_path', 'forks', 'remote_user',
|
|
|
|
|
'private_key_file', 'ssh_common_args', 'ssh_extra_args', 'sftp_extra_args',
|
|
|
|
|
'scp_extra_args', 'become', 'become_method', 'become_user', 'verbosity', 'check'])
|
|
|
|
|
|
|
|
|
|
@ -48,10 +51,10 @@ def main():
|
|
|
|
|
|
|
|
|
|
# create play with tasks
|
|
|
|
|
play_source = dict(
|
|
|
|
|
name = "Ansible Play",
|
|
|
|
|
hosts = host_list,
|
|
|
|
|
gather_facts = 'no',
|
|
|
|
|
tasks = [ dict(action=dict(module='command', args=dict(cmd='/usr/bin/uptime'))) ]
|
|
|
|
|
name="Ansible Play",
|
|
|
|
|
hosts=host_list,
|
|
|
|
|
gather_facts='no',
|
|
|
|
|
tasks=[dict(action=dict(module='command', args=dict(cmd='/usr/bin/uptime')))]
|
|
|
|
|
)
|
|
|
|
|
play = Play().load(play_source, variable_manager=variable_manager, loader=loader)
|
|
|
|
|
|
|
|
|
|
|