4a0c875447
* Working Cisco IOS macro editing (fixes #55211) * Working Cisco IOS macro editing [fixed pylints] (fixes #55211) * Added integration tests for edit_macro * Added conditional integration tests for ios_config macro * Cosmetic fix: when near block for added conditional integration tests for ios_config macro * Move teardown to always for block
66 lines
1.6 KiB
YAML
66 lines
1.6 KiB
YAML
---
|
|
|
|
- debug: msg="START cli/cli_macro.yaml on connection={{ ansible_connection }}"
|
|
|
|
- name: "Check for macro support"
|
|
ios_command:
|
|
commands:
|
|
- "show parser macro brief"
|
|
register: supports_macro
|
|
ignore_errors: yes
|
|
|
|
- name: "ios_config macro integration tests"
|
|
when: supports_macro is succeeded
|
|
block:
|
|
|
|
- name: "Define macro name"
|
|
set_fact:
|
|
macro_name: 'MACRO_ANSIBLE_TEST'
|
|
|
|
- name: "setup - remove configuration"
|
|
ios_config:
|
|
lines:
|
|
- 'no macro name {{ macro_name }}'
|
|
- 'do show clock'
|
|
match: none
|
|
|
|
- name: "configure macro"
|
|
ios_config:
|
|
parents: "macro name {{ macro_name }}"
|
|
# before: [ 'no macro name ...']
|
|
multiline_delimiter: '@'
|
|
after: '@'
|
|
match: line
|
|
replace: block
|
|
lines: "{{ lookup('template', 'basic/macro.j2') }}"
|
|
register: result
|
|
|
|
- name: "Check if macro has been added"
|
|
assert:
|
|
that:
|
|
- "result.changed == true"
|
|
|
|
- name: "configure macro again - idempotent check"
|
|
ios_config:
|
|
parents: "macro name {{ macro_name }}"
|
|
multiline_delimiter: '@'
|
|
after: '@'
|
|
match: line
|
|
replace: block
|
|
lines: "{{ lookup('template', 'basic/macro.j2') }}"
|
|
register: result
|
|
|
|
- name: "macro already/correctly configured ?"
|
|
assert:
|
|
that:
|
|
- "result.changed == false"
|
|
|
|
always:
|
|
- name: "teardown"
|
|
ios_config:
|
|
lines:
|
|
- "no macro name {{ macro_name }}"
|
|
- 'do show clock'
|
|
match: none
|
|
|
|
- debug: msg="END cli/cli_macro.yaml on connection={{ ansible_connection }}"
|