forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for junos cli_config replace option (ansible#62131)
* Fix for junos cli_config replace option * For device that support replace option by loading configuration from a file on device `config` option is not required and value of `replace` option is the path of configuration file on device. This fix allows invoking run() function in cli_config if `config` option is None and `replace` option is not boolean * The command to replace running config on junos device is `load override <filename>` and not `load replace <filename>` This is fixed in the junos cliconf plugin. * Add integration test
- Loading branch information
Showing
3 changed files
with
82 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
test/integration/targets/junos_config/tests/cli_config/cli_replace.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
- debug: msg="START cli_config/cli_replace.yaml on connection={{ ansible_connection }}" | ||
|
||
- name: set interface config | ||
cli_config: | ||
config: "{{ item }}" | ||
loop: | ||
- "delete interfaces ge-0/0/11" | ||
- set interfaces ge-0/0/11 description "test cli_config" | ||
|
||
- name: get running configuration | ||
cli_command: | ||
command: show configuration | ||
register: result | ||
|
||
- name: copy configuration to file | ||
copy: | ||
content: "{{ result['stdout'] }}" | ||
dest: /tmp/junos01.cfg | ||
|
||
- name: "modify interface ge-0/0/11 configuration" | ||
replace: | ||
path: /tmp/junos01.cfg | ||
regexp: 'test cli_config' | ||
replace: 'test cli_config replaced' | ||
|
||
- name: copy config file to remote host | ||
net_put: | ||
src: /tmp/junos01.cfg | ||
dest: /var/home/{{ ansible_user }}/junos01.cfg | ||
|
||
- name: replace syslog test file configuration | ||
cli_config: | ||
replace: "/var/home/{{ ansible_user }}/junos01.cfg" | ||
|
||
- name: get interface configuration | ||
cli_command: | ||
command: show configuration interfaces ge-0/0/11 | ||
register: result | ||
|
||
- name: assert that interface config change is reflected on device | ||
assert: | ||
that: | ||
- "'test cli_config replaced' in result.stdout" | ||
|
||
- name: replace interface configuration (idempotent) | ||
cli_config: | ||
replace: "/var/home/{{ ansible_user }}/junos01.cfg" | ||
register: result | ||
|
||
- name: Assert that the previous task was idempotent | ||
assert: | ||
that: | ||
- "result['changed'] == false" | ||
|
||
- name: delete interface config | ||
cli_config: | ||
config: "delete interfaces ge-0/0/11" | ||
|
||
- debug: msg="END cli_config/cli_replace.yaml on connection={{ ansible_connection }}" |