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

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

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

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

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

@ -16,8 +16,6 @@
- name: "Import autodiscover pre-tasks" - name: "Import autodiscover pre-tasks"
include_tasks: tasks/autodiscover_pre_tasks.yml include_tasks: tasks/autodiscover_pre_tasks.yml
tags:
- always
- name: "Variable <ansible_distribution>" - name: "Variable <ansible_distribution>"
debug: 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..." - name: "Printing..."
debug: debug:
msg: "{{ ansible_ssh_key_private }}" msg: "{{ ansible_ssh_key_private }}"
@ -80,6 +88,13 @@
tags: tags:
- awx_config - 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>" - name: "Search credential type id for <Machine>"
include_tasks: awx-config-get-typ-id.yml include_tasks: awx-config-get-typ-id.yml
vars: vars:
@ -319,6 +334,13 @@
tags: tags:
- awx_config - 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>" - name: "Search execution environment for <hetzner-ansible>"
include_tasks: awx-config-get-typ-id.yml include_tasks: awx-config-get-typ-id.yml
vars: vars:
@ -380,6 +402,13 @@
tags: tags:
- awx_config - 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>" - name: "Search inventory <localhost>"
include_tasks: awx-config-get-typ-id.yml include_tasks: awx-config-get-typ-id.yml
vars: vars:
@ -476,6 +505,13 @@
tags: tags:
- awx_config - 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>" - name: "Search project <hetzner-ansible>"
include_tasks: awx-config-get-typ-id.yml include_tasks: awx-config-get-typ-id.yml
vars: vars:
@ -536,41 +572,12 @@
tags: tags:
- awx_config - awx_config
- name: "Fetch all job_template ids" - name: "Remove all <job_templates>"
uri: include_tasks: awx-config-cleanup.yml
url: "{{ awx_base_url }}/api/v2/job_templates/" vars:
method: GET awx_rest_api_type: job_templates
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
tags: tags:
- awx_config - awx_config
loop: "{{ response.json.results }}"
loop_control:
label: "{{ item.url }}"
- name: "Create job templates" - name: "Create job templates"
include_tasks: awx-config-job-template.yml include_tasks: awx-config-job-template.yml

@ -9,10 +9,10 @@
config_file: "/etc/mysql/mariadb.conf.d/50-client.cnf" config_file: "/etc/mysql/mariadb.conf.d/50-client.cnf"
login_password: "{{ mysql_root_password }}" 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: community.mysql.mysql_db:
name: "{{ target_database }}" name: "{{ target_database }}"
state: import state: import
target: "/tmp/{{ uploaded_file }}" target: "/tmp/{{ database_backup_file }}"
config_file: "/etc/mysql/mariadb.conf.d/50-client.cnf" config_file: "/etc/mysql/mariadb.conf.d/50-client.cnf"
login_password: "{{ mysql_root_password }}" login_password: "{{ mysql_root_password }}"

File diff suppressed because it is too large Load Diff

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?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:signal id="Signal_1rr7wdd" name="Signal_05vo0km" />
<bpmn2:collaboration id="Collaboration_0oahy0i"> <bpmn2:collaboration id="Collaboration_0oahy0i">
<bpmn2:participant id="Participant_19lpjee" name="Simple Connect" processRef="simple-connect" /> <bpmn2:participant id="Participant_19lpjee" name="Simple Connect" processRef="simple-connect" />
@ -695,20 +695,7 @@ Keycloak Realm mit Administrator Account
<camunda:inputOutput> <camunda:inputOutput>
<camunda:outputParameter name="awxPath">/api/v2/job_templates/${job_template_id}/launch/</camunda:outputParameter> <camunda:outputParameter name="awxPath">/api/v2/job_templates/${job_template_id}/launch/</camunda:outputParameter>
<camunda:outputParameter name="extra_vars"> <camunda:outputParameter name="extra_vars">
<camunda:map> <camunda:script scriptFormat="groovy" resource="create-awx-paramaters.groovy" />
<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:outputParameter> </camunda:outputParameter>
</camunda:inputOutput> </camunda:inputOutput>
</bpmn2:extensionElements> </bpmn2:extensionElements>

