mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 12:03:58 -07:00
Add junos_banner declartive module (#25826)
* Add junos_banner declartive module * junos_banner implementation * Integration test for junos_banner * Integration test for net_banner (junos) * Minor fixes * Minor doc change
This commit is contained in:
parent
97e24dc317
commit
450263e934
20 changed files with 508 additions and 16 deletions
3
test/integration/targets/junos_banner/defaults/main.yaml
Normal file
3
test/integration/targets/junos_banner/defaults/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
2
test/integration/targets/junos_banner/tasks/main.yaml
Normal file
2
test/integration/targets/junos_banner/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
14
test/integration/targets/junos_banner/tasks/netconf.yaml
Normal file
14
test/integration/targets/junos_banner/tasks/netconf.yaml
Normal file
|
@ -0,0 +1,14 @@
|
|||
- name: collect netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
141
test/integration/targets/junos_banner/tests/netconf/basic.yaml
Normal file
141
test/integration/targets/junos_banner/tests/netconf/basic.yaml
Normal file
|
@ -0,0 +1,141 @@
|
|||
---
|
||||
- debug: msg="START junos_banner netconf/basic.yaml"
|
||||
|
||||
- name: setup - remove login banner
|
||||
junos_banner:
|
||||
banner: login
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Create login banner
|
||||
junos_banner:
|
||||
banner: login
|
||||
text: this is my login banner
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<message>this is my login banner</message>' in result.rpc"
|
||||
|
||||
- name: Create login banner (idempotent)
|
||||
junos_banner:
|
||||
banner: login
|
||||
text: this is my login banner
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Deactivate login banner
|
||||
junos_banner:
|
||||
banner: login
|
||||
text: this is my login banner
|
||||
state: suspend
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<message inactive=\"inactive\" />' in result.rpc"
|
||||
|
||||
- name: Activate login banner
|
||||
junos_banner:
|
||||
banner: login
|
||||
text: this is my login banner
|
||||
state: active
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<message active=\"active\" />' in result.rpc"
|
||||
|
||||
- name: delete login banner
|
||||
junos_banner:
|
||||
banner: login
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<message delete=\"delete\" />' in result.rpc"
|
||||
|
||||
- name: setup - remove motd banner
|
||||
junos_banner:
|
||||
banner: motd
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Create motd banner
|
||||
junos_banner:
|
||||
banner: motd
|
||||
text: this is my motd banner
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<announcement>this is my motd banner</announcement>' in result.rpc"
|
||||
|
||||
- name: Create motd banner (idempotent)
|
||||
junos_banner:
|
||||
banner: motd
|
||||
text: this is my motd banner
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Deactivate motd banner
|
||||
junos_banner:
|
||||
banner: motd
|
||||
state: suspend
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<announcement inactive=\"inactive\" />' in result.rpc"
|
||||
|
||||
- name: Activate motd banner
|
||||
junos_banner:
|
||||
banner: motd
|
||||
state: active
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<announcement active=\"active\" />' in result.rpc"
|
||||
|
||||
- name: delete motd banner
|
||||
junos_banner:
|
||||
banner: motd
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<announcement delete=\"delete\" />' in result.rpc"
|
Loading…
Add table
Add a link
Reference in a new issue