mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
ios_ntp module (#50705)
* ios_ntp module * add execute_module for config func * fix units test * test empty list * update example * change want logic to follow have - removed try/except * update commands list for config test * add idempotent test case * add more test
This commit is contained in:
committed by
Nathaniel Case
parent
004d8b03d4
commit
f94378fc2f
2
test/integration/targets/ios_ntp/defaults/main.yaml
Normal file
2
test/integration/targets/ios_ntp/defaults/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
2
test/integration/targets/ios_ntp/meta/main.yml
Normal file
2
test/integration/targets/ios_ntp/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_ios_tests
|
||||
22
test/integration/targets/ios_ntp/tasks/cli.yaml
Normal file
22
test/integration/targets/ios_ntp/tasks/cli.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test cases (connection=network_cli)
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: run test case (connection=local)
|
||||
include: "{{ test_case_to_run }} ansible_connection=local"
|
||||
with_first_found: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
2
test/integration/targets/ios_ntp/tasks/main.yaml
Normal file
2
test/integration/targets/ios_ntp/tasks/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
- name: remove NTP (if set)
|
||||
ios_ntp:
|
||||
server: 10.75.32.5
|
||||
source_int: Loopback0
|
||||
acl: NTP_ACL
|
||||
logging: true
|
||||
key_id: 10
|
||||
auth_key: 15435A030726242723273C21181319000A
|
||||
auth: true
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
|
||||
- block:
|
||||
|
||||
- name: configure NTP
|
||||
ios_ntp: &config
|
||||
server: 10.75.32.5
|
||||
source_int: Loopback0
|
||||
state: present
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: idempotence check
|
||||
ios_ntp: *config
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: configure NTP
|
||||
ios_ntp: &config1
|
||||
acl: NTP_ACL
|
||||
logging: true
|
||||
state: present
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: idempotence check
|
||||
ios_ntp: *config1
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: configure NTP with diffferen values
|
||||
ios_ntp: &config2
|
||||
key_id: 10
|
||||
auth_key: 15435A030726242723273C21181319000A
|
||||
auth: true
|
||||
state: present
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: idempotence check
|
||||
ios_ntp: *config2
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: remove part of config
|
||||
ios_ntp: &config3
|
||||
acl: NTP_ACL
|
||||
logging: true
|
||||
state: absent
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: idempotence check
|
||||
ios_ntp: *config3
|
||||
|
||||
- assert: *false
|
||||
|
||||
always:
|
||||
- name: Remove ntp config
|
||||
ios_ntp: *remove
|
||||
Reference in New Issue
Block a user