1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/junos_banner/tests/netconf/basic.yaml
Ganesh Nalawade 8eaa9cc938
Fix junos modules check_mode issue (#37311)
Fixes #37208

If check_mode is enabled instead of committing th config need to
discard all the chnages to cnadidate db
In case of cli to discard changes issue `rollback 0` command
and for netconf execute `discard-changes` rpc call
2018-03-26 07:27:30 -04:00

208 lines
4.4 KiB
YAML

---
- debug: msg="START junos_banner netconf/basic.yaml on connection={{ ansible_connection }}"
- 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
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<message>this is my login banner</message>' in config.xml"
- 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: present
active: False
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<message inactive=\"inactive\">this is my login banner</message>' in config.xml"
- name: Activate login banner
junos_banner:
banner: login
text: this is my login banner
state: present
active: True
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<message>this is my login banner</message>' in config.xml"
- name: check mode
junos_banner:
banner: login
text: this is not the login banner you're looking for
state: present
provider: "{{ netconf }}"
register: result
check_mode: yes
- assert:
that:
- "result.changed == true"
- "result.failed == false"
- name: delete login banner
junos_banner:
banner: login
state: absent
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<message>this is my login banner</message>' not in config.xml"
- 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
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<announcement>this is my motd banner</announcement>' in config.xml"
- 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
text: this is my motd banner
state: present
active: False
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<announcement inactive=\"inactive\">this is my motd banner</announcement>' in config.xml"
- name: Activate motd banner
junos_banner:
banner: motd
text: this is my motd banner
state: present
active: True
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<announcement>this is my motd banner</announcement>' in config.xml"
- name: delete motd banner
junos_banner:
banner: motd
state: absent
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<announcement>this is my motd banner</announcement>' not in config.xml"
- debug: msg="END junos_banner netconf/basic.yaml on connection={{ ansible_connection }}"