Incorporated Ansible community feedback
This commit is contained in:
parent
019de090d4
commit
8c5b189f8b
3 changed files with 56 additions and 37 deletions
0
lib/ansible/modules/network/dnos10/__init__.py
Normal file
0
lib/ansible/modules/network/dnos10/__init__.py
Normal file
|
@ -23,7 +23,7 @@ version_added: "2.2"
|
||||||
author: "Senthil Kumar Ganesan (@skg_net)"
|
author: "Senthil Kumar Ganesan (@skg_net)"
|
||||||
short_description: Run commands on remote devices running Dell OS10
|
short_description: Run commands on remote devices running Dell OS10
|
||||||
description:
|
description:
|
||||||
- Sends arbitrary commands to an Dell OS10 node and returns the results
|
- Sends arbitrary commands to a Dell OS10 node and returns the results
|
||||||
read from the device. This module includes an
|
read from the device. This module includes an
|
||||||
argument that will cause the module to wait for a specific condition
|
argument that will cause the module to wait for a specific condition
|
||||||
before returning or timing out if the condition is not met.
|
before returning or timing out if the condition is not met.
|
||||||
|
@ -44,11 +44,10 @@ options:
|
||||||
- List of conditions to evaluate against the output of the
|
- List of conditions to evaluate against the output of the
|
||||||
command. The task will wait for each condition to be true
|
command. The task will wait for each condition to be true
|
||||||
before moving forward. If the conditional is not true
|
before moving forward. If the conditional is not true
|
||||||
within the configured number of retries, the task fails.
|
within the configured number of I(retries), the task fails.
|
||||||
See examples.
|
See examples.
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
aliases: ['waitfor']
|
|
||||||
retries:
|
retries:
|
||||||
description:
|
description:
|
||||||
- Specifies the number of retries a command should by tried
|
- Specifies the number of retries a command should by tried
|
||||||
|
@ -145,7 +144,7 @@ def to_lines(stdout):
|
||||||
def main():
|
def main():
|
||||||
spec = dict(
|
spec = dict(
|
||||||
commands=dict(type='list', required=True),
|
commands=dict(type='list', required=True),
|
||||||
wait_for=dict(type='list', aliases=['waitfor']),
|
wait_for=dict(type='list'),
|
||||||
retries=dict(default=10, type='int'),
|
retries=dict(default=10, type='int'),
|
||||||
interval=dict(default=1, type='int')
|
interval=dict(default=1, type='int')
|
||||||
)
|
)
|
|
@ -23,8 +23,8 @@ version_added: "2.2"
|
||||||
author: "Senthil Kumar Ganesan (@skg_net)"
|
author: "Senthil Kumar Ganesan (@skg_net)"
|
||||||
short_description: Manage Dell OS10 configuration sections
|
short_description: Manage Dell OS10 configuration sections
|
||||||
description:
|
description:
|
||||||
- Dell OS10 configurations use a simple block indent file sytanx
|
- Dell OS10 configurations use a simple block indent file syntax
|
||||||
for segementing configuration into sections. This module provides
|
for segmenting configuration into sections. This module provides
|
||||||
an implementation for working with Dell OS10 configuration sections in
|
an implementation for working with Dell OS10 configuration sections in
|
||||||
a deterministic way.
|
a deterministic way.
|
||||||
extends_documentation_fragment: dnos10
|
extends_documentation_fragment: dnos10
|
||||||
|
@ -35,7 +35,7 @@ options:
|
||||||
section. The commands must be the exact same commands as found
|
section. The commands must be the exact same commands as found
|
||||||
in the device running-config. Be sure to note the configuration
|
in the device running-config. Be sure to note the configuration
|
||||||
command syntax as some commands are automatically modified by the
|
command syntax as some commands are automatically modified by the
|
||||||
device config parser.
|
device config parser. This argument is mutually exclusive with O(src).
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
aliases: ['commands']
|
aliases: ['commands']
|
||||||
|
@ -62,7 +62,7 @@ options:
|
||||||
a change needs to be made. This allows the playbook designer
|
a change needs to be made. This allows the playbook designer
|
||||||
the opportunity to perform configuration commands prior to pushing
|
the opportunity to perform configuration commands prior to pushing
|
||||||
any changes without affecting how the set of commands are matched
|
any changes without affecting how the set of commands are matched
|
||||||
against the system
|
against the system.
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
after:
|
after:
|
||||||
|
@ -93,20 +93,39 @@ options:
|
||||||
the modified lines are pushed to the device in configuration
|
the modified lines are pushed to the device in configuration
|
||||||
mode. If the replace argument is set to I(block) then the entire
|
mode. If the replace argument is set to I(block) then the entire
|
||||||
command block is pushed to the device in configuration mode if any
|
command block is pushed to the device in configuration mode if any
|
||||||
line is not correct
|
line is not correct.
|
||||||
required: false
|
required: false
|
||||||
default: line
|
default: line
|
||||||
choices: ['line', 'block']
|
choices: ['line', 'block']
|
||||||
update_config:
|
update:
|
||||||
description:
|
description:
|
||||||
- This arugment will either cause or prevent the changed commands
|
- The I(update) argument controls how the configuration statements
|
||||||
from being sent to the remote device. The set to true, the
|
are processed on the remote device. Valid choices for the I(update)
|
||||||
remote Dell OS10 device will be configured with the updated commands
|
argument are I(merge) and I(check). When the argument is set to
|
||||||
and when set to false, the remote device will not be updated.
|
I(merge), the configuration changes are merged with the current
|
||||||
|
device running configuration. When the argument is set to I(check)
|
||||||
|
the configuration updates are determined but not actually configured
|
||||||
|
on the remote device.
|
||||||
required: false
|
required: false
|
||||||
default: yes
|
default: merge
|
||||||
|
choices: ['merge', 'check']
|
||||||
|
save:
|
||||||
|
description:
|
||||||
|
- The C(save) argument instructs the module to save the running-
|
||||||
|
config to the startup-config at the conclusion of the module
|
||||||
|
running. If check mode is specified, this argument is ignored.
|
||||||
|
required: false
|
||||||
|
default: no
|
||||||
choices: ['yes', 'no']
|
choices: ['yes', 'no']
|
||||||
backup_config:
|
config:
|
||||||
|
description:
|
||||||
|
- The C(config) argument allows the playbook desginer to supply
|
||||||
|
the base configuration to be used to validate configuration
|
||||||
|
changes necessary. If this argument is provided, the module
|
||||||
|
will not download the running-config from the remote node.
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
|
backup:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
|
@ -121,7 +140,7 @@ options:
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
- dnos10_config:
|
- dnos10_config:
|
||||||
lines: ['hostname {{ inventory_hostname }}']
|
lines: ['hostname {{ inventory_hostname }}']
|
||||||
force: yes
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
- dnos10_config:
|
- dnos10_config:
|
||||||
lines:
|
lines:
|
||||||
|
@ -130,9 +149,10 @@ EXAMPLES = """
|
||||||
- 30 permit ip host 3.3.3.3 any log
|
- 30 permit ip host 3.3.3.3 any log
|
||||||
- 40 permit ip host 4.4.4.4 any log
|
- 40 permit ip host 4.4.4.4 any log
|
||||||
- 50 permit ip host 5.5.5.5 any log
|
- 50 permit ip host 5.5.5.5 any log
|
||||||
parents: ['ip access-list extended test']
|
parents: ['ip access-list test']
|
||||||
before: ['no ip access-list extended test']
|
before: ['no ip access-list test']
|
||||||
match: exact
|
match: exact
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
- dnos10_config:
|
- dnos10_config:
|
||||||
lines:
|
lines:
|
||||||
|
@ -140,15 +160,10 @@ EXAMPLES = """
|
||||||
- 20 permit ip host 2.2.2.2 any log
|
- 20 permit ip host 2.2.2.2 any log
|
||||||
- 30 permit ip host 3.3.3.3 any log
|
- 30 permit ip host 3.3.3.3 any log
|
||||||
- 40 permit ip host 4.4.4.4 any log
|
- 40 permit ip host 4.4.4.4 any log
|
||||||
parents: ['ip access-list extended test']
|
|
||||||
before: ['no ip access-list extended test']
|
|
||||||
replace: block
|
|
||||||
|
|
||||||
- dnos10_config:
|
|
||||||
commands: "{{lookup('file', 'datcenter1.txt')}}"
|
|
||||||
parents: ['ip access-list test']
|
parents: ['ip access-list test']
|
||||||
before: ['no ip access-list test']
|
before: ['no ip access-list test']
|
||||||
replace: block
|
replace: block
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -164,9 +179,17 @@ responses:
|
||||||
retured: when not check_mode
|
retured: when not check_mode
|
||||||
type: list
|
type: list
|
||||||
sample: ['...', '...']
|
sample: ['...', '...']
|
||||||
|
|
||||||
|
saved:
|
||||||
|
description: Returns whether the configuration is saved to the startup
|
||||||
|
configuration or not.
|
||||||
|
retured: when not check_mode
|
||||||
|
type: bool
|
||||||
|
sample: True
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from ansible.module_utils.netcfg import NetworkConfig, dumps, ConfigLine
|
from ansible.module_utils.netcfg import NetworkConfig, dumps, ConfigLine
|
||||||
from ansible.module_utils.dnos10 import NetworkModule, dnos10_argument_spec
|
from ansible.module_utils.dnos10 import NetworkModule
|
||||||
from ansible.module_utils.dnos10 import get_config, get_sublevel_config
|
from ansible.module_utils.dnos10 import get_config, get_sublevel_config
|
||||||
|
|
||||||
def get_candidate(module):
|
def get_candidate(module):
|
||||||
|
@ -194,10 +217,11 @@ def main():
|
||||||
choices=['line', 'strict', 'exact', 'none']),
|
choices=['line', 'strict', 'exact', 'none']),
|
||||||
replace=dict(default='line', choices=['line', 'block']),
|
replace=dict(default='line', choices=['line', 'block']),
|
||||||
|
|
||||||
update_config=dict(type='bool', default=True),
|
update=dict(choices=['merge', 'check'], default='merge'),
|
||||||
backup_config=dict(type='bool', default=False)
|
save=dict(type='bool', default=False),
|
||||||
|
config=dict(),
|
||||||
|
backup =dict(type='bool', default=False)
|
||||||
)
|
)
|
||||||
argument_spec.update(dnos10_argument_spec)
|
|
||||||
|
|
||||||
mutually_exclusive = [('lines', 'src')]
|
mutually_exclusive = [('lines', 'src')]
|
||||||
|
|
||||||
|
@ -206,18 +230,15 @@ def main():
|
||||||
mutually_exclusive=mutually_exclusive,
|
mutually_exclusive=mutually_exclusive,
|
||||||
supports_check_mode=True)
|
supports_check_mode=True)
|
||||||
|
|
||||||
module.check_mode = not module.params['update_config']
|
|
||||||
|
|
||||||
parents = module.params['parents'] or list()
|
parents = module.params['parents'] or list()
|
||||||
|
|
||||||
match = module.params['match']
|
match = module.params['match']
|
||||||
replace = module.params['replace']
|
replace = module.params['replace']
|
||||||
before = module.params['before']
|
|
||||||
result = dict(changed=False, saved=False)
|
result = dict(changed=False, saved=False)
|
||||||
|
|
||||||
candidate = get_candidate(module)
|
candidate = get_candidate(module)
|
||||||
|
|
||||||
if module.params['match'] != 'none':
|
if match != 'none':
|
||||||
config = get_config(module)
|
config = get_config(module)
|
||||||
if parents:
|
if parents:
|
||||||
contents = get_sublevel_config(config, module)
|
contents = get_sublevel_config(config, module)
|
||||||
|
@ -227,7 +248,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
configobjs = candidate.items
|
configobjs = candidate.items
|
||||||
|
|
||||||
if module.params['backup_config']:
|
if module.params['backup']:
|
||||||
result['__backup__'] = module.cli('show running-config')[0]
|
result['__backup__'] = module.cli('show running-config')[0]
|
||||||
|
|
||||||
commands = list()
|
commands = list()
|
||||||
|
@ -241,18 +262,17 @@ def main():
|
||||||
if module.params['after']:
|
if module.params['after']:
|
||||||
commands.extend(module.params['after'])
|
commands.extend(module.params['after'])
|
||||||
|
|
||||||
if not module.check_mode:
|
if not module.check_mode and module.params['update'] == 'merge':
|
||||||
response = module.config.load_config(commands)
|
response = module.config.load_config(commands)
|
||||||
result['responses'] = response
|
result['responses'] = response
|
||||||
|
|
||||||
if module.params['save_config']:
|
if module.params['save']:
|
||||||
module.config.save_config()
|
module.config.save_config()
|
||||||
result['saved'] = True
|
result['saved'] = True
|
||||||
|
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
|
||||||
result['updates'] = commands
|
result['updates'] = commands
|
||||||
result['connected'] = module.connected
|
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
Loading…
Reference in a new issue