add check mode to snmp module

This commit is contained in:
Valentin Gurmeza 2017-06-05 12:44:19 -07:00
parent 1326fad5c1
commit debe4f35d2
2 changed files with 84 additions and 64 deletions

View file

@ -71,7 +71,8 @@ def main():
choices = ['present', 'absent'], choices = ['present', 'absent'],
type = 'str' type = 'str'
), ),
) ),
supports_check_mode=True
) )
idempotent_parameter = None idempotent_parameter = None
@ -90,7 +91,7 @@ def main():
desired_params = params['settings'], desired_params = params['settings'],
idempotent_param = idempotent_parameter, idempotent_param = idempotent_parameter,
api_path = '/' + str(params['parameter']), api_path = '/' + str(params['parameter']),
check_mode = module.check_mode
) )
mt_obj.sync_state() mt_obj.sync_state()
@ -113,7 +114,6 @@ def main():
module.exit_json( module.exit_json(
failed=False, failed=False,
changed=False, changed=False,
#msg='',
msg=params['settings'], msg=params['settings'],
) )

View file

@ -1632,7 +1632,11 @@
settings: settings:
name: to_remove name: to_remove
register: snmp_community_rem register: snmp_community_rem
failed_when: not ( snmp_community_rem | changed ) failed_when: (
not ansible_check_mode
) and (
not ( snmp_community_rem | changed )
)
- name: ALWAYS_CHANGES modify existing snmp community - name: ALWAYS_CHANGES modify existing snmp community
mt_snmp: mt_snmp:
@ -1645,7 +1649,11 @@
addresses: "10.0.0.0/8" addresses: "10.0.0.0/8"
name: icghol name: icghol
register: snmp_community register: snmp_community
failed_when: not ( snmp_community | changed ) failed_when: (
not ansible_check_mode
) and (
not ( snmp_community | changed )
)
- name: NEVER_CHANGES check idempotency on snmp community - name: NEVER_CHANGES check idempotency on snmp community
mt_snmp: mt_snmp:
@ -1658,7 +1666,11 @@
addresses: "10.0.0.0/8" addresses: "10.0.0.0/8"
name: icghol name: icghol
register: snmp_community_idem register: snmp_community_idem
failed_when: ( snmp_community_idem | changed ) failed_when: (
not ansible_check_mode
) and (
( snmp_community_idem | changed )
)
- name: edit snmp settings - name: edit snmp settings
mt_snmp: mt_snmp:
@ -1682,7 +1694,11 @@
trap-community: icghol trap-community: icghol
trap-version: 2 trap-version: 2
register: snmp_idem register: snmp_idem
failed_when: ( snmp_community_idem | changed ) failed_when: (
not ansible_check_mode
) and (
( snmp_idem | changed )
)
- name: ALWAYS_CHANGES check editing snmp - name: ALWAYS_CHANGES check editing snmp
mt_snmp: mt_snmp:
@ -1695,7 +1711,11 @@
trap-community: icghol trap-community: icghol
trap-version: 3 trap-version: 3
register: snmp_edit register: snmp_edit
failed_when: not ( snmp_edit | changed ) failed_when: (
not ansible_check_mode
) and (
not ( snmp_edit | changed )
)
tags: snmp tags: snmp