diff options
author | Dag Wieers <dag@wieers.com> | 2017-05-18 09:38:40 +0200 |
---|---|---|
committer | John R Barker <john@johnrbarker.com> | 2017-05-18 08:38:40 +0100 |
commit | ea27baf7ff0ba8c148c66fddd5800d7811b200cb (patch) | |
tree | 4d9edfcc9003edca789e847d1f24106dfc686885 /examples/scripts | |
parent | de907a8e36113a4112874234ff8c21958998e51e (diff) | |
download | ansible-ea27baf7ff0ba8c148c66fddd5800d7811b200cb.tar.gz |
examples/: PEP8 compliancy (#24682)
- Make PEP8 compliant
Diffstat (limited to 'examples/scripts')
-rwxr-xr-x | examples/scripts/uptime.py | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/examples/scripts/uptime.py b/examples/scripts/uptime.py index c7d26cf5e9..6df1fa54fc 100755 --- a/examples/scripts/uptime.py +++ b/examples/scripts/uptime.py @@ -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.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.executor.task_queue_manager import TaskQueueManager 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) |