mirror of
https://github.com/zahodi/ansible-mikrotik.git
synced 2025-08-18 08:18:18 +02:00
add check mode to address-list module
This commit is contained in:
parent
5c57fdccad
commit
220f44766b
2 changed files with 57 additions and 37 deletions
|
@ -66,7 +66,8 @@ def main():
|
|||
choices = ['present', 'absent', 'force'],
|
||||
type = 'str'
|
||||
),
|
||||
)
|
||||
),
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
hostname = module.params['hostname']
|
||||
|
@ -75,6 +76,7 @@ def main():
|
|||
ansible_list_name = module.params['list_name']
|
||||
ansible_address_list = module.params['address_list']
|
||||
state = module.params['state']
|
||||
check_mode = module.check_mode
|
||||
changed = False
|
||||
msg = ""
|
||||
|
||||
|
@ -141,6 +143,7 @@ def main():
|
|||
"list": list_name,
|
||||
"comment": i['comment']
|
||||
}
|
||||
if not check_mode:
|
||||
mk.api_add(address_list_path, add_dictionary)
|
||||
changed = True
|
||||
|
||||
|
@ -156,6 +159,7 @@ def main():
|
|||
#######################################
|
||||
for i in remove_list:
|
||||
remove_id = mikrotik_address_id[i]
|
||||
if not check_mode:
|
||||
mk.api_remove(address_list_path, remove_id)
|
||||
if not changed:
|
||||
changed = True
|
||||
|
@ -164,6 +168,7 @@ def main():
|
|||
# Remove every item
|
||||
#######################################
|
||||
for remove_id in mikrotik_address_id.values():
|
||||
if not check_mode:
|
||||
mk.api_remove(address_list_path, remove_id)
|
||||
if not changed:
|
||||
changed = True
|
||||
|
|
|
@ -610,7 +610,11 @@
|
|||
- address: 192.168.1.6
|
||||
comment: test_comment3
|
||||
register: address_list_add_1
|
||||
failed_when: not ( address_list_add_1 | changed )
|
||||
failed_when: (
|
||||
not ansible_check_mode
|
||||
) and (
|
||||
not ( address_list_add_1 | changed )
|
||||
)
|
||||
|
||||
- name: ALWAYS_CHANGES Test editing a firewall address-list
|
||||
mt_ip_firewall_addresslist:
|
||||
|
@ -626,8 +630,12 @@
|
|||
comment: dns2
|
||||
- address: 192.168.1.19
|
||||
comment: test_comment3
|
||||
register: editress_list_edit_1
|
||||
failed_when: not ( editress_list_edit_1 | changed )
|
||||
register: address_list_edit_1
|
||||
failed_when: (
|
||||
not ansible_check_mode
|
||||
) and (
|
||||
not ( address_list_edit_1 | changed )
|
||||
)
|
||||
|
||||
- name: Test adding a duplicate address-list
|
||||
mt_ip_firewall_addresslist:
|
||||
|
@ -643,8 +651,12 @@
|
|||
comment: dns2
|
||||
- address: 192.168.1.19
|
||||
comment: test_comment3
|
||||
register: add_dupress_list_add_dup_1
|
||||
failed_when: ( add_dupress_list_add_dup_1 | changed )
|
||||
register: add_address_list_add_dup_1
|
||||
failed_when: (
|
||||
not ansible_check_mode
|
||||
) and (
|
||||
( add_address_list_add_dup_1 | changed )
|
||||
)
|
||||
|
||||
- name: ALWAYS_CHANGES Test removing a firewall address-list
|
||||
mt_ip_firewall_addresslist:
|
||||
|
@ -653,11 +665,14 @@
|
|||
password: "{{ mt_pass }}"
|
||||
state: "absent"
|
||||
list_name: test_list
|
||||
register: remress_list_rem_1
|
||||
failed_when: not ( remress_list_rem_1 | changed )
|
||||
|
||||
tags: address_list
|
||||
register: address_list_rem_1
|
||||
failed_when: (
|
||||
not ansible_check_mode
|
||||
) and (
|
||||
not ( address_list_rem_1 | changed )
|
||||
)
|
||||
|
||||
tags: address-list
|
||||
|
||||
|
||||
###################
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue