chore: rework cluster_services parameter

- the parameter as list didn't work well
master
Sven Ketelsen 4 years ago
parent 8ee702fb68
commit 7a9c8e42ae

@ -17,7 +17,7 @@
# tenant_id := (unique key for the tenant, e.g. customer)
# cluster_name := (business name for the cluster, e.g. product, department )
# cluster_size := (WIP node count for the cluster) (Currently max is 2 master/slave)
# cluster_services := (services to setup, e.g. ['connect', 'wordpress', ...])
# cluster_services_str := (services to setup, e.g. 'connect,wordpress')
# smardigo message callback
# scope_id := (scope id of the management process)
# process_instance_id := (process instance id of the management process)
@ -38,6 +38,8 @@
- ansible_version.major >= 2
- ansible_version.minor >= 10
msg: "The ansible version has to be at least ({{ ansible_version.full }})"
- set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
tasks:
- name: Add postgres servers to hosts if necessary
@ -46,7 +48,6 @@
groups:
- "stage_{{ stage }}"
- "{{ item }}"
cluster_service: "{{ item }}"
changed_when: False
with_items: "{{ cluster_services }}"
when: item in ['connect', 'management_connect', 'keycloak', 'webdav']
@ -57,7 +58,6 @@
groups:
- "stage_{{ stage }}"
- "{{ item }}"
cluster_service: "{{ item }}"
changed_when: False
with_items: "{{ cluster_services }}"
when: item in ['connect_wordpress']
@ -73,6 +73,9 @@
pre_tasks:
- name: "Import autodiscover pre-tasks"
include_tasks: tasks/autodiscover_pre_tasks.yml
- name: "Parsing cluster_services_str into cluster_services"
set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
roles:
- role: connect-postgres

@ -1,12 +1,15 @@
---
# creates realm/clients on shared keycloak service
# - connect-realm: configuration to use with connect/wordpress
# Parameters:
# playbook inventory
# stage := the type of the stage (e.g. dev, int, qa, prod)
# tenant_id := (unique key for the tenant, e.g. customer)
# cluster_name := (business name for the cluster, e.g. product, department )
# cluster_size := (WIP node count for the cluster)
# cluster_services := (services to setup, e.g. ['connect', 'wordpress', ...])
# cluster_services_str := (services to setup, e.g. 'connect,wordpress')
# playbook roles (keycloak / oidc)
# current_realm_name :=
# current_realm_display_name :=
@ -30,14 +33,14 @@
- ansible_version.major >= 2
- ansible_version.minor >= 10
msg: "The ansible version has to be at least ({{ ansible_version.full }})"
- set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
tasks:
- name: Add hosts
add_host:
name: "{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-{{ '%02d' | format(item|int) }}"
groups:
- "stage_{{ stage }}"
- "{{ cluster_service }}"
groups: "{{ ['stage_' + stage ] + cluster_services }}"
with_sequence: start=1 end={{ cluster_size | default(1) }}
changed_when: False
@ -57,9 +60,13 @@
pre_tasks:
- name: "Import autodiscover pre-tasks"
include_tasks: tasks/autodiscover_pre_tasks.yml
- name: "Parsing cluster_services_str into cluster_services"
set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
roles:
- role: connect-realm
when: '"connect" in cluster_services'
#############################################################
# Sending smardigo management message to process

@ -106,7 +106,6 @@
]
state: 'absent'
when: ansible_distribution == "Ubuntu"
- name: "Import autodiscover pre-tasks"
include_tasks: tasks/autodiscover_pre_tasks.yml

@ -6,7 +6,7 @@
# tenant_id := (unique key for the tenant, e.g. customer)
# cluster_name := (business name for the cluster, e.g. product, department )
# cluster_size := (WIP node count for the cluster)
# cluster_services := (services to setup, e.g. ['connect', 'wordpress', ...])
# cluster_services_str := (services to setup, e.g. 'connect,wordpress')
# smardigo message callback
# scope_id := (scope id of the management process)
# process_instance_id := (process instance id of the management process)
@ -27,6 +27,9 @@
- ansible_version.major >= 2
- ansible_version.minor >= 10
msg: "The ansible version has to be at least ({{ ansible_version.full }})"
- name: "Parsing cluster_services_str into cluster_services"
set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
tasks:
- name: Add hosts
@ -64,8 +67,11 @@
remote_user: root
pre_tasks:
- name: "Import autodiscover tasks"
include_tasks: "tasks/autodiscover_pre_tasks.yml"
- name: "Import autodiscover pre-tasks"
include_tasks: tasks/autodiscover_pre_tasks.yml
- name: "Parsing cluster_services_str into cluster_services"
set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
roles:
- role: connect

@ -6,8 +6,8 @@
# tenant_id := (unique key for the tenant, e.g. customer)
# cluster_name := (business name for the cluster, e.g. product, department )
# cluster_size := (WIP node count for the cluster) (Currently max is 2 master/slave)
# cluster_services := (services to setup, e.g. ['connect', 'wordpress', ...])
# uploaded_file := the dump file to import, has to be on the database server under /tmp (e.g. wordpress_portal.sql)
# cluster_services_str := (services to setup, e.g. 'connect,wordpress')
# database_backup_file := the dump file to import, has to be on the database server under /tmp (e.g. wordpress_portal.sql)
# target_database := (optional) the database to import into ( see {{ connect_wordpress_maria_database }})
# smardigo message callback
# scope_id := (scope id of the management process)
@ -29,6 +29,9 @@
- ansible_version.major >= 2
- ansible_version.minor >= 10
msg: "The ansible version has to be at least ({{ ansible_version.full }})"
- name: "Parsing cluster_services_str into cluster_services"
set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
tasks:
- name: Add hosts
@ -53,19 +56,22 @@
pre_tasks:
- name: "Import autodiscover pre-tasks"
include_tasks: tasks/autodiscover_pre_tasks.yml
- name: "Parsing cluster_services_str into cluster_services"
set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
roles:
- role: import-maria-database
when:
- "'connect_wordpress' in group_names"
- "target_database is defined"
- "uploaded_file is defined"
- "database_backup_file is defined"
- role: import-maria-database
vars:
target_database: "{{ connect_wordpress_maria_database }}"
when:
- "'connect_wordpress' in group_names"
- "uploaded_file is defined"
- "database_backup_file is defined"
#############################################################
# Sending smardigo management message to process

@ -16,8 +16,6 @@
- name: "Import autodiscover pre-tasks"
include_tasks: tasks/autodiscover_pre_tasks.yml
tags:
- always
- name: "Variable <ansible_distribution>"
debug:

@ -0,0 +1,41 @@
---
- name: "Fetch all {{ awx_rest_api_type }} ids"
no_log: true
uri:
url: "{{ awx_base_url }}/api/v2/{{ awx_rest_api_type }}/"
method: GET
user: "{{ awx_rest_api_access_user }}"
password: "{{ awx_rest_api_access_pw }}"
headers:
Content-Type: "application/json"
Accept: "application/json"
body_format: "json"
force_basic_auth: true
validate_certs: false
status_code: 200
register: response
tags:
- awx_config
- name: "Remove all {{ awx_rest_api_type }}"
no_log: true
uri:
url: "{{ awx_base_url }}{{ item.url }}"
method: DELETE
user: "{{ awx_rest_api_access_user }}"
password: "{{ awx_rest_api_access_pw }}"
headers:
Content-Type: "application/json"
Accept: "application/json"
body_format: "json"
force_basic_auth: true
validate_certs: false
status_code: 204
tags:
- awx_config
loop: "{{ response.json.results }}"
loop_control:
label: "{{ item.url }}"
# Ignore errors due to some elements can't be deleted
ignore_errors: true

@ -1,5 +1,13 @@
---
- name: "Remove all <job_templates>"
include_tasks: awx-config-cleanup.yml
vars:
awx_rest_api_type: job_templates
when: (awx_hetzner_ansible_project_id is not defined)
tags:
- awx_config
- name: "Printing..."
debug:
msg: "{{ ansible_ssh_key_private }}"
@ -80,6 +88,13 @@
tags:
- awx_config
- name: "Remove all <credentials>"
include_tasks: awx-config-cleanup.yml
vars:
awx_rest_api_type: credentials
tags:
- awx_config
- name: "Search credential type id for <Machine>"
include_tasks: awx-config-get-typ-id.yml
vars:
@ -319,6 +334,13 @@
tags:
- awx_config
- name: "Remove all <execution_environments>"
include_tasks: awx-config-cleanup.yml
vars:
awx_rest_api_type: execution_environments
tags:
- awx_config
- name: "Search execution environment for <hetzner-ansible>"
include_tasks: awx-config-get-typ-id.yml
vars:
@ -380,6 +402,13 @@
tags:
- awx_config
- name: "Remove all <inventories>"
include_tasks: awx-config-cleanup.yml
vars:
awx_rest_api_type: inventories
tags:
- awx_config
- name: "Search inventory <localhost>"
include_tasks: awx-config-get-typ-id.yml
vars:
@ -476,6 +505,13 @@
tags:
- awx_config
- name: "Remove all <projects>"
include_tasks: awx-config-cleanup.yml
vars:
awx_rest_api_type: projects
tags:
- awx_config
- name: "Search project <hetzner-ansible>"
include_tasks: awx-config-get-typ-id.yml
vars:
@ -536,41 +572,12 @@
tags:
- awx_config
- name: "Fetch all job_template ids"
uri:
url: "{{ awx_base_url }}/api/v2/job_templates/"
method: GET
user: "{{ awx_rest_api_access_user }}"
password: "{{ awx_rest_api_access_pw }}"
headers:
Content-Type: "application/json"
Accept: "application/json"
body_format: "json"
force_basic_auth: true
validate_certs: false
status_code: 200
register: response
tags:
- awx_config
- name: "Remove all job templates"
uri:
url: "{{ awx_base_url }}{{ item.url }}"
method: DELETE
user: "{{ awx_rest_api_access_user }}"
password: "{{ awx_rest_api_access_pw }}"
headers:
Content-Type: "application/json"
Accept: "application/json"
body_format: "json"
force_basic_auth: true
validate_certs: false
status_code: 204
- name: "Remove all <job_templates>"
include_tasks: awx-config-cleanup.yml
vars:
awx_rest_api_type: job_templates
tags:
- awx_config
loop: "{{ response.json.results }}"
loop_control:
label: "{{ item.url }}"
- name: "Create job templates"
include_tasks: awx-config-job-template.yml

@ -9,10 +9,10 @@
config_file: "/etc/mysql/mariadb.conf.d/50-client.cnf"
login_password: "{{ mysql_root_password }}"
- name: "Import database from {{ upload_directory }}/{{ uploaded_file }} to {{ target_database }}"
- name: "Import database from {{ upload_directory }}/{{ database_backup_file }} to {{ target_database }}"
community.mysql.mysql_db:
name: "{{ target_database }}"
state: import
target: "/tmp/{{ uploaded_file }}"
target: "/tmp/{{ database_backup_file }}"
config_file: "/etc/mysql/mariadb.conf.d/50-client.cnf"
login_password: "{{ mysql_root_password }}"

File diff suppressed because it is too large Load Diff

@ -65,18 +65,18 @@
"hidden" : true
} ],
"filters" : [ {
"name" : "Creation User",
"name" : "Ersteller",
"key" : "creation_user_id",
"defaultOption" : {
"key" : "default",
"name" : "All"
"name" : "Alle"
}
}, {
"name" : "State",
"name" : "Status",
"key" : "vorgang_status_text",
"defaultOption" : {
"key" : "default",
"name" : "All"
"name" : "Alle"
}
} ]
}

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.6.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.9.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:signal id="Signal_1rr7wdd" name="Signal_05vo0km" />
<bpmn2:collaboration id="Collaboration_0oahy0i">
<bpmn2:participant id="Participant_19lpjee" name="Simple Connect" processRef="simple-connect" />
@ -695,20 +695,7 @@ Keycloak Realm mit Administrator Account
<camunda:inputOutput>
<camunda:outputParameter name="awxPath">/api/v2/job_templates/${job_template_id}/launch/</camunda:outputParameter>
<camunda:outputParameter name="extra_vars">
<camunda:map>
<camunda:entry key="scope_id">${contextScopeId}</camunda:entry>
<camunda:entry key="process_instance_id">${execution.getProcessInstanceId()}</camunda:entry>
<camunda:entry key="smardigo_management_action">${smardigoManagementAction}</camunda:entry>
<camunda:entry key="cluster_name">${cluster.name}</camunda:entry>
<camunda:entry key="cluster_service">${cluster.service}</camunda:entry>
<camunda:entry key="cluster_size">${cluster.size}</camunda:entry>
<camunda:entry key="stage">${cluster.stage}</camunda:entry>
<camunda:entry key="current_realm_name">${tenant.key}</camunda:entry>
<camunda:entry key="current_realm_display_name">${tenant.name}</camunda:entry>
<camunda:entry key="tenant_id">${tenant.key}</camunda:entry>
<camunda:entry key="cluster_services">${cluster_services}</camunda:entry>
<camunda:entry key="uploaded_file">${execution.getVariable('databaseBackupFilename')}</camunda:entry>
</camunda:map>
<camunda:script scriptFormat="groovy" resource="create-awx-paramaters.groovy" />
</camunda:outputParameter>
</camunda:inputOutput>
</bpmn2:extensionElements>

