mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-19 23:00:22 -07:00
Removing provider from facts, command and config (#54623)
This commit is contained in:
parent
4b3662605d
commit
c2958df3a4
18 changed files with 13 additions and 243 deletions
|
@ -37,54 +37,14 @@ description:
|
|||
argument that will cause the module to wait for a specific condition
|
||||
before returning or timing out if the condition is not met.
|
||||
options:
|
||||
provider:
|
||||
version_added: "2.6"
|
||||
description:
|
||||
- A dict object containing connection details.
|
||||
suboptions:
|
||||
host:
|
||||
description:
|
||||
- Specifies the DNS host name or address for connecting to the remote
|
||||
device over the specified transport. The value of host is used as
|
||||
the destination address for the transport.
|
||||
required: true
|
||||
port:
|
||||
description:
|
||||
- Specifies the port to use when building the connection to the remote device.
|
||||
default: 22
|
||||
username:
|
||||
description:
|
||||
- Configures the username to use to authenticate the connection to
|
||||
the remote device. This value is used to authenticate
|
||||
the SSH session. If the value is not specified in the task, the
|
||||
value of environment variable C(ANSIBLE_NET_USERNAME) will be used instead.
|
||||
password:
|
||||
description:
|
||||
- Specifies the password to use to authenticate the connection to
|
||||
the remote device. This value is used to authenticate
|
||||
the SSH session. If the value is not specified in the task, the
|
||||
value of environment variable C(ANSIBLE_NET_PASSWORD) will be used instead.
|
||||
timeout:
|
||||
description:
|
||||
- Specifies the timeout in seconds for communicating with the network device
|
||||
for either connecting or sending commands. If the timeout is
|
||||
exceeded before the operation is completed, the module will error.
|
||||
default: 10
|
||||
ssh_keyfile:
|
||||
description:
|
||||
- Specifies the SSH key to use to authenticate the connection to
|
||||
the remote device. This value is the path to the
|
||||
key used to authenticate the SSH session. If the value is not specified
|
||||
in the task, the value of environment variable C(ANSIBLE_NET_SSH_KEYFILE)
|
||||
will be used instead.
|
||||
commands:
|
||||
version_added: "2.6"
|
||||
description:
|
||||
- List of commands to send to the remote device over the
|
||||
configured provider. The resulting output from the command
|
||||
is returned. If the I(wait_for) argument is provided, the
|
||||
module is not returned until the condition is satisfied or
|
||||
the number of retires as expired.
|
||||
- List of commands to send to the remote device.
|
||||
The resulting output from the command is returned.
|
||||
If the I(wait_for) argument is provided, the module is not
|
||||
returned until the condition is satisfied or the number of
|
||||
retires is expired.
|
||||
required: true
|
||||
wait_for:
|
||||
version_added: "2.6"
|
||||
|
@ -124,17 +84,6 @@ options:
|
|||
"""
|
||||
|
||||
EXAMPLES = """
|
||||
# Note: examples below use the following provider dict to handle
|
||||
# transport and authentication to the node.
|
||||
---
|
||||
vars:
|
||||
cli:
|
||||
host: "{{ inventory_hostname }}"
|
||||
port: 22
|
||||
username: admin
|
||||
password: admin
|
||||
timeout: 30
|
||||
|
||||
---
|
||||
- name: test contains operator
|
||||
cnos_command:
|
||||
|
@ -144,7 +93,6 @@ vars:
|
|||
wait_for:
|
||||
- "result[0] contains 'Lenovo'"
|
||||
- "result[1] contains 'MemFree'"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -155,7 +103,6 @@ vars:
|
|||
- name: get output for single command
|
||||
cnos_command:
|
||||
commands: ['show version']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -168,7 +115,6 @@ vars:
|
|||
commands:
|
||||
- show version
|
||||
- show interface information
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -200,7 +146,6 @@ import time
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.cnos.cnos import run_commands, check_args
|
||||
from ansible.module_utils.network.cnos.cnos import cnos_argument_spec
|
||||
from ansible.module_utils.network.common.parsing import Conditional
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
|
@ -224,8 +169,6 @@ def main():
|
|||
interval=dict(default=1, type='int')
|
||||
)
|
||||
|
||||
spec.update(cnos_argument_spec)
|
||||
|
||||
module = AnsibleModule(argument_spec=spec, supports_check_mode=True)
|
||||
result = {'changed': False}
|
||||
|
||||
|
|
|
@ -37,48 +37,8 @@ description:
|
|||
an implementation for working with CNOS configuration sections in
|
||||
a deterministic way.
|
||||
notes:
|
||||
- Tested against CNOS 10.8.1
|
||||
- Tested against CNOS 10.9.1
|
||||
options:
|
||||
provider:
|
||||
version_added: "2.6"
|
||||
description:
|
||||
- A dict object containing connection details.
|
||||
suboptions:
|
||||
host:
|
||||
description:
|
||||
- Specifies the DNS host name or address for connecting to the remote
|
||||
device over the specified transport. The value of host is used as
|
||||
the destination address for the transport.
|
||||
required: true
|
||||
port:
|
||||
description:
|
||||
- Specifies the port to use when building the connection to the remote device.
|
||||
default: 22
|
||||
username:
|
||||
description:
|
||||
- Configures the username to use to authenticate the connection to
|
||||
the remote device. This value is used to authenticate
|
||||
the SSH session. If the value is not specified in the task, the
|
||||
value of environment variable C(ANSIBLE_NET_USERNAME) will be used instead.
|
||||
password:
|
||||
description:
|
||||
- Specifies the password to use to authenticate the connection to
|
||||
the remote device. This value is used to authenticate
|
||||
the SSH session. If the value is not specified in the task, the
|
||||
value of environment variable C(ANSIBLE_NET_PASSWORD) will be used instead.
|
||||
timeout:
|
||||
description:
|
||||
- Specifies the timeout in seconds for communicating with the network device
|
||||
for either connecting or sending commands. If the timeout is
|
||||
exceeded before the operation is completed, the module will error.
|
||||
default: 10
|
||||
ssh_keyfile:
|
||||
description:
|
||||
- Specifies the SSH key to use to authenticate the connection to
|
||||
the remote device. This value is the path to the
|
||||
key used to authenticate the SSH session. If the value is not specified
|
||||
in the task, the value of environment variable C(ANSIBLE_NET_SSH_KEYFILE)
|
||||
will be used instead.
|
||||
lines:
|
||||
description:
|
||||
- The ordered set of commands that should be configured in the
|
||||
|
@ -231,7 +191,6 @@ backup_path:
|
|||
"""
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.cnos.cnos import load_config, get_config
|
||||
from ansible.module_utils.network.cnos.cnos import cnos_argument_spec
|
||||
from ansible.module_utils.network.cnos.cnos import check_args
|
||||
from ansible.module_utils.network.common.config import NetworkConfig, dumps
|
||||
|
||||
|
@ -320,8 +279,6 @@ def main():
|
|||
admin=dict(type='bool', default=False)
|
||||
)
|
||||
|
||||
argument_spec.update(cnos_argument_spec)
|
||||
|
||||
mutually_exclusive = [('lines', 'src'),
|
||||
('parents', 'src')]
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (C) 2017 Red Hat Inc.
|
||||
# Copyright (C) 2017 Lenovo.
|
||||
# (C) 2019 Red Hat Inc.
|
||||
# Copyright (C) 2019 Lenovo.
|
||||
#
|
||||
# GNU General Public License v3.0+
|
||||
#
|
||||
|
@ -55,50 +55,6 @@ options:
|
|||
on the remote device. If I(authorize) is false, then this argument
|
||||
does nothing. If the value is not specified in the task, the value of
|
||||
environment variable C(ANSIBLE_NET_AUTH_PASS) will be used instead.
|
||||
provider:
|
||||
version_added: "2.6"
|
||||
description:
|
||||
- A dict object containing connection details.
|
||||
suboptions:
|
||||
host:
|
||||
description:
|
||||
- Specifies the DNS host name or address for connecting to the remote
|
||||
device over the specified transport. The value of host is used as
|
||||
the destination address for the transport.
|
||||
required: true
|
||||
port:
|
||||
description:
|
||||
- Specifies the port to use when building the connection to the
|
||||
remote device.
|
||||
default: 22
|
||||
username:
|
||||
description:
|
||||
- Configures the username to use to authenticate the connection to
|
||||
the remote device. This value is used to authenticate
|
||||
the SSH session. If the value is not specified in the task, the
|
||||
value of environment variable C(ANSIBLE_NET_USERNAME) will be used
|
||||
instead.
|
||||
password:
|
||||
description:
|
||||
- Specifies the password to use to authenticate the connection to
|
||||
the remote device. This value is used to authenticate
|
||||
the SSH session. If the value is not specified in the task, the
|
||||
value of environment variable C(ANSIBLE_NET_PASSWORD) will be used
|
||||
instead.
|
||||
timeout:
|
||||
description:
|
||||
- Specifies the timeout in seconds for communicating with the network
|
||||
device for either connecting or sending commands. If the timeout
|
||||
is exceeded before the operation is completed, the module will
|
||||
error.
|
||||
default: 10
|
||||
ssh_keyfile:
|
||||
description:
|
||||
- Specifies the SSH key to use to authenticate the connection to
|
||||
the remote device. This value is the path to the
|
||||
key used to authenticate the SSH session. If the value is not
|
||||
specified in the task, the value of environment variable
|
||||
C(ANSIBLE_NET_SSH_KEYFILE) will be used instead.
|
||||
gather_subset:
|
||||
version_added: "2.6"
|
||||
description:
|
||||
|
@ -116,36 +72,21 @@ Tasks: The following are examples of using the module cnos_facts.
|
|||
---
|
||||
- name: Test cnos Facts
|
||||
cnos_facts:
|
||||
provider={{ cli }}
|
||||
|
||||
vars:
|
||||
cli:
|
||||
host: "{{ inventory_hostname }}"
|
||||
port: 22
|
||||
username: admin
|
||||
password: admin
|
||||
transport: cli
|
||||
timeout: 30
|
||||
authorize: True
|
||||
auth_pass:
|
||||
|
||||
---
|
||||
# Collect all facts from the device
|
||||
- cnos_facts:
|
||||
gather_subset: all
|
||||
provider: "{{ cli }}"
|
||||
|
||||
# Collect only the config and default facts
|
||||
- cnos_facts:
|
||||
gather_subset:
|
||||
- config
|
||||
provider: "{{ cli }}"
|
||||
|
||||
# Do not collect hardware facts
|
||||
- cnos_facts:
|
||||
gather_subset:
|
||||
- "!hardware"
|
||||
provider: "{{ cli }}"
|
||||
'''
|
||||
RETURN = '''
|
||||
ansible_net_gather_subset:
|
||||
|
@ -207,7 +148,6 @@ RETURN = '''
|
|||
import re
|
||||
|
||||
from ansible.module_utils.network.cnos.cnos import run_commands
|
||||
from ansible.module_utils.network.cnos.cnos import cnos_argument_spec
|
||||
from ansible.module_utils.network.cnos.cnos import check_args
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -452,10 +392,6 @@ class Interfaces(FactsBase):
|
|||
if match:
|
||||
key = match.group(1)
|
||||
parsed.append(line)
|
||||
# match = re.match(r'^(loopback+)', line)
|
||||
# if match:
|
||||
# key = match.group(1)
|
||||
# parsed.append(line)
|
||||
return parsed
|
||||
|
||||
def set_ip_interfaces(self, line4):
|
||||
|
@ -545,8 +481,6 @@ def main():
|
|||
gather_subset=dict(default=['!config'], type='list')
|
||||
)
|
||||
|
||||
argument_spec.update(cnos_argument_spec)
|
||||
|
||||
module = AnsibleModule(argument_spec=argument_spec,
|
||||
supports_check_mode=True)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue