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.
junos_user declarative module changes (ansible#26475)
* junos_user declarative module changes * Active/Deactivate support * junos_user integration test * net_user intergration test for junos * Add version_added for active param
- Loading branch information
Showing
10 changed files
with
352 additions
and
2 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
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,3 @@ | ||
--- | ||
testcase: "*" | ||
test_cases: [] |
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,2 @@ | ||
--- | ||
- { include: netconf.yaml, tags: ['netconf'] } |
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,15 @@ | ||
--- | ||
- name: collect netconf test cases | ||
find: | ||
paths: "{{ role_path }}/tests/netconf" | ||
patterns: "{{ testcase }}.yaml" | ||
register: test_cases | ||
|
||
- name: set test_items | ||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" | ||
|
||
- name: run test case | ||
include: "{{ test_case_to_run }}" | ||
with_items: "{{ test_items }}" | ||
loop_control: | ||
loop_var: test_case_to_run |
170 changes: 170 additions & 0 deletions
170
test/integration/targets/junos_user/tests/netconf/basic.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,170 @@ | ||
--- | ||
- debug: msg="START junos_user netconf/basic.yaml" | ||
|
||
- name: setup - remove user | ||
junos_user: | ||
name: test_user | ||
state: absent | ||
provider: "{{ netconf }}" | ||
|
||
- name: Create user | ||
junos_user: | ||
name: test_user | ||
state: present | ||
full_name: test_user | ||
role: operator | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user</name>' in config.xml" | ||
- "'<full-name>test_user</full-name>' in config.xml" | ||
- "'<class>read-only</class>' in config.xml" | ||
|
||
- name: Create user again (idempotent) | ||
junos_user: | ||
name: test_user | ||
state: present | ||
full_name: test_user | ||
role: operator | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- "result.changed == false" | ||
|
||
- name: Deactivate user | ||
junos_user: | ||
name: test_user | ||
state: present | ||
full_name: test_user | ||
role: operator | ||
active: False | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<user inactive=\"inactive\">' in config.xml" | ||
- "'<name>test_user</name>' in config.xml" | ||
|
||
- name: Activate user | ||
junos_user: | ||
name: test_user | ||
state: present | ||
full_name: test_user | ||
role: operator | ||
active: True | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user</name>' in config.xml" | ||
- "'<full-name>test_user</full-name>' in config.xml" | ||
- "'<class>read-only</class>' in config.xml" | ||
|
||
- name: Delete user | ||
junos_user: | ||
name: test_user | ||
state: absent | ||
full_name: test_user | ||
role: operator | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user</name>' not in config.xml" | ||
- "'<full-name>test_user</full-name>' not in config.xml" | ||
|
||
- name: Delete user again (idempotent check) | ||
junos_user: | ||
name: test_user | ||
state: absent | ||
full_name: test_user | ||
role: operator | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- "result.changed == false" | ||
|
||
- name: Teardown list of users | ||
junos_user: | ||
collection: | ||
- {name: test_user1, state: absent} | ||
- {name: test_user2, state: absent} | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Create list of users | ||
junos_user: | ||
collection: | ||
- {name: test_user1, full_name: test_user2, role: operator, state: present} | ||
- {name: test_user2, full_name: test_user2, role: read-only, state: present} | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user1</name>' in config.xml" | ||
- "'<name>test_user2</name>' in config.xml" | ||
|
||
- name: Delete list of users | ||
junos_user: | ||
collection: | ||
- {name: test_user1, full_name: test_user2, role: operator, state: absent} | ||
- {name: test_user2, full_name: test_user2, role: read-only, state: absent} | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user1</name>' not in config.xml" | ||
- "'<name>test_user2</name>' not in config.xml" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
--- | ||
- { include: cli.yaml, tags: ['cli'] } | ||
- { include: netconf.yaml, tags: ['netconf'] } |
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,16 @@ | ||
--- | ||
- name: collect all netconf test cases | ||
find: | ||
paths: "{{ role_path }}/tests/netconf" | ||
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 case | ||
include: "{{ test_case_to_run }}" | ||
with_items: "{{ test_items }}" | ||
loop_control: | ||
loop_var: test_case_to_run |
120 changes: 120 additions & 0 deletions
120
test/integration/targets/net_user/tests/junos/basic.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,120 @@ | ||
--- | ||
- debug: msg="START net_user junos/basic.yaml" | ||
|
||
- name: setup - remove user | ||
net_user: | ||
name: test_user | ||
state: absent | ||
provider: "{{ netconf }}" | ||
|
||
- name: Create user | ||
net_user: | ||
name: test_user | ||
state: present | ||
role: operator | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user</name>' in config.xml" | ||
- "'<class>read-only</class>' in config.xml" | ||
|
||
- name: Create user again (idempotent) | ||
net_user: | ||
name: test_user | ||
state: present | ||
role: operator | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- "result.changed == false" | ||
|
||
- name: Delete user | ||
net_user: | ||
name: test_user | ||
state: absent | ||
role: operator | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user</name>' not in config.xml" | ||
- "'<full-name>test_user</full-name>' not in config.xml" | ||
|
||
- name: Delete user again (idempotent check) | ||
net_user: | ||
name: test_user | ||
state: absent | ||
role: operator | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- "result.changed == false" | ||
|
||
- name: Teardown list of users | ||
net_user: | ||
collection: | ||
- {name: test_user1, state: absent} | ||
- {name: test_user2, state: absent} | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Create list of users | ||
net_user: | ||
collection: | ||
- {name: test_user1, role: operator, state: present} | ||
- {name: test_user2, role: read-only, state: present} | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user1</name>' in config.xml" | ||
- "'<name>test_user2</name>' in config.xml" | ||
|
||
- name: Delete list of users | ||
net_user: | ||
collection: | ||
- {name: test_user1, role: operator, state: absent} | ||
- {name: test_user2, role: read-only, state: absent} | ||
provider: "{{ netconf }}" | ||
register: result | ||
|
||
- name: Get running configuration | ||
junos_rpc: | ||
rpc: get-configuration | ||
provider: "{{ netconf }}" | ||
register: config | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "'<name>test_user1</name>' not in config.xml" | ||
- "'<name>test_user2</name>' not in config.xml" |
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,3 @@ | ||
--- | ||
- include: "{{ role_path }}/tests/junos/basic.yaml" | ||
when: hostvars[inventory_hostname]['ansible_network_os'] == 'junos' |