Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update Tests #1056

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/tests_update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial_changes:
- Update tests for restore plugin impact.
100 changes: 100 additions & 0 deletions tests/integration/targets/ios_cliconf/tests/common/cli_restore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
- ansible.builtin.debug: msg="END cliconf/restore.yaml on connection={{ ansible_connection }}"

- block:
- name: Prepare appliance for restore
ansible.builtin.debug:
msg:
- "Task to prepare appliance for restore operation"

- name: Make file promt quite
cisco.ios.ios_config:
lines:
- "file prompt quiet"

- name: Overwrite startup config - archive
cisco.ios.ios_config:
lines:
- "archive"

- name: Delete ios hostname config
register: result
cisco.ios.ios_hostname:
config:
state: deleted

- name: Delete ios hostname config
register: result
cisco.ios.ios_hostname:
config:
state: gathered

- name: Add ios hostname config
register: result
cisco.ios.ios_hostname:
config:
hostname: "IOSTest"
state: merged

- name: Get running configuration
register: result
ansible.netcommon.cli_command:
command: show running-config configuration

- name: Copy configuration to file
ansible.builtin.copy:
content: "{{ result['stdout'] }}"
dest: /tmp/ios01.cfg

- name: Modify hostname config
ansible.buitin.replace:
path: /tmp/ios01.cfg
regexp: IOSTest
replace: IOSTest restored

- name: Copy config file to remote host
ansible.netcommon.net_put:
src: /tmp/ios01.cfg
protocol: scp
dest: "flash:ios01.cfg"

- name: Replace syslog test file configuration
ansible.netcommon.cli_restore:
filename: "flash:ios01.cfg"
path: "flash:"

- name: Get hostname configuration
register: result
cisco.ios.ios_hostname:
state: gathered

- name: Assert that interface config change is reflected on device
ansible.builtin.assert:
that:
- "'test cli_config restored' in result.gathered.hostname"

- name: Replace syslog test file configuration
ansible.netcommon.cli_restore:
filename: "flash:ios01.cfg"

- name: Assert that the previous task was idempotent
ansible.builtin.assert:
that:
- result['changed'] == false

always:
- name: Delete hostname config
cisco.ios.ios_hostname:
state: deleted

- name: Make file promt quite
cisco.ios.ios_config:
lines:
- "file prompt quiet"

- name: Delete the backup file post backup
cisco.ios.ios_command:
commands:
- command: "delete /force flash:ios01.cfg"

- ansible.builtin.debug: msg="END cliconf/restore.yaml on connection={{ ansible_connection }}"
Loading