mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Add support for commit label in iosxr_config (#42931)
* Add support for commit label in iosxr_config * sanity pep8 etc fixes
This commit is contained in:
parent
4f1746ee1d
commit
bf544c2200
4 changed files with 130 additions and 8 deletions
|
@ -0,0 +1,70 @@
|
|||
---
|
||||
- debug: msg="START cli/commit_label.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
iosxr_config:
|
||||
commands:
|
||||
- no description
|
||||
- no shutdown
|
||||
parents:
|
||||
- interface Loopback999
|
||||
match: none
|
||||
|
||||
- name: get a unique and valid label
|
||||
set_fact:
|
||||
label: "ansible_{{ 1001 | random | to_uuid | truncate(20, true, '_') }}"
|
||||
|
||||
- name: configure device with a label and a comment
|
||||
iosxr_config:
|
||||
src: basic/config.j2
|
||||
comment: "this is sensible commit message"
|
||||
label: "{{ label }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: setup
|
||||
iosxr_config:
|
||||
commands:
|
||||
- no description
|
||||
- no shutdown
|
||||
parents:
|
||||
- interface Loopback999
|
||||
match: none
|
||||
|
||||
- name: Try to commit with old label, fail with a msg that label is alreay used
|
||||
iosxr_config:
|
||||
src: basic/config.j2
|
||||
label: "{{ label }}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "'already used' in result.msg"
|
||||
|
||||
- name: setup
|
||||
iosxr_config:
|
||||
commands:
|
||||
- no description
|
||||
- no shutdown
|
||||
parents:
|
||||
- interface Loopback999
|
||||
match: none
|
||||
|
||||
- name: Try to commit with invalid chars($) in label
|
||||
iosxr_config:
|
||||
src: basic/config.j2
|
||||
label: 'ansible_iosxr_config_$'
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "'only contain alphabets' in result.msg"
|
||||
|
||||
- debug: msg="END cli/commit_label.yaml on connection={{ ansible_connection }}"
|
Loading…
Add table
Add a link
Reference in a new issue