mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-03 08:52:55 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -75,22 +75,22 @@ class SudoCmdIPAClient(IPAClient):
|
|||
super().__init__(module, host, port, protocol)
|
||||
|
||||
def sudocmd_find(self, name):
|
||||
return self._post_json(method='sudocmd_find', name=None, item={'all': True, 'sudocmd': name})
|
||||
return self._post_json(method="sudocmd_find", name=None, item={"all": True, "sudocmd": name})
|
||||
|
||||
def sudocmd_add(self, name, item):
|
||||
return self._post_json(method='sudocmd_add', name=name, item=item)
|
||||
return self._post_json(method="sudocmd_add", name=name, item=item)
|
||||
|
||||
def sudocmd_mod(self, name, item):
|
||||
return self._post_json(method='sudocmd_mod', name=name, item=item)
|
||||
return self._post_json(method="sudocmd_mod", name=name, item=item)
|
||||
|
||||
def sudocmd_del(self, name):
|
||||
return self._post_json(method='sudocmd_del', name=name)
|
||||
return self._post_json(method="sudocmd_del", name=name)
|
||||
|
||||
|
||||
def get_sudocmd_dict(description=None):
|
||||
data = {}
|
||||
if description is not None:
|
||||
data['description'] = description
|
||||
data["description"] = description
|
||||
return data
|
||||
|
||||
|
||||
|
|
@ -99,14 +99,14 @@ def get_sudocmd_diff(client, ipa_sudocmd, module_sudocmd):
|
|||
|
||||
|
||||
def ensure(module, client):
|
||||
name = module.params['sudocmd']
|
||||
state = module.params['state']
|
||||
name = module.params["sudocmd"]
|
||||
state = module.params["state"]
|
||||
|
||||
module_sudocmd = get_sudocmd_dict(description=module.params['description'])
|
||||
module_sudocmd = get_sudocmd_dict(description=module.params["description"])
|
||||
ipa_sudocmd = client.sudocmd_find(name=name)
|
||||
|
||||
changed = False
|
||||
if state == 'present':
|
||||
if state == "present":
|
||||
if not ipa_sudocmd:
|
||||
changed = True
|
||||
if not module.check_mode:
|
||||
|
|
@ -131,25 +131,27 @@ def ensure(module, client):
|
|||
|
||||
def main():
|
||||
argument_spec = ipa_argument_spec()
|
||||
argument_spec.update(description=dict(type='str'),
|
||||
state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']),
|
||||
sudocmd=dict(type='str', required=True, aliases=['name']))
|
||||
argument_spec.update(
|
||||
description=dict(type="str"),
|
||||
state=dict(type="str", default="present", choices=["present", "absent", "enabled", "disabled"]),
|
||||
sudocmd=dict(type="str", required=True, aliases=["name"]),
|
||||
)
|
||||
|
||||
module = AnsibleModule(argument_spec=argument_spec,
|
||||
supports_check_mode=True)
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
|
||||
client = SudoCmdIPAClient(module=module,
|
||||
host=module.params['ipa_host'],
|
||||
port=module.params['ipa_port'],
|
||||
protocol=module.params['ipa_prot'])
|
||||
client = SudoCmdIPAClient(
|
||||
module=module,
|
||||
host=module.params["ipa_host"],
|
||||
port=module.params["ipa_port"],
|
||||
protocol=module.params["ipa_prot"],
|
||||
)
|
||||
try:
|
||||
client.login(username=module.params['ipa_user'],
|
||||
password=module.params['ipa_pass'])
|
||||
client.login(username=module.params["ipa_user"], password=module.params["ipa_pass"])
|
||||
changed, sudocmd = ensure(module, client)
|
||||
module.exit_json(changed=changed, sudocmd=sudocmd)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue