Debian Codegraph @

ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml

raw
1 # Test code for the MSO modules
2 # Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) <[email protected]>
3 #
4
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 - name: Test that we have an ACI MultiSite host, username and password
8 ansible.builtin.fail:
9 msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.'
10 when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined
11
12
13 # CLEAN ENVIRONMENT
14 - name: Set vars
15 ansible.builtin.set_fact:
16 mso_info: &mso_info
17 host: '{{ mso_hostname }}'
18 username: '{{ mso_username }}'
19 password: '{{ mso_password }}'
20 validate_certs: '{{ mso_validate_certs | default(false) }}'
21 use_ssl: '{{ mso_use_ssl | default(true) }}'
22 use_proxy: '{{ mso_use_proxy | default(true) }}'
23 output_level: '{{ mso_output_level | default("debug") }}'
24
25 - name: Remove schemas
26 cisco.mso.mso_schema:
27 <<: *mso_info
28 schema: '{{ item }}'
29 state: absent
30 loop:
31 - '{{ mso_schema | default("ansible_test") }}_1'
32 - '{{ mso_schema | default("ansible_test") }}'
33
34 - name: Remove tenant ansible_test
35 cisco.mso.mso_tenant:
36 <<: *mso_info
37 tenant: ansible_test
38 state: absent
39
40 # QUERY A USER
41 - name: Query our user
42 cisco.mso.mso_user:
43 <<: *mso_info
44 state: query
45 user: '{{ mso_username }}'
46 check_mode: true
47 register: query_user_id
48
49 - name: Verify query_user_id
50 ansible.builtin.assert:
51 that:
52 - query_user_id is not changed
53 - query_user_id.current.username == '{{ mso_username }}'
54
55 - name: Add a tenant from a templated payload file from templates
56 cisco.mso.mso_rest:
57 <<: *mso_info
58 path: /api/v1/tenants
59 method: post
60 content: "{{ lookup('template', 'tenant.json.j2') }}"
61 register: add_tenant
62
63 - name: Verify add_tenant in json_string
64 ansible.builtin.assert:
65 that:
66 - add_tenant is changed
67 - add_tenant.jsondata.displayName == 'ansible_test'