mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 23:14:02 -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
|
@ -34,7 +34,7 @@ These are the various options the customer have in executing the cnos_command mo
|
|||
|
||||
Variable | Description
|
||||
--- | ---
|
||||
`commands` | 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.
|
||||
`commands` | 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 as expired.
|
||||
`wait_for` | List of conditions to evaluate against the output of the command. The task will wait for each condition to be true before moving forward. If the conditional is not true within the configured number of retries, the task fails. See examples.
|
||||
`match` | The I(match) argument is used in conjunction with the I(wait_for) argument to specify the match policy. Valid values are C(all) or C(any). If the value is set to C(all) then all conditionals in the wait_for must be satisfied. If the value is set to C(any) then only one of the values must be satisfied.
|
||||
`retries` | Specifies the number of retries a command should by tried before it is considered failed. The command is run on the target device every retry and evaluated against the I(wait_for) conditions.
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
- display interface brief
|
||||
wait_for:
|
||||
- result[0] contains 'Description: Foo'
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
wait_for:
|
||||
- "result[0] contains 'Lenovo'"
|
||||
- "result[1] contains 'Mem:'"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
- name: run invalid command
|
||||
cnos_command:
|
||||
commands: ['display foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
|
@ -17,7 +16,6 @@
|
|||
commands:
|
||||
- display version
|
||||
- display foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
- name: get output for single command
|
||||
cnos_command:
|
||||
commands: ['display version']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -17,7 +16,6 @@
|
|||
commands:
|
||||
- display version
|
||||
- display interface brief
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
- display version
|
||||
wait_for:
|
||||
- "result[0] contains bad_value_string"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
---
|
||||
cli:
|
||||
host: "{{ inventory_hostname }}"
|
||||
port: 22
|
||||
username: admin
|
||||
password: admin
|
||||
# transport: cli
|
||||
timeout: 30
|
||||
authorize: True
|
||||
auth_pass:
|
|
@ -47,19 +47,6 @@ Variable | Description
|
|||
`admin` | Enters into administration configuration mode for making config changes to the device.
|
||||
|
||||
|
||||
Need to specify these variables in vars/main.yml under variable `cli`
|
||||
|
||||
Variable | Description
|
||||
--- | ---
|
||||
`host` | Has to be "{{ inventory_hostname }}"
|
||||
`port` | Has to be`22`
|
||||
`username` | User Name of switch
|
||||
`password` | Password of switch
|
||||
`timeout` | time out value for CLI
|
||||
`authorixe` | Whether u have to enter enable mode for data collection.
|
||||
`auth_pass`| Enable Password if required
|
||||
|
||||
|
||||
## Dependencies
|
||||
---
|
||||
<add dependencies information below>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# - You can enter hostnames or ip Addresses
|
||||
# - A hostname/ip can be a member of multiple groups
|
||||
#
|
||||
# In the /etc/ansible/hosts file u have to enter [cnos_command_sample] tag
|
||||
# In the /etc/ansible/hosts file u have to enter [cnos_config_sample] tag
|
||||
# Following you should specify IP Addresses details
|
||||
# Please change <username> and <password> with appropriate value for your switch.
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
cnos_config:
|
||||
commands:
|
||||
- no vlan 13
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: collect any backup files
|
||||
|
@ -25,12 +24,11 @@
|
|||
cnos_config:
|
||||
src: roles/cnos_config/templates/basic/config.j2
|
||||
backup: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.changed == true"
|
||||
|
||||
- name: collect any backup files
|
||||
find:
|
||||
|
@ -47,6 +45,5 @@
|
|||
cnos_config:
|
||||
commands:
|
||||
- no vlan 13
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/backup.yaml"
|
||||
|
|
|
@ -5,35 +5,31 @@
|
|||
cnos_config:
|
||||
commands:
|
||||
- no vlan 13\n
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: configure device with config
|
||||
cnos_config:
|
||||
src: roles/cnos_config/templates/basic/config.j2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.changed == true"
|
||||
- "result.updates is not defined"
|
||||
|
||||
- name: check device with config
|
||||
cnos_config:
|
||||
src: roles/cnos_config/templates/basic/config.j2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.changed == true"
|
||||
- "result.updates is not defined"
|
||||
|
||||
- name: teardown
|
||||
cnos_config:
|
||||
commands:
|
||||
- no vlan 13\n
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/basic.yaml"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
cnos_config:
|
||||
commands:
|
||||
- no vlan 13\n
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
become: True
|
||||
become_method: enable
|
||||
|
@ -13,7 +12,6 @@
|
|||
- name: configure device with defaults included
|
||||
cnos_config:
|
||||
src: roles/cnos_config/templates/defaults/config.j2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
become: True
|
||||
become_method: enable
|
||||
|
@ -28,7 +26,6 @@
|
|||
- name: check device with defaults included Hell
|
||||
cnos_config:
|
||||
src: roles/cnos_config/templates/defaults/config.j2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- debug: var=result
|
||||
|
@ -42,7 +39,6 @@
|
|||
cnos_config:
|
||||
commands:
|
||||
- no vlan 13\n
|
||||
provider: "{{ cli }}"
|
||||
become: true
|
||||
become_method: enable
|
||||
ignore_errors: yes
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
cli:
|
||||
host: "{{ inventory_hostname }}"
|
||||
port: 22
|
||||
username: admin
|
||||
password: admin
|
||||
timeout: 60
|
||||
context: ansible
|
||||
auth_pass:
|
|
@ -15,16 +15,11 @@
|
|||
- "'hardware' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'default' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
|
||||
#- "result.ansible_facts.ansible_net_filesystems is defined"
|
||||
# ... and not present
|
||||
- "'config' not in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
# Items from those subsets are present
|
||||
#- "result.ansible_facts.ansible_net_filesystems is defined" #hw
|
||||
- "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
|
||||
- "result.ansible_facts.ansible_net_interfaces | length > 1" # more than one interface returned
|
||||
|
||||
# ... and not present
|
||||
- "result.ansible_facts.ansible_net_config is not defined" # config
|
||||
|
||||
- debug: msg="END cli/default.yaml"
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
cli:
|
||||
host: "{{ inventory_hostname }}"
|
||||
port: 22
|
||||
username: admin
|
||||
password: admin
|
||||
timeout: 30
|
||||
authorize: True
|
||||
auth_pass:
|
Loading…
Add table
Add a link
Reference in a new issue