Commit 1d8bb177 by Michael DeHaan

misc code cleanup

parent 5a63a48e
...@@ -94,7 +94,7 @@ class Inventory(object): ...@@ -94,7 +94,7 @@ class Inventory(object):
for group in groups: for group in groups:
for host in group.get_hosts(): for host in group.get_hosts():
if group.name == pat or pat == 'all' or self._match(host.name, pat): if group.name == pat or pat == 'all' or self._match(host.name, pat):
#must test explicitly for None because [] means no hosts allowed # must test explicitly for None because [] means no hosts allowed
if self._restriction==None or host.name in self._restriction: if self._restriction==None or host.name in self._restriction:
if inverted: if inverted:
if host.name in hosts: if host.name in hosts:
...@@ -128,7 +128,6 @@ class Inventory(object): ...@@ -128,7 +128,6 @@ class Inventory(object):
def get_variables(self, hostname): def get_variables(self, hostname):
if self._is_script: if self._is_script:
# TODO: move this to inventory_script.py
host = self.get_host(hostname) host = self.get_host(hostname)
cmd = subprocess.Popen( cmd = subprocess.Popen(
[self.host_list,"--host",hostname], [self.host_list,"--host",hostname],
......
...@@ -23,6 +23,7 @@ import ansible.constants as C ...@@ -23,6 +23,7 @@ import ansible.constants as C
from ansible import utils from ansible import utils
from ansible import errors from ansible import errors
import os import os
import collections
from play import Play from play import Play
############################################# #############################################
...@@ -81,7 +82,7 @@ class PlayBook(object): ...@@ -81,7 +82,7 @@ class PlayBook(object):
sudo: if not specified per play, requests all plays use sudo mode sudo: if not specified per play, requests all plays use sudo mode
""" """
self.SETUP_CACHE = {} self.SETUP_CACHE = collections.defaultdict(dict)
if playbook is None or callbacks is None or runner_callbacks is None or stats is None: if playbook is None or callbacks is None or runner_callbacks is None or stats is None:
raise Exception('missing required arguments') raise Exception('missing required arguments')
...@@ -157,7 +158,7 @@ class PlayBook(object): ...@@ -157,7 +158,7 @@ class PlayBook(object):
# loop through all patterns and run them # loop through all patterns and run them
self.callbacks.on_start() self.callbacks.on_start()
for play_ds in self.playbook: for play_ds in self.playbook:
self.SETUP_CACHE = {} self.SETUP_CACHE = collections.defaultdict(dict)
self._run_play(Play(self,play_ds)) self._run_play(Play(self,play_ds))
# summarize the results # summarize the results
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment