examples/: PEP8 compliancy (#24682)

- Make PEP8 compliant
This commit is contained in:
Dag Wieers 2017-05-18 09:38:40 +02:00 committed by John R Barker
parent de907a8e36
commit ea27baf7ff
2 changed files with 21 additions and 19 deletions

View file

@ -1,44 +1,47 @@
#!/usr/bin/env python
from collections import namedtuple
from ansible.parsing.dataloader import DataLoader
from ansible.vars import VariableManager
from ansible.inventory import Inventory
from ansible.playbook.play import Play
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.plugins.callback import CallbackBase
from ansible.vars import VariableManager
# Create a callback object so we can capture the output
class ResultsCollector(CallbackBase):
def __init__(self, *args, **kwargs):
super(ResultsCollector, self).__init__(*args, **kwargs)
self.host_ok = {}
self.host_ok = {}
self.host_unreachable = {}
self.host_failed = {}
def v2_runner_on_unreachable(self, result):
self.host_unreachable[result._host.get_name()] = result
def v2_runner_on_ok(self, result, *args, **kwargs):
def v2_runner_on_ok(self, result, *args, **kwargs):
self.host_ok[result._host.get_name()] = result
def v2_runner_on_failed(self, result, *args, **kwargs):
def v2_runner_on_failed(self, result, *args, **kwargs):
self.host_failed[result._host.get_name()] = result
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'])
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'])
# 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)
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)
passwords = dict()
@ -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)

View file

@ -5,7 +5,6 @@ docs/api/conf.py
docs/bin/dump_keywords.py
docs/bin/plugin_formatter.py
docs/docsite/rst/conf.py
examples/scripts/uptime.py
lib/ansible/cli/__init__.py
lib/ansible/cli/adhoc.py
lib/ansible/cli/console.py