File tree 2 files changed +39
-9
lines changed
plugins/module_utils/helper
2 files changed +39
-9
lines changed Original file line number Diff line number Diff line change 1
1
from ansible .module_utils .basic import AnsibleModule
2
+ from ansible_collections .ansibleguy .opnsense .plugins .module_utils .base .handler import \
3
+ ModuleSoftError
2
4
3
5
4
6
def purge (
@@ -12,17 +14,20 @@ def purge(
12
14
result ['diff' ]['after' ][item_to_purge [diff_param ]] = None
13
15
14
16
if not module .check_mode :
15
- _obj = obj_func (item_to_purge )
16
- _obj .exists = True
17
+ try :
18
+ _obj = obj_func (item_to_purge )
19
+ _obj .exists = True
17
20
18
- if module .params ['action' ] == 'delete' :
19
- _obj .delete ()
21
+ if module .params ['action' ] == 'delete' :
22
+ _obj .delete ()
20
23
21
- else :
22
- if _obj .b .is_enabled ():
23
- result ['diff' ]['before' ][item_to_purge [diff_param ]] = {'enabled' : True }
24
- result ['diff' ]['after' ][item_to_purge [diff_param ]] = {'enabled' : False }
25
- _obj .b .disable ()
24
+ else :
25
+ if _obj .b .is_enabled ():
26
+ result ['diff' ]['before' ][item_to_purge [diff_param ]] = {'enabled' : True }
27
+ result ['diff' ]['after' ][item_to_purge [diff_param ]] = {'enabled' : False }
28
+ _obj .b .disable ()
29
+ except ModuleSoftError :
30
+ pass
26
31
27
32
28
33
def check_purge_filter (module : AnsibleModule , item : dict ) -> bool :
Original file line number Diff line number Diff line change 126
126
opn7.data | length != 1
127
127
when : not ansible_check_mode
128
128
129
+ - name : Adding 4
130
+ ansibleguy.opnsense.alias_multi :
131
+ aliases :
132
+ ANSIBLE_TEST_4_1 :
133
+ content : ['192.168.1.1', '192.168.1.2']
134
+ ANSIBLE_TEST_4_2 :
135
+ content : ' ANSIBLE_TEST_4_1'
136
+ when : not ansible_check_mode
137
+
138
+ - name : Purge used alias
139
+ ansibleguy.opnsense.alias_purge :
140
+ aliases :
141
+ ANSIBLE_TEST_4_2 :
142
+ when : not ansible_check_mode
143
+ register : opn11
144
+ failed_when : >
145
+ opn11.failed or
146
+ 'warnings' not in opn11
147
+
148
+ - name : Purge using alias first
149
+ ansibleguy.opnsense.alias_purge :
150
+ aliases :
151
+ ANSIBLE_TEST_4_1 :
152
+ when : not ansible_check_mode
153
+
129
154
- name : Purge ALL - not forced
130
155
ansibleguy.opnsense.alias_purge :
131
156
when : not ansible_check_mode
You can’t perform that action at this time.
0 commit comments