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

This commit is contained in:
Matt Martz 2017-10-03 09:59:37 -05:00 committed by Toshio Kuratomi
parent f00d47fac0
commit 2b08e00a54

View file

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