1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-04 01:13:00 +00:00

Reformat everything.

This commit is contained in:
Felix Fontein 2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View file

@ -98,19 +98,24 @@ from ansible.module_utils.basic import AnsibleModule
class BackendProp:
def __init__(self, module):
self._module = module
def get_property(self, opendj_bindir, hostname, port, username, password_method, backend_name):
my_command = [
f"{opendj_bindir}/dsconfig",
'get-backend-prop',
'-h', hostname,
'--port', str(port),
'--bindDN', username,
'--backend-name', backend_name,
'-n', '-X', '-s'
"get-backend-prop",
"-h",
hostname,
"--port",
str(port),
"--bindDN",
username,
"--backend-name",
backend_name,
"-n",
"-X",
"-s",
] + password_method
rc, stdout, stderr = self._module.run_command(my_command)
if rc == 0:
@ -121,13 +126,19 @@ class BackendProp:
def set_property(self, opendj_bindir, hostname, port, username, password_method, backend_name, name, value):
my_command = [
f"{opendj_bindir}/dsconfig",
'set-backend-prop',
'-h', hostname,
'--port', str(port),
'--bindDN', username,
'--backend-name', backend_name,
'--set', f"{name}:{value}",
'-n', '-X'
"set-backend-prop",
"-h",
hostname,
"--port",
str(port),
"--bindDN",
username,
"--backend-name",
backend_name,
"--set",
f"{name}:{value}",
"-n",
"-X",
] + password_method
rc, stdout, stderr = self._module.run_command(my_command)
if rc == 0:
@ -136,7 +147,7 @@ class BackendProp:
self._module.fail_json(msg=f"Error message: {stderr}")
def validate_data(self, data=None, name=None, value=None):
for config_line in data.split('\n'):
for config_line in data.split("\n"):
if config_line:
split_line = config_line.split()
if split_line[0] == name:
@ -160,46 +171,50 @@ def main():
state=dict(default="present"),
),
supports_check_mode=True,
mutually_exclusive=[['password', 'passwordfile']],
required_one_of=[['password', 'passwordfile']]
mutually_exclusive=[["password", "passwordfile"]],
required_one_of=[["password", "passwordfile"]],
)
opendj_bindir = module.params['opendj_bindir']
hostname = module.params['hostname']
port = module.params['port']
username = module.params['username']
password = module.params['password']
passwordfile = module.params['passwordfile']
backend_name = module.params['backend']
name = module.params['name']
value = module.params['value']
state = module.params['state']
opendj_bindir = module.params["opendj_bindir"]
hostname = module.params["hostname"]
port = module.params["port"]
username = module.params["username"]
password = module.params["password"]
passwordfile = module.params["passwordfile"]
backend_name = module.params["backend"]
name = module.params["name"]
value = module.params["value"]
state = module.params["state"]
if module.params["password"] is not None:
password_method = ['-w', password]
password_method = ["-w", password]
elif module.params["passwordfile"] is not None:
password_method = ['-j', passwordfile]
password_method = ["-j", passwordfile]
opendj = BackendProp(module)
validate = opendj.get_property(opendj_bindir=opendj_bindir,
hostname=hostname,
port=port,
username=username,
password_method=password_method,
backend_name=backend_name)
validate = opendj.get_property(
opendj_bindir=opendj_bindir,
hostname=hostname,
port=port,
username=username,
password_method=password_method,
backend_name=backend_name,
)
if validate:
if not opendj.validate_data(data=validate, name=name, value=value):
if module.check_mode:
module.exit_json(changed=True)
if opendj.set_property(opendj_bindir=opendj_bindir,
hostname=hostname,
port=port,
username=username,
password_method=password_method,
backend_name=backend_name,
name=name,
value=value):
if opendj.set_property(
opendj_bindir=opendj_bindir,
hostname=hostname,
port=port,
username=username,
password_method=password_method,
backend_name=backend_name,
name=name,
value=value,
):
module.exit_json(changed=True)
else:
module.exit_json(changed=False)
@ -209,5 +224,5 @@ def main():
module.exit_json(changed=False)
if __name__ == '__main__':
if __name__ == "__main__":
main()