@ -4,7 +4,7 @@ def env = [
smardigo_management_action: smardigoManagementAction, smardigo_management_action: smardigoManagementAction,
cluster_name: cluster.name, cluster_name: cluster.name,
cluster_service: cluster.service, 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, cluster_size: cluster.size,
stage: cluster.stage, stage: cluster.stage,
current_realm_name: tenant.key, current_realm_name: tenant.key,
@ -17,12 +17,7 @@ def ansibleCommand= 'ansible-playbook ' + smardigoManagementAction + '.yml --vau
def ansibleEnvironment= ' -e \"' def ansibleEnvironment= ' -e \"'
env.each { key, val -> env.each { key, val ->
if (val instanceof List) { if (val instanceof List) {
ansibleEnvironment+= key + '=[' ansibleEnvironment+= key + '=\'' + val.join(',') + '\' '
val.each { _val ->
ansibleEnvironment+='\'' + _val + '\','
}
ansibleEnvironment = ansibleEnvironment.substring(0, ansibleEnvironment.length() - 1);
ansibleEnvironment+='] '
} else { } else {
ansibleEnvironment+= key + '=\'' + val + '\' ' 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" : [ { "groups" : [ {
"id" : "user", "id" : "administrator",
"name" : "User" "name" : "Administrator"
}, {
"id" : "head",
"name" : "Head"
}, { }, {
"id" : "maintainer", "id" : "maintainer",
"name" : "Maintainer" "name" : "Maintainer"
}, { }, {
"id" : "administrator", "id" : "process-delete-approver",
"name" : "Administrator" "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 }}>" - name: "Reading hetzner private network id for <{{ stage }}>"
set_fact: set_fact:
stage_private_network_id: "{{ hetzner_networks.json.networks | json_query(querystr) | first }}" stage_private_network_id: "{{ hetzner_networks.json.networks | map(attribute='id') | first }}"
vars:
querystr: "[?ip_range=='{{ shared_service_network }}'].id"
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
become: false become: false
tags: tags:
@ -64,35 +62,26 @@
when: when:
- debug - debug
- name: "Reading private ip address for {{ inventory_hostname }}" - name: "Reading hetzner server infos for stage <{{ stage }}>"
set_fact: set_fact:
stage_private_server_ip: "{% for server in hetzner_servers.json.servers %}\ stage_server_infos: "\
{% if server.name == inventory_hostname %}\ {% set list= [] %}\
{% for server in hetzner_servers.json.servers %}\
{% for private_net in server.private_net %}\ {% for private_net in server.private_net %}\
{% if private_net.network == stage_private_network_id|int %}\ {% 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 %}\ {% endif %}\
{% endfor %}\ {% endfor %}\
{% endif %}\ {% endfor %}\
{% endfor %}" {{ list|list }}"
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"
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
become: false become: false
tags: tags:
- always - always
- name: "Printing ip addresses for {{ inventory_hostname }}" - name: "Printing hetzner server infos for stage <{{ stage }}>"
debug: debug:
msg: "{{ stage_server_ip }} / {{ stage_private_server_ip }}" msg: "{{ stage_server_infos }}"
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
become: false become: false
tags: tags:
@ -100,26 +89,35 @@
when: when:
- debug - debug
- name: "Reading hetzner server infos for stage <{{ stage }}>" - name: "Reading private ip address for {{ inventory_hostname }}"
set_fact: set_fact:
stage_server_infos: "\ stage_private_server_ip: "{% for server in hetzner_servers.json.servers %}\
{% set list= [] %}\ {% if server.name == inventory_hostname %}\
{% for server in hetzner_servers.json.servers %}\
{% for private_net in server.private_net %}\ {% for private_net in server.private_net %}\
{% if private_net.network == stage_private_network_id|int %}\ {% 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 %}\ {% endif %}\
{% endfor %}\ {% endfor %}\
{% endfor %}\ {% endif %}\
{{ list|list }}" {% endfor %}"
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
become: false become: false
tags: tags:
- always - 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: debug:
msg: "{{ stage_server_infos }}" msg: "{{ stage_server_ip }} / {{ stage_private_server_ip }}"
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
become: false become: false
tags: tags:

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

Loading…
Cancel
Save