diff --git a/group_vars/stage_dev/plain.yml b/group_vars/stage_dev/plain.yml index 5040a07..092fa02 100644 --- a/group_vars/stage_dev/plain.yml +++ b/group_vars/stage_dev/plain.yml @@ -147,6 +147,7 @@ kube_node_01_hostname: "{{ stage }}-kube-node-01.{{ domain }}" kube_node_02_hostname: "{{ stage }}-kube-node-02.{{ domain }}" kube_node_03_hostname: "{{ stage }}-kube-node-03.{{ domain }}" +shared_service_awx_hostname: "{{ stage }}-awx-01.{{ domain }}" shared_service_iam_hostname: "{{ stage }}-iam-01.{{ domain }}" shared_service_mail_hostname: "{{ stage }}-mail-01.{{ domain }}" shared_service_gitea_hostname: "{{ stage }}-gitea-01.{{ domain }}" diff --git a/group_vars/stage_qa/plain.yml b/group_vars/stage_qa/plain.yml index 17f63bb..4fd39e3 100644 --- a/group_vars/stage_qa/plain.yml +++ b/group_vars/stage_qa/plain.yml @@ -147,6 +147,7 @@ kube_node_01_hostname: "{{ stage }}-kube-node-01.{{ domain }}" kube_node_02_hostname: "{{ stage }}-kube-node-02.{{ domain }}" kube_node_03_hostname: "{{ stage }}-kube-node-03.{{ domain }}" +shared_service_awx_hostname: "{{ stage }}-awx-01.{{ domain }}" shared_service_iam_hostname: "{{ stage }}-iam-01.{{ domain }}" shared_service_mail_hostname: "{{ stage }}-mail-01.{{ domain }}" shared_service_gitea_hostname: "{{ stage }}-gitea-01.{{ domain }}" diff --git a/roles/connect/tasks/connections.yml b/roles/connect/tasks/connections.yml new file mode 100644 index 0000000..d93bb37 --- /dev/null +++ b/roles/connect/tasks/connections.yml @@ -0,0 +1,73 @@ +--- + +### tags: +### update_connections +### update_configuration + +- name: "Checking connect is running on <{{ connect_base_url }}>" + delegate_to: 127.0.0.1 + become: false + uri: + url: "{{ http_s }}://{{ connect_base_url }}/api/profile-info" + method: GET + headers: + "Smardigo-User-Token": "{{ smardigo_auth_token_value }}" + status_code: [200] + register: connect_profile_info + delay: 15 + retries: 10 + until: connect_profile_info.status in [200] + tags: + - update_connections + - update_configuration + +- name: "Reading connections from <{{ connect_base_url }}>" + delegate_to: 127.0.0.1 + become: false + uri: + url: "{{ http_s }}://{{ connect_base_url }}/api/datasource-connections" + method: GET + headers: + "Smardigo-User-Token": "{{ smardigo_auth_token_value }}" + status_code: [200,201] + register: connect_connections_result + tags: + - update_connections + - update_configuration + +- name: "Reading connection ids from <{{ connect_base_url }}>" + set_fact: + connect_connection_ids: "{{ connect_connections_result.json | community.general.json_query(querystr) | list | flatten }}" + vars: + querystr: "[[*].id]" + tags: + - update_connections + - update_configuration + +- name: "Printing connection ids for <{{ connect_base_url }}>" + debug: + msg: "{{ connect_connection_ids }}" + when: + - debug + tags: + - update_connections + - update_configuration + +- name: "Creating/Updating connections on <{{ connect_base_url }}>" + delegate_to: 127.0.0.1 + become: false + uri: + url: "{{ http_s }}://{{ connect_base_url }}/api/datasource-connections" + method: "{% if item.id in connect_connection_ids %}PUT{% else %}POST{% endif %}" + body_format: json + body: '{{ item | to_json }}' + headers: + "Smardigo-User-Token": "{{ smardigo_auth_token_value }}" + status_code: [200,201] + loop: "{{ connect_connections | default([]) }}" + loop_control: + label: "{{ item.id }}" # do not print confidential data + changed_when: true + tags: + - update_connections + - update_configuration diff --git a/roles/connect/tasks/main.yml b/roles/connect/tasks/main.yml index 3939b4d..2c3702e 100644 --- a/roles/connect/tasks/main.yml +++ b/roles/connect/tasks/main.yml @@ -3,6 +3,8 @@ ### tags: ### update_certs ### update_deployment +### update_connections +### update_configuration - name: "Setup DNS configuration for <{{ connect_id }}> to <{{ stage_server_ip }}>" include_role: @@ -78,3 +80,8 @@ chdir: '{{ service_base_path }}/{{ connect_id }}' tags: - update_deployment + +- name: "Configure connect connections" + include_tasks: connections.yml + tags: + - always diff --git a/roles/management/defaults/main.yml b/roles/management/defaults/main.yml index ed97d53..5935f68 100644 --- a/roles/management/defaults/main.yml +++ b/roles/management/defaults/main.yml @@ -1 +1,15 @@ --- + +connect_connections: +- id: "teams" + name: "MS Teams" + url: "{{ netgo_msteams_hook_alerting_vault }}" + connectionType: "HTTPS" + authType: "NO_AUTH" +- id: "awx" + name: "AWX" + url: "http://{{ shared_service_awx_hostname }}/" + connectionType: "HTTP" + authType: "BASIC_AUTH" + username: "{{ awx_admin_username }}" + password: "{{ awx_admin_password }}" diff --git a/roles/management/tasks/main.yaml b/roles/management/tasks/main.yaml index dc0e0fe..d396ae0 100644 --- a/roles/management/tasks/main.yaml +++ b/roles/management/tasks/main.yaml @@ -1,6 +1,7 @@ --- ### tags: +### update_configuration - name: "Creating smardigo user token" smardigo_user_token: @@ -10,24 +11,30 @@ delegate_to: 127.0.0.1 become: false tags: - - update_deployment + - always - name: "Setting smardigo_auth_token_value as fact" set_fact: smardigo_auth_token_value: "{{ smardigo_user_token_result.token }}" tags: - - update_deployment + - always - name: "Create database for <{{ inventory_hostname }}> if necessary" include_role: name: connect-postgres vars: ansible_ssh_host: "{{ stage }}-postgres-01.{{ domain }}" + tags: + - always - name: "Create realm for <{{ inventory_hostname }}> if necessary" include_role: name: connect-realm + tags: + - always - name: "Create connect for <{{ inventory_hostname }}> if necessary" include_role: name: connect + tags: + - always