mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Reformat everything.
This commit is contained in:
@@ -157,12 +157,17 @@ class RundeckACLManager:
|
||||
if info["status"] == 201:
|
||||
self.module.exit_json(changed=True, before={}, after=self.get_acl())
|
||||
elif info["status"] == 400:
|
||||
self.module.fail_json(msg=f"Unable to validate acl {self.module.params['name']}. Please ensure it is a valid ACL")
|
||||
self.module.fail_json(
|
||||
msg=f"Unable to validate acl {self.module.params['name']}. Please ensure it is a valid ACL"
|
||||
)
|
||||
elif info["status"] == 409:
|
||||
self.module.fail_json(msg=f"ACL {self.module.params['name']} already exists")
|
||||
else:
|
||||
self.module.fail_json(msg=f"Unhandled HTTP status {info['status']}, please report the bug",
|
||||
before={}, after=self.get_acl())
|
||||
self.module.fail_json(
|
||||
msg=f"Unhandled HTTP status {info['status']}, please report the bug",
|
||||
before={},
|
||||
after=self.get_acl(),
|
||||
)
|
||||
else:
|
||||
if facts["contents"] == self.module.params["policy"]:
|
||||
self.module.exit_json(changed=False, before=facts, after=facts)
|
||||
@@ -180,7 +185,9 @@ class RundeckACLManager:
|
||||
if info["status"] == 200:
|
||||
self.module.exit_json(changed=True, before=facts, after=self.get_acl())
|
||||
elif info["status"] == 400:
|
||||
self.module.fail_json(msg=f"Unable to validate acl {self.module.params['name']}. Please ensure it is a valid ACL")
|
||||
self.module.fail_json(
|
||||
msg=f"Unable to validate acl {self.module.params['name']}. Please ensure it is a valid ACL"
|
||||
)
|
||||
elif info["status"] == 404:
|
||||
self.module.fail_json(msg=f"ACL {self.module.params['name']} doesn't exists. Cannot update.")
|
||||
|
||||
@@ -204,35 +211,39 @@ class RundeckACLManager:
|
||||
def main():
|
||||
# Also allow the user to set values for fetch_url
|
||||
argument_spec = api_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
state=dict(type='str', choices=['present', 'absent'], default='present'),
|
||||
name=dict(required=True, type='str'),
|
||||
policy=dict(type='str'),
|
||||
project=dict(type='str'),
|
||||
))
|
||||
argument_spec.update(
|
||||
dict(
|
||||
state=dict(type="str", choices=["present", "absent"], default="present"),
|
||||
name=dict(required=True, type="str"),
|
||||
policy=dict(type="str"),
|
||||
project=dict(type="str"),
|
||||
)
|
||||
)
|
||||
|
||||
argument_spec['api_token']['aliases'] = ['token']
|
||||
argument_spec["api_token"]["aliases"] = ["token"]
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
required_if=[
|
||||
['state', 'present', ['policy']],
|
||||
["state", "present", ["policy"]],
|
||||
],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
if not bool(re.match("[a-zA-Z0-9,.+_-]+", module.params["name"])):
|
||||
module.fail_json(msg="Name contains forbidden characters. The policy can contain the characters: a-zA-Z0-9,.+_-")
|
||||
module.fail_json(
|
||||
msg="Name contains forbidden characters. The policy can contain the characters: a-zA-Z0-9,.+_-"
|
||||
)
|
||||
|
||||
if module.params["api_version"] < 14:
|
||||
module.fail_json(msg="API version should be at least 14")
|
||||
|
||||
rundeck = RundeckACLManager(module)
|
||||
if module.params['state'] == 'present':
|
||||
if module.params["state"] == "present":
|
||||
rundeck.create_or_update_acl()
|
||||
elif module.params['state'] == 'absent':
|
||||
elif module.params["state"] == "absent":
|
||||
rundeck.remove_acl()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user