@ -4,7 +4,7 @@ def env = [
smardigo_management_action: smardigoManagementAction,
cluster_name: cluster.name,
cluster_service: cluster.service,
cluster_services: [cluster.service] + execution.getVariable('connect-features'),
cluster_services_str: ([cluster.service] + execution.getVariable('connect-features')).join(','),
cluster_size: cluster.size,
stage: cluster.stage,
current_realm_name: tenant.key,
@ -17,12 +17,7 @@ def ansibleCommand= 'ansible-playbook ' + smardigoManagementAction + '.yml --vau
def ansibleEnvironment= ' -e \"'
env.each { key, val ->
if (val instanceof List) {
ansibleEnvironment+= key + '=['
val.each { _val ->
ansibleEnvironment+='\'' + _val + '\','
}
ansibleEnvironment = ansibleEnvironment.substring(0, ansibleEnvironment.length() - 1);
ansibleEnvironment+='] '
ansibleEnvironment+= key + '=\'' + val.join(',') + '\' '
} else {
ansibleEnvironment+= key + '=\'' + val + '\' '
}

@ -0,0 +1,14 @@
[
scope_id: contextScopeId,
process_instance_id: execution.getProcessInstanceId(),
smardigo_management_action: smardigoManagementAction,
cluster_name: cluster.name,
cluster_service: cluster.service,
cluster_services_str: ([cluster.service] + execution.getVariable('connect-features')).join(','),
cluster_size: cluster.size,
stage: cluster.stage,
current_realm_name: tenant.key,
current_realm_display_name: tenant.name,
uploaded_file: execution.getVariable('databaseBackupFilename'),
tenant_id: tenant.key
]

@ -1,15 +1,18 @@
{
"groups" : [ {
"id" : "user",
"name" : "User"
}, {
"id" : "head",
"name" : "Head"
"id" : "administrator",
"name" : "Administrator"
}, {
"id" : "maintainer",
"name" : "Maintainer"
}, {
"id" : "administrator",
"name" : "Administrator"
"id" : "process-delete-approver",
"name" : "Aussonderungsliste anzeigen und bearbeiten"
}, {
"id" : "process-deleter",
"name" : "Löschen von Vorgängen"
}, {
"id" : "user",
"name" : "User"
} ]
}

@ -46,9 +46,7 @@
- name: "Reading hetzner private network id for <{{ stage }}>"
set_fact:
stage_private_network_id: "{{ hetzner_networks.json.networks | json_query(querystr) | first }}"
vars:
querystr: "[?ip_range=='{{ shared_service_network }}'].id"
stage_private_network_id: "{{ hetzner_networks.json.networks | map(attribute='id') | first }}"
delegate_to: 127.0.0.1
become: false
tags:
@ -64,35 +62,26 @@
when:
- debug
- name: "Reading private ip address for {{ inventory_hostname }}"
- name: "Reading hetzner server infos for stage <{{ stage }}>"
set_fact:
stage_private_server_ip: "{% for server in hetzner_servers.json.servers %}\
{% if server.name == inventory_hostname %}\
stage_server_infos: "\
{% set list= [] %}\
{% for server in hetzner_servers.json.servers %}\
{% for private_net in server.private_net %}\
{% if private_net.network == stage_private_network_id|int %}\
{{ private_net.ip }}\
{{ list.append({'service': server.labels.service, 'private_ip': private_net.ip, 'public_ip': server.public_net.ipv4.ip, 'name': server.name}) }}\
{% endif %}\
{% endfor %}\
{% endif %}\
{% endfor %}"
delegate_to: 127.0.0.1
become: false
tags:
- always
- name: "Reading public ip address for {{ inventory_hostname }}"
set_fact:
stage_server_ip: "{{ hetzner_servers.json.servers | json_query(querystr) | first }}"
vars:
querystr: "[?name=='{{ inventory_hostname }}'].public_net.ipv4.ip"
{% endfor %}\
{{ list|list }}"
delegate_to: 127.0.0.1
become: false
tags:
- always
- name: "Printing ip addresses for {{ inventory_hostname }}"
- name: "Printing hetzner server infos for stage <{{ stage }}>"
debug:
msg: "{{ stage_server_ip }} / {{ stage_private_server_ip }}"
msg: "{{ stage_server_infos }}"
delegate_to: 127.0.0.1
become: false
tags:
@ -100,26 +89,35 @@
when:
- debug
- name: "Reading hetzner server infos for stage <{{ stage }}>"
- name: "Reading private ip address for {{ inventory_hostname }}"
set_fact:
stage_server_infos: "\
{% set list= [] %}\
{% for server in hetzner_servers.json.servers %}\
stage_private_server_ip: "{% for server in hetzner_servers.json.servers %}\
{% if server.name == inventory_hostname %}\
{% for private_net in server.private_net %}\
{% if private_net.network == stage_private_network_id|int %}\
{{ list.append({'service': server.labels.service, 'private_ip': private_net.ip, 'public_ip': server.public_net.ipv4.ip, 'name': server.name}) }}\
{{ private_net.ip }}\
{% endif %}\
{% endfor %}\
{% endfor %}\
{{ list|list }}"
{% endif %}\
{% endfor %}"
delegate_to: 127.0.0.1
become: false
tags:
- always
- name: "Printing hetzner server infos for stage <{{ stage }}>"
- name: "Reading public ip address for {{ inventory_hostname }}"
set_fact:
stage_server_ip: "{{ hetzner_servers.json.servers | json_query(querystr) | first }}"
vars:
querystr: "[?name=='{{ inventory_hostname }}'].public_net.ipv4.ip"
delegate_to: 127.0.0.1
become: false
tags:
- always
- name: "Printing ip addresses for {{ inventory_hostname }}"
debug:
msg: "{{ stage_server_infos }}"
msg: "{{ stage_server_ip }} / {{ stage_private_server_ip }}"
delegate_to: 127.0.0.1
become: false
tags:

@ -4,7 +4,7 @@
# How this stuff works:
# If `upload_file` is defined the upload role save the binary to `upload_directory` (default /tmp)
# If `uploaded_file` and `target_database` are defined the import role imports from file basename `uploaded_file` to `target_database`
# If `database_backup_file` and `target_database` are defined the import role imports from file basename `database_backup_file` to `target_database`
# If both role conditions match the upload role trigger first.
# Parameters:
@ -15,7 +15,7 @@
# cluster_size := (WIP node count for the cluster) (Currently max is 2 master/slave)
# cluster_services := (services to setup, e.g. ['connect', 'wordpress', ...])
# upload_file := the local file to upload (e.g. dumps/wordpress_portal.sql)
# uploaded_file := the dump file to import (e.g. wordpress_portal.sql)
# database_backup_file := the dump file to import (e.g. wordpress_portal.sql)
# smardigo message callback
# scope_id := (scope id of the management process)
# process_instance_id := (process instance id of the management process)
@ -36,6 +36,11 @@
- ansible_version.major >= 2
- ansible_version.minor >= 10
msg: "The ansible version has to be at least ({{ ansible_version.full }})"
- name: "Parsing cluster_services_str into cluster_services"
set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
tags:
- always
tasks:
- name: Add hosts
@ -44,7 +49,6 @@
groups:
- "stage_{{ stage }}"
- "{{ item }}"
cluster_service: "{{ item }}"
changed_when: False
with_items: "{{ cluster_services }}"
when: item in ['connect_wordpress']
@ -60,6 +64,11 @@
pre_tasks:
- name: "Import autodiscover pre-tasks"
include_tasks: tasks/autodiscover_pre_tasks.yml
- name: "Parsing cluster_services_str into cluster_services"
set_fact:
cluster_services: "{{ cluster_services_str | split(',') }}"
tags:
- always
roles:
- role: upload-local-file

Loading…
Cancel
Save