|
|
|
@ -174,15 +174,6 @@ options:
|
|
|
|
|
default: no
|
|
|
|
|
choices: ['yes', 'no']
|
|
|
|
|
version_added: "2.2"
|
|
|
|
|
state:
|
|
|
|
|
description:
|
|
|
|
|
- This argument specifies whether or not the running-config is
|
|
|
|
|
present on the remote device. When set to I(absent) the
|
|
|
|
|
running-config on the remote device is erased.
|
|
|
|
|
required: false
|
|
|
|
|
default: no
|
|
|
|
|
choices: ['yes', 'no']
|
|
|
|
|
version_added: "2.2"
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
EXAMPLES = """
|
|
|
|
@ -247,11 +238,6 @@ from ansible.module_utils.ios import NetworkModule, NetworkError
|
|
|
|
|
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
|
|
|
|
from ansible.module_utils.netcli import Command
|
|
|
|
|
|
|
|
|
|
def invoke(name, *args, **kwargs):
|
|
|
|
|
func = globals().get(name)
|
|
|
|
|
if func:
|
|
|
|
|
return func(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
def check_args(module, warnings):
|
|
|
|
|
if module.params['parents']:
|
|
|
|
|
if not module.params['lines'] or module.params['src']:
|
|
|
|
@ -304,7 +290,7 @@ def load_config(module, commands, result):
|
|
|
|
|
result['changed'] = module.params['update'] != 'check'
|
|
|
|
|
result['updates'] = commands.split('\n')
|
|
|
|
|
|
|
|
|
|
def present(module, result):
|
|
|
|
|
def run(module, result):
|
|
|
|
|
match = module.params['match']
|
|
|
|
|
replace = module.params['replace']
|
|
|
|
|
|
|
|
|
@ -341,11 +327,6 @@ def present(module, result):
|
|
|
|
|
if module.params['save'] and not module.check_mode:
|
|
|
|
|
module.config.save_config()
|
|
|
|
|
|
|
|
|
|
def absent(module, result):
|
|
|
|
|
if not module.check_mode:
|
|
|
|
|
module.cli('write erase')
|
|
|
|
|
result['changed'] = True
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
argument_spec = dict(
|
|
|
|
@ -371,8 +352,6 @@ def main():
|
|
|
|
|
default=dict(type='bool', default=False),
|
|
|
|
|
|
|
|
|
|
save=dict(type='bool', default=False),
|
|
|
|
|
|
|
|
|
|
state=dict(choices=['present', 'absent'], default='present')
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
mutually_exclusive = [('lines', 'src')]
|
|
|
|
@ -382,8 +361,6 @@ def main():
|
|
|
|
|
mutually_exclusive=mutually_exclusive,
|
|
|
|
|
supports_check_mode=True)
|
|
|
|
|
|
|
|
|
|
state = module.params['state']
|
|
|
|
|
|
|
|
|
|
if module.params['force'] is True:
|
|
|
|
|
module.params['match'] = 'none'
|
|
|
|
|
|
|
|
|
@ -396,7 +373,7 @@ def main():
|
|
|
|
|
result['__backup__'] = module.config.get_config()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
invoke(state, module, result)
|
|
|
|
|
run(module, result)
|
|
|
|
|
except NetworkError:
|
|
|
|
|
load_backup(module)
|
|
|
|
|
exc = get_exception()
|
|
|
|
|