- name: Check if project name exists
uri:
url: "{{ webapp_url }}/api/orgs"
method: GET
return_content: yes
validate_certs: no
user: "{{ user }}"
password: "{{ password }}"
force_basic_auth: yes
register: existing_projects
- name: Check if project name exists in the response
set_fact:
project_already_exists: "{{ project_name in existing_projects.json | json_query('*.name') }}"
- name: REST POST Example if project name doesn't exist
uri:
url: "{{ webapp_url }}/api/orgs"
method: POST
return_content: yes
body: "{ \"name\": \"{{ project_name }}\" }"
body_format: json
validate_certs: no
user: "{{ user }}"
password: "{{ password }}"
force_basic_auth: yes
when: not project_already_exists