mirror of
https://github.com/zahodi/ansible-mikrotik.git
synced 2025-07-14 04:04:21 +02:00
add check mode to interface_bridge_port
This commit is contained in:
parent
297f3228bc
commit
35020e9c4e
1 changed files with 47 additions and 43 deletions
|
@ -96,7 +96,6 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
hostname =dict(required=True),
|
hostname =dict(required=True),
|
||||||
|
@ -133,7 +132,8 @@ def main():
|
||||||
choices=['present', 'absent'],
|
choices=['present', 'absent'],
|
||||||
type='str'
|
type='str'
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
hostname = module.params['hostname']
|
hostname = module.params['hostname']
|
||||||
|
@ -143,6 +143,7 @@ def main():
|
||||||
ansible_bridge_port_interface = module.params['interface']
|
ansible_bridge_port_interface = module.params['interface']
|
||||||
changed = False
|
changed = False
|
||||||
changed_message = []
|
changed_message = []
|
||||||
|
check_mode = module.check_mode
|
||||||
msg = ""
|
msg = ""
|
||||||
|
|
||||||
mk = mt_api.Mikrotik(hostname, username, password)
|
mk = mt_api.Mikrotik(hostname, username, password)
|
||||||
|
@ -184,6 +185,7 @@ def main():
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
if mikrotik_bridge_port == {}:
|
if mikrotik_bridge_port == {}:
|
||||||
|
if not check_mode:
|
||||||
mk.api_add(
|
mk.api_add(
|
||||||
base_path=bridge_port_path,
|
base_path=bridge_port_path,
|
||||||
params=bridge_port_params
|
params=bridge_port_params
|
||||||
|
@ -201,6 +203,7 @@ def main():
|
||||||
bridge_port_diff_keys[key] = bridge_port_params[key]
|
bridge_port_diff_keys[key] = bridge_port_params[key]
|
||||||
if bridge_port_diff_keys != {}:
|
if bridge_port_diff_keys != {}:
|
||||||
bridge_port_diff_keys['numbers'] = client_id
|
bridge_port_diff_keys['numbers'] = client_id
|
||||||
|
if not check_mode:
|
||||||
mk.api_edit(base_path=bridge_port_path, params=bridge_port_diff_keys)
|
mk.api_edit(base_path=bridge_port_path, params=bridge_port_diff_keys)
|
||||||
changed = True
|
changed = True
|
||||||
changed_message.append("Changed bridge port: " + bridge_port_params['bridge'])
|
changed_message.append("Changed bridge port: " + bridge_port_params['bridge'])
|
||||||
|
@ -213,6 +216,7 @@ def main():
|
||||||
|
|
||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
if client_id:
|
if client_id:
|
||||||
|
if not check_mode:
|
||||||
mk.api_remove(base_path=bridge_port_path, remove_id=client_id)
|
mk.api_remove(base_path=bridge_port_path, remove_id=client_id)
|
||||||
changed_message.append(bridge_port_params['interface'] + " removed")
|
changed_message.append(bridge_port_params['interface'] + " removed")
|
||||||
changed = True
|
changed = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue