mirror of
https://github.com/zahodi/ansible-mikrotik.git
synced 2025-07-13 19:54:23 +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():
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
hostname =dict(required=True),
|
||||
|
@ -133,7 +132,8 @@ def main():
|
|||
choices=['present', 'absent'],
|
||||
type='str'
|
||||
),
|
||||
)
|
||||
),
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
hostname = module.params['hostname']
|
||||
|
@ -143,6 +143,7 @@ def main():
|
|||
ansible_bridge_port_interface = module.params['interface']
|
||||
changed = False
|
||||
changed_message = []
|
||||
check_mode = module.check_mode
|
||||
msg = ""
|
||||
|
||||
mk = mt_api.Mikrotik(hostname, username, password)
|
||||
|
@ -184,6 +185,7 @@ def main():
|
|||
|
||||
if state == "present":
|
||||
if mikrotik_bridge_port == {}:
|
||||
if not check_mode:
|
||||
mk.api_add(
|
||||
base_path=bridge_port_path,
|
||||
params=bridge_port_params
|
||||
|
@ -201,6 +203,7 @@ def main():
|
|||
bridge_port_diff_keys[key] = bridge_port_params[key]
|
||||
if bridge_port_diff_keys != {}:
|
||||
bridge_port_diff_keys['numbers'] = client_id
|
||||
if not check_mode:
|
||||
mk.api_edit(base_path=bridge_port_path, params=bridge_port_diff_keys)
|
||||
changed = True
|
||||
changed_message.append("Changed bridge port: " + bridge_port_params['bridge'])
|
||||
|
@ -213,6 +216,7 @@ def main():
|
|||
|
||||
elif state == "absent":
|
||||
if client_id:
|
||||
if not check_mode:
|
||||
mk.api_remove(base_path=bridge_port_path, remove_id=client_id)
|
||||
changed_message.append(bridge_port_params['interface'] + " removed")
|
||||
changed = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue