mirror of
https://github.com/zahodi/ansible-mikrotik.git
synced 2025-08-01 08:34:28 +02:00
add check mode to tests.yml
This commit is contained in:
parent
8ddf2e67d9
commit
fcd02f6384
2 changed files with 75 additions and 59 deletions
|
@ -53,7 +53,6 @@ from mt_common import clean_params, MikrotikIdempotent
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
|
@ -71,7 +70,8 @@ def main():
|
|||
choices = ['present', 'absent'],
|
||||
type = 'str'
|
||||
),
|
||||
)
|
||||
),
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
idempotent_parameter = None
|
||||
|
@ -90,6 +90,7 @@ def main():
|
|||
desired_params = params['settings'],
|
||||
idempotent_param = idempotent_parameter,
|
||||
api_path = '/tool/' + str(params['parameter']),
|
||||
check_mode = module.check_mode
|
||||
|
||||
)
|
||||
|
||||
|
@ -97,14 +98,14 @@ def main():
|
|||
|
||||
if mt_obj.failed:
|
||||
module.fail_json(
|
||||
msg = mt_obj.failed_msg
|
||||
msg=mt_obj.failed_msg
|
||||
)
|
||||
elif mt_obj.changed:
|
||||
module.exit_json(
|
||||
failed=False,
|
||||
changed=True,
|
||||
msg=mt_obj.changed_msg,
|
||||
diff={ "prepared": {
|
||||
diff={"prepared": {
|
||||
"old": mt_obj.old_params,
|
||||
"new": mt_obj.new_params,
|
||||
}},
|
||||
|
@ -113,7 +114,6 @@ def main():
|
|||
module.exit_json(
|
||||
failed=False,
|
||||
changed=False,
|
||||
#msg='',
|
||||
msg=params['settings'],
|
||||
)
|
||||
|
||||
|
|
|
@ -1515,7 +1515,11 @@
|
|||
address: 192.168.1.3
|
||||
from: email@localhost.com
|
||||
register: email_edit
|
||||
failed_when: not ( email_edit | changed )
|
||||
failed_when: (
|
||||
not ansible_check_mode
|
||||
) and (
|
||||
not ( email_edit | changed )
|
||||
)
|
||||
|
||||
- name: add netwatch item
|
||||
mt_tool:
|
||||
|
@ -1539,7 +1543,11 @@
|
|||
host: '192.168.10.1'
|
||||
up-script: test
|
||||
register: netwatch_idem
|
||||
failed_when: ( netwatch_idem | changed )
|
||||
failed_when: (
|
||||
not ansible_check_mode
|
||||
) and (
|
||||
( netwatch_idem | changed )
|
||||
)
|
||||
|
||||
- name: ALWAYS_CHANGES edit netwatch item, change up-script
|
||||
mt_tool:
|
||||
|
@ -1552,7 +1560,11 @@
|
|||
host: '192.168.10.1'
|
||||
up-script: test2
|
||||
register: netwatch_edit
|
||||
failed_when: not ( netwatch_edit | changed )
|
||||
failed_when: (
|
||||
not ansible_check_mode
|
||||
) and (
|
||||
not ( netwatch_edit | changed )
|
||||
)
|
||||
|
||||
- name: ALWAYS_CHANGES remove netwatch item
|
||||
mt_tool:
|
||||
|
@ -1564,7 +1576,11 @@
|
|||
settings:
|
||||
host: '192.168.10.1'
|
||||
register: netwatch_rem
|
||||
failed_when: not ( netwatch_rem | changed )
|
||||
failed_when: (
|
||||
not ansible_check_mode
|
||||
) and (
|
||||
not ( netwatch_rem | changed )
|
||||
)
|
||||
|
||||
tags: tool
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue