diff --git a/library/apt_key b/library/apt_key index e2e66cd441..7bc9287eab 100644 --- a/library/apt_key +++ b/library/apt_key @@ -84,11 +84,11 @@ def all_keys(module): results = [] lines = out.split('\n') for line in lines: - if line.startswith("pub"): - tokens = line.split() - code = tokens[1] - (len_type, real_code) = code.split("/") - results.append(real_code) + if line.startswith("pub"): + tokens = line.split() + code = tokens[1] + (len_type, real_code) = code.split("/") + results.append(real_code) return results def key_present(module, key_id): diff --git a/library/ec2 b/library/ec2 index 75317562e2..e34d63d761 100644 --- a/library/ec2 +++ b/library/ec2 @@ -219,9 +219,7 @@ def main(): } instances.append(d) - result = {"changed": True, - "instances": instances } - module.exit_json(**result) + module.exit_json(changed=True, instances=instances) # this is magic, see lib/ansible/module_common.py #<> diff --git a/library/ec2_facts b/library/ec2_facts index 270558bf61..ad7b02a3c9 100644 --- a/library/ec2_facts +++ b/library/ec2_facts @@ -73,7 +73,8 @@ class Ec2Metadata(object): for pattern in filter_patterns: for key in new_fields.keys(): match = re.search(pattern, key) - if match: new_fields.pop(key) + if match: + new_fields.pop(key) return new_fields def fetch(self, uri, recurse=True): @@ -103,23 +104,19 @@ class Ec2Metadata(object): newkey = key.replace(':','_').replace('-','_') data[newkey] = value - def run(self): self.fetch(self.uri_meta) # populate _data - data = self._mangle_fields(self._data, - self.uri_meta) + data = self._mangle_fields(self._data, self.uri_meta) data[self._prefix % 'user-data'] = self._fetch(self.uri_user) data[self._prefix % 'public-key'] = self._fetch(self.uri_ssh) self.fix_invalid_varnames(data) return data - def main(): + ec2_facts = Ec2Metadata().run() - ec2_facts_result = { - "changed" : False, - "ansible_facts" : ec2_facts - } + ec2_facts_result = dict(changed=False, ansible_facts=ec2_facts) + module = AnsibleModule( argument_spec = dict() ) diff --git a/library/fireball b/library/fireball index 11a0b61188..93988d4eb7 100644 --- a/library/fireball +++ b/library/fireball @@ -170,7 +170,7 @@ def fetch(data): # so don't use it to move ISOs, use rsync. fh = open(data['in_path']) - data = base64.b64encode(fh.read()) + data = base64.b64encode(fh.read()) return dict(data=data) def put(data): diff --git a/library/mongodb_user b/library/mongodb_user index d6b6469d4e..bba1c192d0 100644 --- a/library/mongodb_user +++ b/library/mongodb_user @@ -116,7 +116,7 @@ def load_mongocnf(): config = ConfigParser.RawConfigParser() mongocnf = os.path.expanduser('~/.mongodb.cnf') if not os.path.exists(mongocnf): - return False + return False try: config.readfp(open(mongocnf)) diff --git a/library/nagios b/library/nagios index b5afbcf546..7d4edd9c18 100644 --- a/library/nagios +++ b/library/nagios @@ -347,13 +347,13 @@ class Nagios(object): def schedule_host_svc_downtime(self, host, minutes=30): """ This command is used to schedule downtime for - all services associated with a particular host. + all services associated with a particular host. During the specified downtime, Nagios will not send notifications out about the host. - SCHEDULE_HOST_SVC_DOWNTIME;;;; - ;;;; + SCHEDULE_HOST_SVC_DOWNTIME;;;; + ;;;; """ cmd = "SCHEDULE_HOST_SVC_DOWNTIME" diff --git a/library/service b/library/service index 29929e892f..963d8e6a68 100644 --- a/library/service +++ b/library/service @@ -596,9 +596,9 @@ class NetBsdService(Service): initpaths = [ '/etc/rc.d' ] # better: $rc_directories - how to get in here? Run: sh -c '. /etc/rc.conf ; echo $rc_directories' for initdir in initpaths: - initscript = "%s/%s" % (initdir,self.name) - if os.path.isfile(initscript): - self.svc_initscript = initscript + initscript = "%s/%s" % (initdir,self.name) + if os.path.isfile(initscript): + self.svc_initscript = initscript if not self.svc_initscript: self.module.fail_json(msg='unable to find rc.d script') diff --git a/library/setup b/library/setup index c92a8e0b2c..5119b08647 100644 --- a/library/setup +++ b/library/setup @@ -656,7 +656,7 @@ class AIX(Hardware): for line in out.split('\n'): data = line.split(':') if 'Available' in line: - i += 1 + i += 1 self.facts['processor_count'] = int(i) def get_memory_facts(self): diff --git a/library/sysctl b/library/sysctl index 3de0659e6a..c1f34f4f80 100644 --- a/library/sysctl +++ b/library/sysctl @@ -120,11 +120,8 @@ def write_sysctl(module, lines, **sysctl_args): # ============================================================== def sysctl_args_expand(**sysctl_args): - # key_path sysctl_args['key_path'] = sysctl_args['name'].replace('.' ,'/') - sysctl_args['key_path'] = '/proc/sys/' + sysctl_args['key_path']; - - # end + sysctl_args['key_path'] = '/proc/sys/' + sysctl_args['key_path'] return sysctl_args # ============================================================== diff --git a/library/uri b/library/uri index 7e5d0b6e31..7b0b28f6ab 100644 --- a/library/uri +++ b/library/uri @@ -295,7 +295,7 @@ def main(): # Some 'basic auth' servies fail to send a 401 and require the authentication # up front. This creates the Basic authentication header and sends it immediately. if force_basic_auth: - dict_headers["Authorization"] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(user, password))) + dict_headers["Authorization"] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(user, password))) # Redirects if follow_redirects: diff --git a/library/user b/library/user index d03ef329b7..cb1b1aafd2 100644 --- a/library/user +++ b/library/user @@ -508,20 +508,24 @@ class FreeBsdUser(User): SHADOWFILE = '/etc/master.passwd' def remove_user(self): - cmd = [self.module.get_bin_path('pw', True), - 'userdel', - '-n', - self.name ] + cmd = [ + self.module.get_bin_path('pw', True), + 'userdel', + '-n', + self.name + ] if self.remove: cmd.append('-r') return self.execute_command(cmd) def create_user(self): - cmd = [self.module.get_bin_path('pw', True), - 'useradd', - '-n', - self.name ] + cmd = [ + self.module.get_bin_path('pw', True), + 'useradd', + '-n', + self.name + ] if self.uid is not None: cmd.append('-u') @@ -563,19 +567,23 @@ class FreeBsdUser(User): # we have to set the password in a second command if self.password is not None: - cmd = [self.module.get_bin_path('chpass', True), - '-p', - self.password, - self.name ] + cmd = [ + self.module.get_bin_path('chpass', True), + '-p', + self.password, + self.name + ] return self.execute_command(cmd) return (rc, out, err) def modify_user(self): - cmd = [self.module.get_bin_path('pw', True), - 'usermod', - '-n', - self.name ] + cmd = [ + self.module.get_bin_path('pw', True), + 'usermod', + '-n', + self.name + ] cmd_len = len(cmd) info = self.user_info() @@ -639,10 +647,12 @@ class FreeBsdUser(User): # we have to set the password in a second command if self.password is not None and info[1] != self.password: - cmd = [self.module.get_bin_path('chpass', True), - '-p', - self.password, - self.name ] + cmd = [ + self.module.get_bin_path('chpass', True), + '-p', + self.password, + self.name + ] return self.execute_command(cmd) return (rc, out, err)