mirror of https://github.com/ansible/ansible.git
Fix for junos cli_config replace option (#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
(cherry picked from commit 200ed25648
)
pull/62378/head
parent
9812e52682
commit
f7fed1dacc
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- Fix for junos cli_config replace option (https://github.com/ansible/ansible/pull/62131).
|
@ -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 }}"
|
Loading…
Reference in New Issue