mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Lenovo cnos banner new module (#50145)
* Adding cnos_banner module to the list.
This commit is contained in:
committed by
Nathaniel Case
parent
95f97bb8d6
commit
f5ebd9736c
2
test/integration/targets/cnos_banner/aliases
Normal file
2
test/integration/targets/cnos_banner/aliases
Normal file
@@ -0,0 +1,2 @@
|
||||
# No Lenovo Switch simulator yet, so not enabled
|
||||
unsupported
|
||||
@@ -0,0 +1,14 @@
|
||||
# You have to paste this dummy information in /etc/ansible/hosts
|
||||
# Notes:
|
||||
# - Comments begin with the '#' character
|
||||
# - Blank lines are ignored
|
||||
# - Groups of hosts are delimited by [header] elements
|
||||
# - 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_banner_sample] tag
|
||||
# Following you should specify IP Adresses details
|
||||
# Please change <username> and <password> with appropriate value for your switch.
|
||||
|
||||
[cnos_banner_sample]
|
||||
10.241.107.39 ansible_network_os=cnos ansible_ssh_user=<username> ansible_ssh_pass=<password>
|
||||
2
test/integration/targets/cnos_banner/defaults/main.yaml
Normal file
2
test/integration/targets/cnos_banner/defaults/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
22
test/integration/targets/cnos_banner/tasks/cli.yaml
Normal file
22
test/integration/targets/cnos_banner/tasks/cli.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test cases (connection=network_cli)
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: run test case (connection=local)
|
||||
include: "{{ test_case_to_run }} ansible_connection=local"
|
||||
with_first_found: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
2
test/integration/targets/cnos_banner/tasks/main.yaml
Normal file
2
test/integration/targets/cnos_banner/tasks/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
|
||||
- name: setup - remove login
|
||||
cnos_banner:
|
||||
banner: login
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Set login
|
||||
cnos_banner:
|
||||
banner: login
|
||||
text: |
|
||||
this is my login banner
|
||||
that has a multiline
|
||||
string
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Set login again (idempotent)
|
||||
cnos_banner:
|
||||
banner: login
|
||||
text: |
|
||||
this is my login banner
|
||||
that has a multiline
|
||||
string
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
@@ -0,0 +1,45 @@
|
||||
---
|
||||
|
||||
- name: setup - remove motd
|
||||
cnos_banner:
|
||||
banner: motd
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
|
||||
|
||||
- name: Set motd
|
||||
cnos_banner:
|
||||
banner: motd
|
||||
text: |
|
||||
this is my motd banner
|
||||
that has a multiline
|
||||
string
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
# - "'banner motd @\nthis is my motd banner\nthat has a multiline\nstring\n@' in result.commands"
|
||||
|
||||
- name: Set motd again (idempotent)
|
||||
cnos_banner:
|
||||
banner: motd
|
||||
text: |
|
||||
this is my motd banner
|
||||
that has a multiline
|
||||
string
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
- name: Setup
|
||||
cnos_banner:
|
||||
banner: login
|
||||
text: |
|
||||
Junk login banner
|
||||
over multiple lines
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: remove login
|
||||
cnos_banner:
|
||||
banner: login
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'no banner login' in result.commands" # does this break due to "contains?"
|
||||
|
||||
- name: remove login (idempotent)
|
||||
cnos_banner:
|
||||
banner: login
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
9
test/integration/targets/cnos_banner/vars/main.yaml
Normal file
9
test/integration/targets/cnos_banner/vars/main.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
cli:
|
||||
host: "{{ inventory_hostname }}"
|
||||
port: 22
|
||||
username: admin
|
||||
password: admin
|
||||
timeout: 30
|
||||
authorize: True
|
||||
auth_pass:
|
||||
Reference in New Issue
Block a user