1# Test code for the vmware_local_role_info module
2# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
3# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5- import_role:
6    name: prepare_vmware_tests
7
8- name: Set list of Roles in fact
9  set_fact:
10    role_list:
11      - Admin
12      - NoCryptoAdmin
13      - NoAccess
14      - Anonymous
15      - ReadOnly
16
17- &role_data
18  name: Gather Role info
19  vmware_local_role_info:
20    hostname: "{{ vcenter_hostname }}"
21    username: "{{ vcenter_username }}"
22    password: "{{ vcenter_password }}"
23    validate_certs: no
24  register: role_details
25
26- &role_test
27  name: Test if role id is present for role
28  assert:
29    that: "{{ role_details.local_role_info | json_query(s_query) != [] }}"
30  vars:
31    s_query: "[?role_name == '{{ item }}'].role_id"
32  with_items: "{{ role_list }}"
33
34- <<: *role_data
35  name: Gather Role info in check mode
36  check_mode: yes
37
38- <<: *role_test
39  name: Test if role id is present for role in check mode
40