diff --git a/ansible/library/machinectl.py b/ansible/library/machinectl.py index 58e9994..946f3fa 100644 --- a/ansible/library/machinectl.py +++ b/ansible/library/machinectl.py @@ -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: