Idempotency for net_get and net_put modules (#42307)

* Idempotency for net_get and net_put modules

* pep8 warnings fix

* remove import q
This commit is contained in:
Deepak Agrawal 2018-07-05 20:15:25 +05:30 committed by GitHub
commit 30688fecf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 155 additions and 19 deletions

View file

@ -17,18 +17,11 @@
src: ios1.cfg
register: result
- assert:
that:
- result.changed == true
- name: get the file from device with dest unspecified
net_get:
src: ios1.cfg
register: result
- assert:
that:
- result.changed == true
- name: setup (remove file from localhost if present)
file:
path: ios_{{ ansible_host }}.cfg
state: absent
delegate_to: localhost
- name: get the file from device with relative destination
net_get:
@ -40,4 +33,14 @@
that:
- result.changed == true
- name: Idempotency check
net_get:
src: ios1.cfg
dest: 'ios_{{ ansible_host }}.cfg'
register: result
- assert:
that:
- result.changed == false
- debug: msg="END ios cli/net_get.yaml on connection={{ ansible_connection }}"

View file

@ -12,6 +12,24 @@
- username {{ ansible_ssh_user }} privilege 15
match: none
- name: Delete existing file ios1.cfg if presen on remote host
ios_command:
commands:
- command: 'delete /force ios1.cfg'
ignore_errors: true
- name: Delete existing file ios.cfg if presen on remote host
ios_command:
commands:
- command: 'delete /force ios.cfg'
ignore_errors: true
- name: Delete existing file nonascii.bin if presen on remote host
ios_command:
commands:
- command: 'delete /force nonascii.bin'
ignore_errors: true
- name: copy file from controller to ios + scp (Default)
net_put:
src: ios1.cfg
@ -21,6 +39,15 @@
that:
- result.changed == true
- name: Idempotency Check
net_put:
src: ios1.cfg
register: result
- assert:
that:
- result.changed == false
- name: copy file from controller to ios + dest specified
net_put:
src: ios1.cfg
@ -34,7 +61,7 @@
- name: copy file with non-ascii characters to ios in template mode(Fail case)
net_put:
src: nonascii.bin
mode: 'template'
mode: 'text'
register: result
ignore_errors: true