parent
999404121f
commit
f628881750
2 changed files with 9 additions and 8 deletions
|
@ -46,6 +46,7 @@ Ansible Changes By Release
|
||||||
* Fix ansible_distribution fact for Arch linux (https://github.com/ansible/ansible/issues/30600)
|
* Fix ansible_distribution fact for Arch linux (https://github.com/ansible/ansible/issues/30600)
|
||||||
* remove print statements from play_context/become
|
* remove print statements from play_context/become
|
||||||
* Fix vault errors after 'ansible-vault edit' (https://github.com/ansible/ansible/issues/30575)
|
* Fix vault errors after 'ansible-vault edit' (https://github.com/ansible/ansible/issues/30575)
|
||||||
|
* updated api doc example to match api changes
|
||||||
|
|
||||||
<a id="2.4"></a>
|
<a id="2.4"></a>
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ In 2.0 things get a bit more complicated to start, but you end up with much more
|
||||||
import json
|
import json
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from ansible.parsing.dataloader import DataLoader
|
from ansible.parsing.dataloader import DataLoader
|
||||||
from ansible.vars import VariableManager
|
from ansible.vars.manager import VariableManager
|
||||||
from ansible.inventory import Inventory
|
from ansible.inventory.manager import InventoryManager
|
||||||
from ansible.playbook.play import Play
|
from ansible.playbook.play import Play
|
||||||
from ansible.executor.task_queue_manager import TaskQueueManager
|
from ansible.executor.task_queue_manager import TaskQueueManager
|
||||||
from ansible.plugins.callback import CallbackBase
|
from ansible.plugins.callback import CallbackBase
|
||||||
|
@ -63,21 +63,21 @@ In 2.0 things get a bit more complicated to start, but you end up with much more
|
||||||
This method could store the result in an instance attribute for retrieval later
|
This method could store the result in an instance attribute for retrieval later
|
||||||
"""
|
"""
|
||||||
host = result._host
|
host = result._host
|
||||||
print json.dumps({host.name: result._result}, indent=4)
|
print(json.dumps({host.name: result._result}, indent=4))
|
||||||
|
|
||||||
Options = namedtuple('Options', ['connection', 'module_path', 'forks', 'become', 'become_method', 'become_user', 'check'])
|
Options = namedtuple('Options', ['connection', 'module_path', 'forks', 'become', 'become_method', 'become_user', 'check', 'diff'])
|
||||||
# initialize needed objects
|
# initialize needed objects
|
||||||
variable_manager = VariableManager()
|
|
||||||
loader = DataLoader()
|
loader = DataLoader()
|
||||||
options = Options(connection='local', module_path='/path/to/mymodules', forks=100, become=None, become_method=None, become_user=None, check=False)
|
options = Options(connection='local', module_path='/path/to/mymodules', forks=100, become=None, become_method=None, become_user=None, check=False,
|
||||||
|
diff=False)
|
||||||
passwords = dict(vault_pass='secret')
|
passwords = dict(vault_pass='secret')
|
||||||
|
|
||||||
# Instantiate our ResultCallback for handling results as they come in
|
# Instantiate our ResultCallback for handling results as they come in
|
||||||
results_callback = ResultCallback()
|
results_callback = ResultCallback()
|
||||||
|
|
||||||
# create inventory and pass to var manager
|
# create inventory and pass to var manager
|
||||||
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list='localhost')
|
inventory = InventoryManager(loader=loader, sources=['localhost'])
|
||||||
variable_manager.set_inventory(inventory)
|
variable_manager = VariableManager(loader=loader, inventory=inventory)
|
||||||
|
|
||||||
# create play with tasks
|
# create play with tasks
|
||||||
play_source = dict(
|
play_source = dict(
|
||||||
|
|
Loading…
Reference in a new issue