Remove the dellosX_template module (#5110)
This commit is contained in:
parent
c07a2b49b6
commit
21ae84a04e
3 changed files with 0 additions and 540 deletions
|
@ -1,180 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
#
|
|
||||||
# (c) 2015 Peter Sprygada, <psprygada@ansible.com>
|
|
||||||
#
|
|
||||||
# Copyright (c) 2016 Dell Inc.
|
|
||||||
#
|
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
DOCUMENTATION = """
|
|
||||||
---
|
|
||||||
module: dellos10_template
|
|
||||||
version_added: "2.2"
|
|
||||||
author: "Senthil Kumar Ganesan (@skg-net)"
|
|
||||||
short_description: Manage Dell OS10 device configurations over SSH.
|
|
||||||
description:
|
|
||||||
- Manages Dell OS10 network device configurations over SSH. This module
|
|
||||||
allows implementors to work with the device running-config. It
|
|
||||||
provides a way to push a set of commands onto a network device
|
|
||||||
by evaluating the current running-config and only pushing configuration
|
|
||||||
commands that are not already configured. The config source can
|
|
||||||
be a set of commands or a template.
|
|
||||||
extends_documentation_fragment: dellos10
|
|
||||||
options:
|
|
||||||
src:
|
|
||||||
description:
|
|
||||||
- The path to the config source. The source can be either a
|
|
||||||
file with config or a template that will be merged during
|
|
||||||
runtime. By default the task will first search for the source
|
|
||||||
file in role or playbook root folder in templates unless a full
|
|
||||||
path to the file is given.
|
|
||||||
required: true
|
|
||||||
force:
|
|
||||||
description:
|
|
||||||
- The force argument instructs the module not to consider the
|
|
||||||
current device running-config. When set to true, this will
|
|
||||||
cause the module to push the contents of I(src) into the device
|
|
||||||
without first checking if already configured. This argument is
|
|
||||||
mutually exclusive with I(config).
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
choices: [ "true", "false" ]
|
|
||||||
backup:
|
|
||||||
description:
|
|
||||||
- When this argument is configured true, the module will backup
|
|
||||||
the running-config from the node prior to making any changes.
|
|
||||||
The backup file will be written to backup_{{ hostname }} in
|
|
||||||
the root of the playbook directory. This argument is
|
|
||||||
mutually exclusive with I(config).
|
|
||||||
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
choices: [ "true", "false" ]
|
|
||||||
config:
|
|
||||||
description:
|
|
||||||
- The module, by default, will connect to the remote device and
|
|
||||||
retrieve the current running-config to use as a base for comparing
|
|
||||||
against the contents of source. There are times when it is not
|
|
||||||
desirable to have the task get the current running-config for
|
|
||||||
every task. The I(config) argument allows the implementer to
|
|
||||||
pass in the configuration to use as the base config for
|
|
||||||
comparison. This argument is mutually exclusive with
|
|
||||||
I(force) and I(backup).
|
|
||||||
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = """
|
|
||||||
- name: push a configuration onto the device
|
|
||||||
dellos10_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: config.j2
|
|
||||||
|
|
||||||
- name: forceable push a configuration onto the device
|
|
||||||
dellos10_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: config.j2
|
|
||||||
force: yes
|
|
||||||
|
|
||||||
- name: provide the base configuration for comparison
|
|
||||||
dellos10_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: candidate_config.txt
|
|
||||||
config: current_config.txt
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = """
|
|
||||||
updates:
|
|
||||||
description: The set of commands that will be pushed to the remote device
|
|
||||||
returned: always
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
|
|
||||||
_backup:
|
|
||||||
description: The current running config of the remote device.
|
|
||||||
returned: when running config is present in the remote device.
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
|
|
||||||
responses:
|
|
||||||
description: The set of responses from issuing the commands on the device
|
|
||||||
returned: when not check_mode
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
"""
|
|
||||||
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
|
||||||
from ansible.module_utils.network import NetworkModule
|
|
||||||
import ansible.module_utils.dellos10
|
|
||||||
|
|
||||||
|
|
||||||
def get_config(module):
|
|
||||||
config = module.params['config'] or dict()
|
|
||||||
if not config and not module.params['force']:
|
|
||||||
config = module.config.get_config()
|
|
||||||
return config
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
""" main entry point for module execution
|
|
||||||
"""
|
|
||||||
|
|
||||||
argument_spec = dict(
|
|
||||||
src=dict(),
|
|
||||||
force=dict(default=False, type='bool'),
|
|
||||||
backup=dict(default=False, type='bool'),
|
|
||||||
config=dict(),
|
|
||||||
)
|
|
||||||
|
|
||||||
mutually_exclusive = [('config', 'backup'), ('config', 'force')]
|
|
||||||
|
|
||||||
module = NetworkModule(argument_spec=argument_spec,
|
|
||||||
mutually_exclusive=mutually_exclusive,
|
|
||||||
supports_check_mode=True)
|
|
||||||
|
|
||||||
result = dict(changed=False)
|
|
||||||
|
|
||||||
candidate = NetworkConfig(contents=module.params['src'], indent=1)
|
|
||||||
|
|
||||||
|
|
||||||
contents = get_config(module)
|
|
||||||
|
|
||||||
if contents:
|
|
||||||
config = NetworkConfig(contents=contents[0], indent=1)
|
|
||||||
result['_backup'] = contents[0]
|
|
||||||
|
|
||||||
commands = list()
|
|
||||||
if not module.params['force']:
|
|
||||||
commands = dumps(candidate.difference(config), 'commands')
|
|
||||||
else:
|
|
||||||
commands = str(candidate)
|
|
||||||
|
|
||||||
if commands:
|
|
||||||
commands = commands.split('\n')
|
|
||||||
if not module.check_mode:
|
|
||||||
response = module.config(commands)
|
|
||||||
result['responses'] = response
|
|
||||||
result['changed'] = True
|
|
||||||
|
|
||||||
result['updates'] = commands
|
|
||||||
module.exit_json(**result)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1,174 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
#
|
|
||||||
# (c) 2015 Peter Sprygada, <psprygada@ansible.com>
|
|
||||||
#
|
|
||||||
# Copyright (c) 2016 Dell Inc.
|
|
||||||
#
|
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
DOCUMENTATION = """
|
|
||||||
---
|
|
||||||
module: dellos6_template
|
|
||||||
version_added: "2.2"
|
|
||||||
author: "Dhivya P (@dhivyap)"
|
|
||||||
short_description: Manage Dell OS6 device configurations over SSH.
|
|
||||||
description:
|
|
||||||
- Manages Dell OS6 network device configurations over SSH. This module
|
|
||||||
allows implementors to work with the device running-config. It
|
|
||||||
provides a way to push a set of commands onto a network device
|
|
||||||
by evaluating the current running-config and only pushing configuration
|
|
||||||
commands that are not already configured. The config source can
|
|
||||||
be a set of commands or a template.
|
|
||||||
extends_documentation_fragment: dellos6
|
|
||||||
options:
|
|
||||||
src:
|
|
||||||
description:
|
|
||||||
- The path to the config source. The source can be either a
|
|
||||||
file with config or a template that will be merged during
|
|
||||||
runtime. By default the task will first search for the source
|
|
||||||
file in role or playbook root folder in templates unless a full
|
|
||||||
path to the file is given.
|
|
||||||
required: true
|
|
||||||
force:
|
|
||||||
description:
|
|
||||||
- The force argument instructs the module not to consider the
|
|
||||||
current device running-config. When set to true, this will
|
|
||||||
cause the module to push the contents of I(src) into the device
|
|
||||||
without first checking if already configured. This argument is
|
|
||||||
mutually exclusive with I(config).
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
choices: [ "true", "false" ]
|
|
||||||
backup:
|
|
||||||
description:
|
|
||||||
- When this argument is configured true, the module will backup
|
|
||||||
the running-config from the node prior to making any changes.
|
|
||||||
The backup file will be written to backup_{{ hostname }} in
|
|
||||||
the root of the playbook directory. This argument is
|
|
||||||
mutually exclusive with I(config).
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
choices: [ "true", "false" ]
|
|
||||||
config:
|
|
||||||
description:
|
|
||||||
- The module, by default, will connect to the remote device and
|
|
||||||
retrieve the current running-config to use as a base for comparing
|
|
||||||
against the contents of source. There are times when it is not
|
|
||||||
desirable to have the task get the current running-config for
|
|
||||||
every task. The I(config) argument allows the implementer to
|
|
||||||
pass in the configuration to use as the base config for
|
|
||||||
comparison. This argument is mutually exclusive with
|
|
||||||
I(force) and I(backup).
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = """
|
|
||||||
- name: push a configuration onto the device
|
|
||||||
dellos6_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: config.j2
|
|
||||||
|
|
||||||
- name: forceable push a configuration onto the device
|
|
||||||
dellos6_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: config.j2
|
|
||||||
force: yes
|
|
||||||
|
|
||||||
- name: provide the base configuration for comparison
|
|
||||||
dellos6_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: candidate_config.txt
|
|
||||||
config: current_config.txt
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = """
|
|
||||||
updates:
|
|
||||||
description: The set of commands that will be pushed to the remote device
|
|
||||||
returned: always
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
|
|
||||||
_backup:
|
|
||||||
description: The current running config of the remote device.
|
|
||||||
returned: when running config is present in the remote device.
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
|
|
||||||
responses:
|
|
||||||
description: The set of responses from issuing the commands on the device
|
|
||||||
returned: when not check_mode
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
"""
|
|
||||||
from ansible.module_utils.netcfg import dumps
|
|
||||||
from ansible.module_utils.network import NetworkModule
|
|
||||||
from ansible.module_utils.dellos6 import Dellos6NetworkConfig
|
|
||||||
|
|
||||||
|
|
||||||
def get_config(module):
|
|
||||||
config = module.params['config'] or dict()
|
|
||||||
if not config and not module.params['force']:
|
|
||||||
config = module.config.get_config()
|
|
||||||
return config
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
""" main entry point for module execution
|
|
||||||
"""
|
|
||||||
|
|
||||||
argument_spec = dict(
|
|
||||||
src=dict(),
|
|
||||||
force=dict(default=False, type='bool'),
|
|
||||||
backup=dict(default=False, type='bool'),
|
|
||||||
config=dict(),
|
|
||||||
)
|
|
||||||
mutually_exclusive = [('config', 'backup'), ('config', 'force')]
|
|
||||||
|
|
||||||
module = NetworkModule(argument_spec=argument_spec,
|
|
||||||
mutually_exclusive=mutually_exclusive,
|
|
||||||
supports_check_mode=True)
|
|
||||||
|
|
||||||
result = dict(changed=False)
|
|
||||||
candidate = Dellos6NetworkConfig(contents=module.params['src'], indent=0)
|
|
||||||
|
|
||||||
contents = get_config(module)
|
|
||||||
if contents:
|
|
||||||
config = Dellos6NetworkConfig(contents=contents[0], indent=0)
|
|
||||||
result['_backup'] = contents[0]
|
|
||||||
commands = list()
|
|
||||||
|
|
||||||
if not module.params['force']:
|
|
||||||
commands = dumps(candidate.difference(config), 'commands')
|
|
||||||
else:
|
|
||||||
commands = str(candidate)
|
|
||||||
|
|
||||||
if commands:
|
|
||||||
commands = commands.split('\n')
|
|
||||||
if not module.check_mode:
|
|
||||||
response = module.config(commands)
|
|
||||||
result['responses'] = response
|
|
||||||
result['changed'] = True
|
|
||||||
|
|
||||||
result['updates'] = commands
|
|
||||||
module.exit_json(**result)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1,186 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
#
|
|
||||||
# (c) 2015 Peter Sprygada, <psprygada@ansible.com>
|
|
||||||
#
|
|
||||||
# Copyright (c) 2016 Dell Inc.
|
|
||||||
#
|
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
DOCUMENTATION = """
|
|
||||||
---
|
|
||||||
module: dellos9_template
|
|
||||||
version_added: "2.2"
|
|
||||||
author: "Dhivya P (@dhivyap)"
|
|
||||||
short_description: Manage Dell OS9 device configurations over SSH.
|
|
||||||
description:
|
|
||||||
- Manages Dell OS9 network device configurations over SSH. This module
|
|
||||||
allows implementors to work with the device running-config. It
|
|
||||||
provides a way to push a set of commands onto a network device
|
|
||||||
by evaluating the current running-config and only pushing configuration
|
|
||||||
commands that are not already configured. The config source can
|
|
||||||
be a set of commands or a template.
|
|
||||||
extends_documentation_fragment: dellos9
|
|
||||||
options:
|
|
||||||
src:
|
|
||||||
description:
|
|
||||||
- The path to the config source. The source can be either a
|
|
||||||
file with config or a template that will be merged during
|
|
||||||
runtime. By default the task will first search for the source
|
|
||||||
file in role or playbook root folder in templates unless a full
|
|
||||||
path to the file is given.
|
|
||||||
required: true
|
|
||||||
force:
|
|
||||||
description:
|
|
||||||
- The force argument instructs the module not to consider the
|
|
||||||
current device running-config. When set to true, this will
|
|
||||||
cause the module to push the contents of I(src) into the device
|
|
||||||
without first checking if already configured. This argument is
|
|
||||||
mutually exclusive with I(config).
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
choices: [ "true", "false" ]
|
|
||||||
backup:
|
|
||||||
description:
|
|
||||||
- When this argument is configured true, the module will backup
|
|
||||||
the running-config from the node prior to making any changes.
|
|
||||||
The backup file will be written to backup_{{ hostname }} in
|
|
||||||
the root of the playbook directory. This argument is
|
|
||||||
mutually exclusive with I(config).
|
|
||||||
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
choices: [ "true", "false" ]
|
|
||||||
config:
|
|
||||||
description:
|
|
||||||
- The module, by default, will connect to the remote device and
|
|
||||||
retrieve the current running-config to use as a base for comparing
|
|
||||||
against the contents of source. There are times when it is not
|
|
||||||
desirable to have the task get the current running-config for
|
|
||||||
every task. The I(config) argument allows the implementer to
|
|
||||||
pass in the configuration to use as the base config for
|
|
||||||
comparison. This argument is mutually exclusive with
|
|
||||||
I(force) and I(backup).
|
|
||||||
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
notes:
|
|
||||||
- This module requires Dell OS9 version 9.10.0.1P13 or above.
|
|
||||||
|
|
||||||
- This module requires to increase the ssh connection rate limit.
|
|
||||||
Use the following command I(ip ssh connection-rate-limit 60)
|
|
||||||
to configure the same. This can be done via M(dnos_config) module
|
|
||||||
as well.
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = """
|
|
||||||
- name: push a configuration onto the device
|
|
||||||
dellos9_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: config.j2
|
|
||||||
|
|
||||||
- name: forceable push a configuration onto the device
|
|
||||||
dellos9_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: config.j2
|
|
||||||
force: yes
|
|
||||||
|
|
||||||
- name: provide the base configuration for comparison
|
|
||||||
dellos9_template:
|
|
||||||
host: hostname
|
|
||||||
username: foo
|
|
||||||
src: candidate_config.txt
|
|
||||||
config: current_config.txt
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = """
|
|
||||||
updates:
|
|
||||||
description: The set of commands that will be pushed to the remote device
|
|
||||||
returned: always
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
|
|
||||||
_backup:
|
|
||||||
description: The current running config of the remote device.
|
|
||||||
returned: when running config is present in the remote device.
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
|
|
||||||
responses:
|
|
||||||
description: The set of responses from issuing the commands on the device
|
|
||||||
returned: when not check_mode
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
"""
|
|
||||||
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
|
||||||
from ansible.module_utils.network import NetworkModule
|
|
||||||
import ansible.module_utils.dellos9
|
|
||||||
|
|
||||||
|
|
||||||
def get_config(module):
|
|
||||||
config = module.params['config'] or dict()
|
|
||||||
if not config and not module.params['force']:
|
|
||||||
config = module.config.get_config()
|
|
||||||
return config
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
""" main entry point for module execution
|
|
||||||
"""
|
|
||||||
|
|
||||||
argument_spec = dict(
|
|
||||||
src=dict(),
|
|
||||||
force=dict(default=False, type='bool'),
|
|
||||||
backup=dict(default=False, type='bool'),
|
|
||||||
config=dict(),
|
|
||||||
)
|
|
||||||
|
|
||||||
mutually_exclusive = [('config', 'backup'), ('config', 'force')]
|
|
||||||
|
|
||||||
module = NetworkModule(argument_spec=argument_spec,
|
|
||||||
mutually_exclusive=mutually_exclusive,
|
|
||||||
supports_check_mode=True)
|
|
||||||
|
|
||||||
result = dict(changed=False)
|
|
||||||
|
|
||||||
candidate = NetworkConfig(contents=module.params['src'], indent=1)
|
|
||||||
|
|
||||||
contents = get_config(module)
|
|
||||||
|
|
||||||
if contents:
|
|
||||||
config = NetworkConfig(contents=contents[0], indent=1)
|
|
||||||
result['_backup'] = contents[0]
|
|
||||||
|
|
||||||
commands = list()
|
|
||||||
if not module.params['force']:
|
|
||||||
commands = dumps(candidate.difference(config), 'commands')
|
|
||||||
else:
|
|
||||||
commands = str(candidate)
|
|
||||||
|
|
||||||
if commands:
|
|
||||||
commands = commands.split('\n')
|
|
||||||
if not module.check_mode:
|
|
||||||
response = module.config(commands)
|
|
||||||
result['responses'] = response
|
|
||||||
result['changed'] = True
|
|
||||||
|
|
||||||
result['updates'] = commands
|
|
||||||
module.exit_json(**result)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
Loading…
Reference in a new issue