1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

'make pep8' is now clean

This commit is contained in:
Michael DeHaan 2013-02-17 19:48:02 -05:00
parent 9cf66f4376
commit 8097fd18a2
11 changed files with 53 additions and 51 deletions

View file

@ -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
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>

View file

@ -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()
)

View file

@ -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
# ==============================================================

View file

@ -508,20 +508,24 @@ class FreeBsdUser(User):
SHADOWFILE = '/etc/master.passwd'
def remove_user(self):
cmd = [self.module.get_bin_path('pw', True),
cmd = [
self.module.get_bin_path('pw', True),
'userdel',
'-n',
self.name ]
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),
cmd = [
self.module.get_bin_path('pw', True),
'useradd',
'-n',
self.name ]
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),
cmd = [
self.module.get_bin_path('chpass', True),
'-p',
self.password,
self.name ]
self.name
]
return self.execute_command(cmd)
return (rc, out, err)
def modify_user(self):
cmd = [self.module.get_bin_path('pw', True),
cmd = [
self.module.get_bin_path('pw', True),
'usermod',
'-n',
self.name ]
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),
cmd = [
self.module.get_bin_path('chpass', True),
'-p',
self.password,
self.name ]
self.name
]
return self.execute_command(cmd)
return (rc, out, err)