tls_machine is not mandatory

This commit is contained in:
egarette@silique.fr 2023-06-22 15:37:29 +02:00
parent 4bacf38188
commit 7f745b3609

View file

@ -154,7 +154,7 @@ def run_module():
module_args = dict(
state=dict(type='str', required=True),
machines=dict(type='list', required=True),
tls_machine=dict(type='str', required=True),
tls_machine=dict(type='str', required=False),
)
# seed the result dict in the object
@ -184,10 +184,10 @@ def run_module():
# manipulate or modify the state as needed (this is going to be the
# part where your module will do what it needs to do)
machines = module.params['machines']
tls_machine = module.params['tls_machine']
tls_machine = module.params.get('tls_machine')
if module.params['state'] == 'stopped':
if tls_machine and tls_machine not in machines:
machines.append(tls_machine)
if tls_machine and tls_machine in machines:
machines.remove(tls_machine)
bus = SystemBus()
result['changed'], errors = stop(bus, machines)
if errors: