mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Some minor from 'pep8', and silencing the PEP8 messages I don't care about.
Also make pep8 show all messages rather than just 1 per code.
This commit is contained in:
parent
0d7a84d591
commit
3ad9db4966
5 changed files with 32 additions and 24 deletions
5
Makefile
5
Makefile
|
@ -17,11 +17,14 @@ manuals: $(MANPAGES)
|
||||||
%.5: %.5.asciidoc
|
%.5: %.5.asciidoc
|
||||||
$(ASCII2MAN)
|
$(ASCII2MAN)
|
||||||
|
|
||||||
|
loc:
|
||||||
|
sloccount lib library bin
|
||||||
|
|
||||||
pep8:
|
pep8:
|
||||||
@echo "#############################################"
|
@echo "#############################################"
|
||||||
@echo "# Running PEP8 Compliance Tests"
|
@echo "# Running PEP8 Compliance Tests"
|
||||||
@echo "#############################################"
|
@echo "#############################################"
|
||||||
pep8 lib/
|
pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225 lib/ bin/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
|
|
@ -14,4 +14,3 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import shlex
|
||||||
# duplicating these
|
# duplicating these
|
||||||
|
|
||||||
class PlayBook(object):
|
class PlayBook(object):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
runs an ansible playbook, given as a datastructure
|
runs an ansible playbook, given as a datastructure
|
||||||
or YAML filename. a playbook is a deployment, config
|
or YAML filename. a playbook is a deployment, config
|
||||||
|
@ -98,7 +99,7 @@ class PlayBook(object):
|
||||||
def _prune_failed_hosts(self, host_list):
|
def _prune_failed_hosts(self, host_list):
|
||||||
new_hosts = []
|
new_hosts = []
|
||||||
for x in host_list:
|
for x in host_list:
|
||||||
if not self.failures.has_key(x) and not self.dark.has_key(x):
|
if not x in self.failures and not x in self.dark:
|
||||||
new_hosts.append(x)
|
new_hosts.append(x)
|
||||||
return new_hosts
|
return new_hosts
|
||||||
|
|
||||||
|
@ -152,7 +153,8 @@ class PlayBook(object):
|
||||||
|
|
||||||
# load up an appropriate ansible runner to
|
# load up an appropriate ansible runner to
|
||||||
# run the task in parallel
|
# run the task in parallel
|
||||||
results = self._run_module(pattern, module_name, module_args, host_list, remote_user)
|
results = self._run_module(pattern, module_name,
|
||||||
|
module_args, host_list, remote_user)
|
||||||
|
|
||||||
# if no hosts are matched, carry on, unlike /bin/ansible
|
# if no hosts are matched, carry on, unlike /bin/ansible
|
||||||
# which would warn you about this
|
# which would warn you about this
|
||||||
|
@ -171,7 +173,7 @@ class PlayBook(object):
|
||||||
self.processed[host] = 1
|
self.processed[host] = 1
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "unreachable: [%s] => %s" % (host, msg)
|
print "unreachable: [%s] => %s" % (host, msg)
|
||||||
if not self.dark.has_key(host):
|
if not host in self.dark:
|
||||||
self.dark[host] = 1
|
self.dark[host] = 1
|
||||||
else:
|
else:
|
||||||
self.dark[host] = self.dark[host] + 1
|
self.dark[host] = self.dark[host] + 1
|
||||||
|
@ -182,19 +184,19 @@ class PlayBook(object):
|
||||||
if is_failed(results):
|
if is_failed(results):
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "failed: [%s] => %s\n" % (host, smjson(results))
|
print "failed: [%s] => %s\n" % (host, smjson(results))
|
||||||
if not self.failures.has_key(host):
|
if not host in self.failures:
|
||||||
self.failures[host] = 1
|
self.failures[host] = 1
|
||||||
else:
|
else:
|
||||||
self.failures[host] = self.failures[host] + 1
|
self.failures[host] = self.failures[host] + 1
|
||||||
else:
|
else:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "ok: [%s]\n" % host
|
print "ok: [%s]\n" % host
|
||||||
if not self.invocations.has_key(host):
|
if not host in self.invocations:
|
||||||
self.invocations[host] = 1
|
self.invocations[host] = 1
|
||||||
else:
|
else:
|
||||||
self.invocations[host] = self.invocations[host] + 1
|
self.invocations[host] = self.invocations[host] + 1
|
||||||
if results.get('changed', False):
|
if results.get('changed', False):
|
||||||
if not self.changed.has_key(host):
|
if not host in self.changed:
|
||||||
self.changed[host] = 1
|
self.changed[host] = 1
|
||||||
else:
|
else:
|
||||||
self.changed[host] = self.changed[host] + 1
|
self.changed[host] = self.changed[host] + 1
|
||||||
|
@ -227,7 +229,7 @@ class PlayBook(object):
|
||||||
if match_name == name:
|
if match_name == name:
|
||||||
# flag the handler with the list of hosts
|
# flag the handler with the list of hosts
|
||||||
# it needs to be run on, it will be run later
|
# it needs to be run on, it will be run later
|
||||||
if not x.has_key("run"):
|
if not run in x:
|
||||||
x['run'] = []
|
x['run'] = []
|
||||||
x['run'].append(host)
|
x['run'].append(host)
|
||||||
|
|
||||||
|
@ -246,7 +248,7 @@ class PlayBook(object):
|
||||||
self.host_list, groups = ansible.runner.Runner.parse_hosts(host_file)
|
self.host_list, groups = ansible.runner.Runner.parse_hosts(host_file)
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "PLAY [%s] ****************************************\n" % pattern
|
print "PLAY [%s] ****************************\n" % pattern
|
||||||
|
|
||||||
# run all the top level tasks, these get run on every node
|
# run all the top level tasks, these get run on every node
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -26,9 +28,11 @@ import multiprocessing
|
||||||
import signal
|
import signal
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
import paramiko # non-core dependency
|
|
||||||
import ansible.constants as C
|
import ansible.constants as C
|
||||||
import Queue
|
import Queue
|
||||||
|
import paramiko
|
||||||
|
|
||||||
|
################################################
|
||||||
|
|
||||||
def _executor_hook(job_queue, result_queue):
|
def _executor_hook(job_queue, result_queue):
|
||||||
''' callback used by multiprocessing pool '''
|
''' callback used by multiprocessing pool '''
|
||||||
|
@ -126,7 +130,7 @@ class Runner(object):
|
||||||
if fnmatch.fnmatch(host_name, subpattern):
|
if fnmatch.fnmatch(host_name, subpattern):
|
||||||
return True
|
return True
|
||||||
# or it could be a literal group name instead
|
# or it could be a literal group name instead
|
||||||
if self.groups.has_key(subpattern):
|
if subpattern in self.groups:
|
||||||
if host_name in self.groups[subpattern]:
|
if host_name in self.groups[subpattern]:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue