mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
adds support for eos_local connections to eos modules (#20961)
* updates modules to use eos_local
This commit is contained in:
parent
1d7c71ce50
commit
d8d0b007e3
4 changed files with 25 additions and 26 deletions
|
@ -28,14 +28,14 @@ version_added: "2.1"
|
||||||
author: "Peter Sprygada (@privateip)"
|
author: "Peter Sprygada (@privateip)"
|
||||||
short_description: Manage Arista EOS device configurations
|
short_description: Manage Arista EOS device configurations
|
||||||
description:
|
description:
|
||||||
- Manages network device configurations over SSH or eAPI. This module
|
- Manages network device configurations over SSH or eos_local. This module
|
||||||
allows implementers to work with the device running-config. It
|
allows implementers to work with the device running-config. It
|
||||||
provides a way to push a set of commands onto a network device
|
provides a way to push a set of commands onto a network device
|
||||||
by evaluating the current running-config and only pushing configuration
|
by evaluating the current running-config and only pushing configuration
|
||||||
commands that are not already configured. The config source can
|
commands that are not already configured. The config source can
|
||||||
be a set of commands or a template.
|
be a set of commands or a template.
|
||||||
deprecated: Deprecated in 2.2. Use M(eos_config) instead
|
deprecated: Deprecated in 2.2. Use M(eos_config) instead
|
||||||
extends_documentation_fragment: eapi
|
extends_documentation_fragment: eos_local
|
||||||
options:
|
options:
|
||||||
src:
|
src:
|
||||||
description:
|
description:
|
||||||
|
@ -76,7 +76,7 @@ options:
|
||||||
- This argument will cause the provided configuration to be replaced
|
- This argument will cause the provided configuration to be replaced
|
||||||
on the destination node. The use of the replace argument will
|
on the destination node. The use of the replace argument will
|
||||||
always cause the task to set changed to true and will implies
|
always cause the task to set changed to true and will implies
|
||||||
C(force=true). This argument is only valid with C(transport=eapi).
|
C(force=true). This argument is only valid with C(transport=eos_local).
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
choices: ['yes', 'no']
|
choices: ['yes', 'no']
|
||||||
|
@ -125,11 +125,10 @@ responses:
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from ansible.module_utils import eos
|
from ansible.module_utils import eos
|
||||||
from ansible.module_utils import eapi
|
from ansible.module_utils import eos_local
|
||||||
from ansible.module_utils.local import LocalAnsibleModule
|
from ansible.module_utils.local import LocalAnsibleModule
|
||||||
from ansible.module_utils.basic import AnsibleModle
|
from ansible.module_utils.basic import AnsibleModle
|
||||||
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
||||||
from ansible.module_utils.network import NET_TRANSPORT_ARGS, _transitional_argument_spec
|
|
||||||
|
|
||||||
SHARED_LIB = 'eos'
|
SHARED_LIB = 'eos'
|
||||||
|
|
||||||
|
@ -148,8 +147,8 @@ get_config = partial(invoke, 'get_config')
|
||||||
|
|
||||||
def check_args(module):
|
def check_args(module):
|
||||||
warnings = list()
|
warnings = list()
|
||||||
if SHARED_LIB == 'eapi':
|
if SHARED_LIB == 'eos_local':
|
||||||
eapi.check_args(module)
|
eos_local.check_args(module)
|
||||||
return warnings
|
return warnings
|
||||||
|
|
||||||
def get_current_config(module):
|
def get_current_config(module):
|
||||||
|
@ -198,7 +197,7 @@ def main():
|
||||||
config=dict()
|
config=dict()
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(eapi.eapi_argument_spec)
|
argument_spec.update(eos_local.eapi_argument_spec)
|
||||||
|
|
||||||
mutually_exclusive = [('config', 'backup'), ('config', 'force')]
|
mutually_exclusive = [('config', 'backup'), ('config', 'force')]
|
||||||
|
|
||||||
|
@ -232,7 +231,7 @@ def main():
|
||||||
# FIXME not implemented yet!!
|
# FIXME not implemented yet!!
|
||||||
if replace:
|
if replace:
|
||||||
if module.params['transport'] == 'cli':
|
if module.params['transport'] == 'cli':
|
||||||
module.fail_json(msg='config replace is only supported over eapi')
|
module.fail_json(msg='config replace is only supported over eos_local')
|
||||||
commands = str(candidate).split('\n')
|
commands = str(candidate).split('\n')
|
||||||
|
|
||||||
if commands:
|
if commands:
|
||||||
|
@ -246,5 +245,5 @@ def main():
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
SHARED_LIB = 'eapi'
|
SHARED_LIB = 'eos_local'
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -33,7 +33,7 @@ description:
|
||||||
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.
|
||||||
extends_documentation_fragment: eapi
|
extends_documentation_fragment: eos_local
|
||||||
options:
|
options:
|
||||||
commands:
|
commands:
|
||||||
description:
|
description:
|
||||||
|
@ -128,7 +128,7 @@ import time
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from ansible.module_utils import eos
|
from ansible.module_utils import eos
|
||||||
from ansible.module_utils import eapi
|
from ansible.module_utils import eos_local
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.local import LocalAnsibleModule
|
from ansible.module_utils.local import LocalAnsibleModule
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
|
@ -153,8 +153,8 @@ def invoke(name, *args, **kwargs):
|
||||||
run_commands = partial(invoke, 'run_commands')
|
run_commands = partial(invoke, 'run_commands')
|
||||||
|
|
||||||
def check_args(module, warnings):
|
def check_args(module, warnings):
|
||||||
if SHARED_LIB == 'eapi':
|
if SHARED_LIB == 'eos_local':
|
||||||
eapi.check_args(module)
|
eos_local.check_args(module, warnings)
|
||||||
|
|
||||||
def to_lines(stdout):
|
def to_lines(stdout):
|
||||||
lines = list()
|
lines = list()
|
||||||
|
@ -202,7 +202,7 @@ def main():
|
||||||
interval=dict(default=1, type='int')
|
interval=dict(default=1, type='int')
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(eapi.eapi_argument_spec)
|
argument_spec.update(eos_local.eos_local_argument_spec)
|
||||||
|
|
||||||
cls = get_ansible_module()
|
cls = get_ansible_module()
|
||||||
module = cls(argument_spec=argument_spec, supports_check_mode=True)
|
module = cls(argument_spec=argument_spec, supports_check_mode=True)
|
||||||
|
@ -256,5 +256,5 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
SHARED_LIB = 'eapi'
|
SHARED_LIB = 'eos_local'
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -222,7 +222,7 @@ delta:
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from ansible.module_utils import eos
|
from ansible.module_utils import eos
|
||||||
from ansible.module_utils import eapi
|
from ansible.module_utils import eos_local
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.local import LocalAnsibleModule
|
from ansible.module_utils.local import LocalAnsibleModule
|
||||||
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
||||||
|
@ -245,8 +245,8 @@ load_config = partial(invoke, 'load_config')
|
||||||
supports_sessions = partial(invoke, 'supports_sessions')
|
supports_sessions = partial(invoke, 'supports_sessions')
|
||||||
|
|
||||||
def check_args(module, warnings):
|
def check_args(module, warnings):
|
||||||
if SHARED_LIB == 'eapi':
|
if SHARED_LIB == 'eos_local':
|
||||||
eapi.check_args(module)
|
eos_local.check_args(module)
|
||||||
|
|
||||||
if module.params['force']:
|
if module.params['force']:
|
||||||
warnings.append('The force argument is deprecated, please use '
|
warnings.append('The force argument is deprecated, please use '
|
||||||
|
@ -330,7 +330,7 @@ def main():
|
||||||
force=dict(default=False, type='bool'),
|
force=dict(default=False, type='bool'),
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(eapi.eapi_argument_spec)
|
argument_spec.update(eos_local.eos_local_argument_spec)
|
||||||
|
|
||||||
mutually_exclusive = [('lines', 'src')]
|
mutually_exclusive = [('lines', 'src')]
|
||||||
|
|
||||||
|
@ -371,5 +371,5 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
SHARED_LIB = 'eapi'
|
SHARED_LIB = 'eos_local'
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -138,7 +138,7 @@ import re
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from ansible.module_utils import eos
|
from ansible.module_utils import eos
|
||||||
from ansible.module_utils import eapi
|
from ansible.module_utils import eos_local
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.local import LocalAnsibleModule
|
from ansible.module_utils.local import LocalAnsibleModule
|
||||||
from ansible.module_utils.six import iteritems
|
from ansible.module_utils.six import iteritems
|
||||||
|
@ -159,8 +159,8 @@ def invoke(name, *args, **kwargs):
|
||||||
run_commands = partial(invoke, 'run_commands')
|
run_commands = partial(invoke, 'run_commands')
|
||||||
|
|
||||||
def check_args(module, warnings):
|
def check_args(module, warnings):
|
||||||
if SHARED_LIB == 'eapi':
|
if SHARED_LIB == 'eos_local':
|
||||||
eapi.check_args(module)
|
eos_local.check_args(module, warnings)
|
||||||
|
|
||||||
class FactsBase(object):
|
class FactsBase(object):
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ def main():
|
||||||
gather_subset=dict(default=['!config'], type='list')
|
gather_subset=dict(default=['!config'], type='list')
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(eapi.eapi_argument_spec)
|
argument_spec.update(eos_local.eos_local_argument_spec)
|
||||||
|
|
||||||
cls = get_ansible_module()
|
cls = get_ansible_module()
|
||||||
module = cls(argument_spec=argument_spec, supports_check_mode=True)
|
module = cls(argument_spec=argument_spec, supports_check_mode=True)
|
||||||
|
@ -397,5 +397,5 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
SHARED_LIB = 'eapi'
|
SHARED_LIB = 'eos_local'
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue