summaryrefslogtreecommitdiffstats
path: root/roles/ands_kaas/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/ands_kaas/tasks')
-rw-r--r--roles/ands_kaas/tasks/do_apps.yml18
-rw-r--r--roles/ands_kaas/tasks/do_keys.yml6
-rw-r--r--roles/ands_kaas/tasks/do_project.yml77
-rw-r--r--roles/ands_kaas/tasks/do_storage.yml14
-rw-r--r--roles/ands_kaas/tasks/ocitem.yml28
-rw-r--r--roles/ands_kaas/tasks/project.yml17
-rw-r--r--roles/ands_kaas/tasks/template.yml11
7 files changed, 82 insertions, 89 deletions
diff --git a/roles/ands_kaas/tasks/do_apps.yml b/roles/ands_kaas/tasks/do_apps.yml
index 6738b7f..39283b4 100644
--- a/roles/ands_kaas/tasks/do_apps.yml
+++ b/roles/ands_kaas/tasks/do_apps.yml
@@ -1,16 +1,20 @@
- name: "Process KaaS apps"
include_tasks: "template.yml"
run_once: true
- with_items: "{{ kaas_project_apps }}"
+ with_dict: "{{ kaas_project_apps }}"
loop_control:
- loop_var: appname
+ loop_var: appitem
when:
- - app.provision | default(true)
- - (ands_configure_app == ands_none) or (app.name == ands_configure_app)
+ - appitem.value.provision | default(true)
+ - (ands_configure_app == ands_none) or (appname == ands_configure_app)
+ - appname | match(kaas_app_regexp | default(.*))
vars:
- app: "{{ kaas_project_config[appname] }}"
- name: "{{ app.name | default((app.pods.keys() | list)[0]) }}"
- instantiate: "{{ app.instantiate | default(false) }}"
+ app: "{{ kaas_project_config[appitem.key] }}"
+ appname: "{{ app.name | default(appitem.key) | regex_replace('_','-') }}"
+# appname: "{{ app.name | default((app.pods.keys() | list)[0]) }}"
+ options: "{{ app.options | default({}) }}"
+ delete: "{{ options.delete | default(true) }}"
+ instantiate: "{{ appitem.value.instantiate | default(false) }}"
load: "{{ app.load | default(false) }}"
pods: "{{ app.pods }}"
tmpl_name: "50-kaas-pods.yml.j2"
diff --git a/roles/ands_kaas/tasks/do_keys.yml b/roles/ands_kaas/tasks/do_keys.yml
new file mode 100644
index 0000000..391392e
--- /dev/null
+++ b/roles/ands_kaas/tasks/do_keys.yml
@@ -0,0 +1,6 @@
+- name: Load OpenSSL keys
+ include_tasks: keys.yml
+ run_once: true
+ with_dict: "{{ kaas_project_pods }}"
+ loop_control:
+ loop_var: pod
diff --git a/roles/ands_kaas/tasks/do_project.yml b/roles/ands_kaas/tasks/do_project.yml
index f5b3276..71a54ad 100644
--- a/roles/ands_kaas/tasks/do_project.yml
+++ b/roles/ands_kaas/tasks/do_project.yml
@@ -2,77 +2,24 @@
- name: Ensure OpenShift template directory exists
file: path="{{ kaas_template_path }}" state="directory" mode=0755 owner=root group=root
-- name: Configure KaaS volumes
- include_tasks: volume.yml
- run_once: true
-# delegate_to: "{{ groups.masters[0] }}"
- with_dict: "{{ kaas_project_volumes }}"
- loop_control:
- loop_var: osv
- vars:
- vt_query: "[*].volumes.{{osv.value.volume}}.type"
- voltype: "{{ (kaas_storage_domains | json_query(vt_query)) }}"
- mp_query: "[*].volumes.{{osv.value.volume}}.mount"
- mntpath: "{{ (kaas_storage_domains | json_query(mp_query)) }}"
- rp_query: "[*].volumes.{{osv.value.volume}}.path"
- realpath: "{{ (kaas_storage_domains | json_query(rp_query)) }}"
- osvpath: "{{ osv.value.path | default('') }}"
- prefix: "{{ ( osvpath[:1] == '/' ) | ternary('', '/' ~ kaas_project ~ '/') }}"
- path: "{{ mntpath[0] ~ prefix ~ osvpath }}"
- hostpath: "{{ realpath[0] is defined | ternary((realpath[0] | default('')) ~ prefix ~ osvpath, '') }}"
- name: "{{osv.key}}"
- volume: "{{osv.value}}"
- when: ( mntpath | length ) > 0
-
-- name: Check if static configuration exists
- local_action: stat path="{{ kaas_project_path }}/files/"
- register: result
-
-- name: Search static configuration
- include_tasks: search.yml
- when: result.stat.exists
-
-- name: Configure KaaS files
- include_tasks: file.yml
- run_once: true
-# delegate_to: "{{ groups.masters[0] }}"
- with_items: "{{ kaas_project_config.files | default(kaas_openshift_files) | default([]) }}"
- loop_control:
- loop_var: file
- vars:
- osv: "{{ kaas_project_volumes[file.osv] }}"
- vt_query: "[*].volumes.{{osv.volume}}.type"
- voltype: "{{ (kaas_storage_domains | json_query(vt_query)) }}"
- mp_query: "[*].volumes.{{osv.volume}}.mount"
- mntpath: "{{ (kaas_storage_domains | json_query(mp_query)) }}"
- rp_query: "[*].volumes.{{osv.volume}}.path"
- realpath: "{{ (kaas_storage_domains | json_query(rp_query)) }}"
- pvar: "kaas_{{ file.osv }}_path"
- path: "{{ hostvars[inventory_hostname][pvar] }}/{{ file.path }}"
- hvar: "kaas_{{ file.osv }}_hostpath"
- hostpath: "{{ hostvars[inventory_hostname][hvar] }}/{{ file.path }}"
- when: file.osv in kaas_project_volumes
-
-- name: Load OpenSSL keys
- include_tasks: keys.yml
-# delegate_to: "{{ groups.masters[0] }}"
- run_once: true
- with_dict: "{{ kaas_project_pods }}"
- loop_control:
- loop_var: pod
-
- name: "Run OC script"
include_tasks: ocscript.yml
-# delegate_to: "{{ groups.masters[0] }}"
run_once: true
when: kaas_project_config.oc is defined
-- name: "Configure all templates"
- include_tasks: templates.yml
-# delegate_to: "{{ groups.masters[0] }}"
+- block:
+ - name: Configure storage
+ include_tasks: do_storage.yml
+
+ - name: Configure SSL keys
+ include_tasks: do_keys.yml
+
+ - name: Configure all templates
+ include_tasks: templates.yml
+
+ - name: Install Applications
+ include_tasks: do_apps.yml
run_once: true
when:
- kaas_project_config.oc is undefined
-- name: Install Applications
- include_tasks: do_apps.yml
diff --git a/roles/ands_kaas/tasks/do_storage.yml b/roles/ands_kaas/tasks/do_storage.yml
index ee118fd..e79db56 100644
--- a/roles/ands_kaas/tasks/do_storage.yml
+++ b/roles/ands_kaas/tasks/do_storage.yml
@@ -18,8 +18,18 @@
volume: "{{osv.value}}"
when:
- ( mntpath | length ) > 0
- - (osv.type | default("host")) in [ "host" ]
+ - (kaas_storage_types is not defined) or ((osv.type | default("host")) in kaas_storage_types)
+- name: Check if static configuration exists
+ local_action: stat path="{{ kaas_project_path }}/files/"
+ register: result
+
+# Executed only if complete project is provisioned (not if we just care to provision per-node storage)
+- name: Search static configuration
+ include_tasks: search.yml
+ when:
+ - result.stat.exists
+ - kaas_storage_types is not defined
- name: Configure KaaS files
include_tasks: file.yml
@@ -40,4 +50,4 @@
hostpath: "{{ hostvars[inventory_hostname][hvar] }}/{{ file.path }}"
when:
- file.osv in kaas_project_volumes
- - (osv.type | default("host")) in [ "host" ]
+ - (kaas_storage_types is not defined) or ((osv.type | default("host")) in kaas_storage_types)
diff --git a/roles/ands_kaas/tasks/ocitem.yml b/roles/ands_kaas/tasks/ocitem.yml
index addb249..758cdaf 100644
--- a/roles/ands_kaas/tasks/ocitem.yml
+++ b/roles/ands_kaas/tasks/ocitem.yml
@@ -1,13 +1,35 @@
---
+- name: Storage
+ include_tasks: do_storage.yml
+ run_once: true
+ vars:
+ kaas_storage_regexp: "{{ ocitem.storage }}"
+ when: ocitem.storage is defined
+
+- name: Keys
+ include_tasks: do_keys.yml
+ run_once: true
+ vars:
+ kaas_keys_regexp: "{{ ocitem.keys }}"
+ when: ocitem.keys is defined
+
- name: OpenShift templates
include_tasks: templates.yml
run_once: true
vars:
- kaas_template_glob: "{{ ocitem.template }}"
- when: ocitem.template is defined
+ kaas_template_glob: "{{ ocitem.templates }}"
+ when: ocitem.templates is defined
+
+- name: OpenShift apps
+ include_tasks: do_apps.yml
+ run_once: true
+ vars:
+ kaas_app_regexp: "{{ ocitem.apps }}"
+ when: ocitem.apps is defined
- name: OpenShift commands
include_tasks: oc.yml
-# delegate_to: "{{ groups.masters[0] }}"
run_once: true
when: ocitem.oc is defined
+
+
diff --git a/roles/ands_kaas/tasks/project.yml b/roles/ands_kaas/tasks/project.yml
index ecb2035..26bd0cc 100644
--- a/roles/ands_kaas/tasks/project.yml
+++ b/roles/ands_kaas/tasks/project.yml
@@ -26,7 +26,7 @@
with_dict: "{{ kaas_block_volumes }}"
when: item.value.project == kaas_project
-- name: Get information about block volumes
+- name: Get more information about block volumes
delegate_to: "{{ groups.masters[0] }}"
shell: gluster-block info {{ item.value.volume }}/{{ item.key }} | grep -oP '^EXPORTED NODE.*:\s*\K.*' | tr ' ' '\n'
register: portal_info
@@ -55,11 +55,12 @@
- include_tasks: "do_{{ do_subrole | default('project') }}.yml"
vars:
var_name: "var_{{kaas_project}}_config"
- kaas_project_config: "{{ hostvars[inventory_hostname][var_name] }}"
- kaas_project_volumes: "{{ kaas_project_config.volumes | default(kaas_project_config.extra_volumes | default({}) | combine(kaas_openshift_volumes)) }}"
- kaas_project_pods: "{{ kaas_project_config.pods | default({}) }}"
- kaas_project_apps: "{{ kaas_project_config.apps | default([]) }}"
- kaas_project_gids: "{{ kaas_project_config.gids | default(kaas_openshift_gids) }}"
- kaas_project_uids: "{{ kaas_project_config.uids | default(kaas_openshift_uids) }}"
- kaas_blockvol_info: "{{ block_info }}"
+ kaas_project_config: "{{ hostvars[inventory_hostname][var_name] }}"
+ kaas_project_volumes: "{{ kaas_project_config.volumes | default(kaas_project_config.extra_volumes | default({}) | combine(kaas_openshift_volumes)) }}"
+ kaas_project_local_volumes: "{{ kaas_project_config.local_volumes | default({}) }}"
+ kaas_project_pods: "{{ kaas_project_config.pods | default({}) }}"
+ kaas_project_apps: "{{ kaas_project_config.apps | default([]) }}"
+ kaas_project_gids: "{{ kaas_project_config.gids | default(kaas_openshift_gids) }}"
+ kaas_project_uids: "{{ kaas_project_config.uids | default(kaas_openshift_uids) }}"
+ kaas_blockvol_info: "{{ block_info }}"
\ No newline at end of file
diff --git a/roles/ands_kaas/tasks/template.yml b/roles/ands_kaas/tasks/template.yml
index 418331a..87e45a6 100644
--- a/roles/ands_kaas/tasks/template.yml
+++ b/roles/ands_kaas/tasks/template.yml
@@ -1,9 +1,9 @@
-- name: "Populate template {{ tmpl_name }}"
+- name: "Populate template '{{ tmpl_name }}' in project '{{ kaas_project }}' for application '{{ appname | default('kaas') }}'"
template: src="{{ item }}" dest="{{ kaas_template_path }}/{{ dest_name }}" owner=root group=root mode="0644"
register: result
vars:
default_name: "{{ item | basename | regex_replace('\\.j2','') }}"
- dest_name: "{{ (name is defined) | ternary ( (name | default('')) + '.yml', default_name ) }}"
+ dest_name: "{{ (appname is defined) | ternary ( '90-' + (appname | default('')) + '.yml', default_name ) }}"
with_first_found:
- paths:
- "{{ role_path }}/templates/"
@@ -15,10 +15,13 @@
include_role: name="openshift_resource"
when: instantiate == true
vars:
- template: "{{ tmpl_name | basename | regex_replace('\\.j2','') }}"
+ default_name: "{{ tmpl_name | basename | regex_replace('\\.j2','') }}"
+ dest_name: "{{ (appname is defined) | ternary ( '90-' + (appname | default('')) + '.yml', default_name ) }}"
+ template: "{{ dest_name }}"
template_path: "{{ kaas_template_path }}"
project: "{{ kaas_project }}"
- recreate: "{{ result | changed | ternary (true, false) }}"
+ recreate: "{{ result | changed | ternary (delete | ternary(true, false), false) }}"
+ replace: "{{ result | changed | ternary (delete | ternary(false, true), false) }}"
# alternatively load template
# TODO