Update uptime.py example script with changes to the API. Fixes #31229

(cherry picked from commit 2b08e00a54)
This commit is contained in:
Matt Martz 2017-10-03 09:59:37 -05:00 committed by Toshio Kuratomi
parent 280e9d7bb7
commit 3d4e77f44b

View file

@ -3,7 +3,7 @@
from collections import namedtuple
from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.inventory import Inventory
from ansible.inventory.manager import InventoryManager
from ansible.parsing.dataloader import DataLoader
from ansible.playbook.play import Play
from ansible.plugins.callback import CallbackBase
@ -33,21 +33,21 @@ def main():
host_list = ['localhost', 'www.example.com', 'www.google.com']
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'])
'scp_extra_args', 'become', 'become_method', 'become_user', 'verbosity', 'check',
'diff'])
# initialize needed objects
variable_manager = VariableManager()
loader = DataLoader()
options = Options(connection='smart', module_path='/usr/share/ansible', 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)
become_user=None, verbosity=None, check=False, diff=False)
passwords = dict()
# create inventory and pass to var manager
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=host_list)
variable_manager.set_inventory(inventory)
inventory = InventoryManager(loader=loader, sources=','.join(host_list))
variable_manager = VariableManager(loader=loader, inventory=inventory)
# create play with tasks
play_source = dict(