From 4b953c4b161c5e9fdaed60596ac9dc48bd7e6d91 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Sat, 13 Feb 2016 19:40:05 -0500 Subject: [PATCH] extended api example with more options in tasks also adopted to less requried options --- docsite/rst/developing_api.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docsite/rst/developing_api.rst b/docsite/rst/developing_api.rst index d911d4b4e84..c6f66709c9d 100644 --- a/docsite/rst/developing_api.rst +++ b/docsite/rst/developing_api.rst @@ -46,11 +46,11 @@ In 2.0 things get a bit more complicated to start, but you end up with much more from ansible.playbook.play import Play from ansible.executor.task_queue_manager import TaskQueueManager - 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']) + Options = namedtuple('Options', ['connection', 'module_path', 'forks', 'become', 'become_method', 'become_user', 'check']) # initialize needed objects variable_manager = VariableManager() loader = DataLoader() - options = Options(connection='local', module_path='/path/to/mymodules', forks=100, remote_user=None, private_key_file=None, ssh_common_args=None, ssh_extra_args=None, sftp_extra_args=None, scp_extra_args=None, become=None, become_method=None, become_user=None, verbosity=None, check=False) + options = Options(connection='local', module_path='/path/to/mymodules', forks=100, become=None, become_method=None, become_user=None, check=False) passwords = dict(vault_pass='secret') # create inventory and pass to var manager @@ -62,7 +62,10 @@ In 2.0 things get a bit more complicated to start, but you end up with much more name = "Ansible Play", hosts = 'localhost', gather_facts = 'no', - tasks = [ dict(action=dict(module='debug', args=dict(msg='Hello Galaxy!'))) ] + tasks = [ + dict(action=dict(module='shell', args='ls'), register='shell_out'), + dict(action=dict(module='debug', args=dict(msg='{{shell_out.stdout}}'))) + ] ) play = Play().load(play_source, variable_manager=variable_manager, loader=loader)