TEST
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
- name: Read client protocol mappers
|
||||
ansible.builtin.uri:
|
||||
url: "{{ kc_api }}/clients/{{ kc_client_current.id }}/protocol-mappers/models"
|
||||
headers: "{{ kc_headers }}"
|
||||
register: kc_mappers
|
||||
- name: Select mapper by name
|
||||
ansible.builtin.set_fact:
|
||||
kc_mapper_matches: "{{ kc_mappers.json | selectattr('name', 'equalto', kc_mapper_desired.name) | list }}"
|
||||
- name: Check mapper uniqueness
|
||||
ansible.builtin.assert:
|
||||
that: kc_mapper_matches | length <= 1
|
||||
- name: Create mapper
|
||||
ansible.builtin.uri:
|
||||
url: "{{ kc_api }}/clients/{{ kc_client_current.id }}/protocol-mappers/models"
|
||||
headers: "{{ kc_headers }}"
|
||||
method: POST
|
||||
body_format: json
|
||||
body: "{{ kc_mapper_desired }}"
|
||||
status_code: 201
|
||||
when: kc_mapper_matches | length == 0
|
||||
changed_when: true
|
||||
- name: Update existing mapper on drift
|
||||
ansible.builtin.uri:
|
||||
url: "{{ kc_api }}/clients/{{ kc_client_current.id }}/protocol-mappers/models/{{ kc_mapper_matches[0].id }}"
|
||||
headers: "{{ kc_headers }}"
|
||||
method: PUT
|
||||
body_format: json
|
||||
body: "{{ kc_mapper_matches[0] | combine(kc_mapper_desired, recursive=true) }}"
|
||||
status_code: 204
|
||||
when:
|
||||
- kc_mapper_matches | length == 1
|
||||
- (kc_mapper_matches[0] | combine(kc_mapper_desired, recursive=true)) != kc_mapper_matches[0]
|
||||
changed_when: true
|
||||
Reference in New Issue
Block a user