@@ -51,23 +51,24 @@ class {{ resource|capitalize }}(ConfigBase, {{ resource|capitalize }}Args):
51
51
commands = list ()
52
52
warnings = list ()
53
53
54
- commands .extend (self .set_config ())
54
+ existing_ {{ resource }}_facts = self .get_ {{ resource }}_facts ()
55
+ commands .extend (self .set_config (existing_ {{ resource }}_facts ))
55
56
if commands :
56
57
if not self ._module .check_mode :
57
58
self ._connection .edit_config (commands )
58
59
result ['changed' ] = True
59
60
result ['commands' ] = commands
60
61
61
- {{ resource }}_facts = self .get_ {{ resource }}_facts ()
62
+ changed_ {{ resource }}_facts = self .get_ {{ resource }}_facts ()
62
63
63
- result ['before' ] = {{ resource }}_facts
64
+ result ['before' ] = existing_ {{ resource }}_facts
64
65
if result ['changed' ]:
65
- result ['after' ] = {{ resource }}_facts
66
+ result ['after' ] = changed_ {{ resource }}_facts
66
67
67
68
result ['warnings' ] = warnings
68
69
return result
69
70
70
- def set_config (self ):
71
+ def set_config (self , existing_ {{ resource }} _facts ):
71
72
""" Collect the configuration from the args passed to the module,
72
73
collect the current configuration (as a dict from facts)
73
74
@@ -76,7 +77,7 @@ class {{ resource|capitalize }}(ConfigBase, {{ resource|capitalize }}Args):
76
77
to the desired configuration
77
78
"""
78
79
want = self ._module .params ['config' ]
79
- have = self . get_ {{ resource }}_facts ()
80
+ have = existing_ {{ resource }}_facts
80
81
resp = self .set_state (want , have )
81
82
return to_list (resp )
82
83
0 commit comments