summaryrefslogtreecommitdiffstats
path: root/roles/ands_kaas
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-02-16 20:54:52 +0100
committerSuren A. Chilingaryan <csa@suren.me>2018-02-16 20:54:52 +0100
commit96ced00e05b50f276841a9212ae89e018de4d92d (patch)
treeb86c75fa97326dc89cc37c6dd23d294bd13eb56a /roles/ands_kaas
parentcd94e324d3401e518578d91382a2b7ee67562112 (diff)
downloadands-96ced00e05b50f276841a9212ae89e018de4d92d.tar.gz
ands-96ced00e05b50f276841a9212ae89e018de4d92d.tar.bz2
ands-96ced00e05b50f276841a9212ae89e018de4d92d.tar.xz
ands-96ced00e05b50f276841a9212ae89e018de4d92d.zip
Updated to OpenShift 3.7 and tested
Diffstat (limited to 'roles/ands_kaas')
-rw-r--r--roles/ands_kaas/tasks/do_project.yml62
-rw-r--r--roles/ands_kaas/tasks/main.yml6
-rw-r--r--roles/ands_kaas/tasks/ocitem.yml6
-rw-r--r--roles/ands_kaas/tasks/ocscript.yml4
-rw-r--r--roles/ands_kaas/tasks/project.yml83
-rw-r--r--roles/ands_kaas/tasks/search.yml16
-rw-r--r--roles/ands_kaas/tasks/sync.yml2
-rw-r--r--roles/ands_kaas/tasks/sync_all.yml2
-rw-r--r--roles/ands_kaas/tasks/templates.yml8
9 files changed, 110 insertions, 79 deletions
diff --git a/roles/ands_kaas/tasks/do_project.yml b/roles/ands_kaas/tasks/do_project.yml
new file mode 100644
index 0000000..61b91d2
--- /dev/null
+++ b/roles/ands_kaas/tasks/do_project.yml
@@ -0,0 +1,62 @@
+---
+- 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_config.volumes | default(kaas_openshift_volumes) }}"
+ loop_control:
+ loop_var: osv
+ vars:
+ query: "[*].volumes.{{osv.value.volume}}.mount"
+ mntpath: "{{ (ands_storage_domains | json_query(query)) }}"
+ path: "{{ mntpath[0] ~ (osv.value.path | default('')) }}"
+ 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(ands_openshift_files) }}"
+ loop_control:
+ loop_var: file
+ vars:
+ pvar: "kaas_{{ file.osv }}_path"
+ path: "{{ hostvars[inventory_hostname][pvar] }}/{{ file.path }}"
+ when: file.osv in ( kaas_project_config.volumes | default(kaas_openshift_volumes) )
+
+- name: Load OpenSSL keys
+ include_tasks: keys.yml
+# delegate_to: "{{ groups.masters[0] }}"
+ run_once: true
+ with_dict: "{{ kaas_project_config.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] }}"
+ run_once: true
+ when:
+ - kaas_project_config.oc is undefined
+ - kaas_project_config.pods != {}
+
+
diff --git a/roles/ands_kaas/tasks/main.yml b/roles/ands_kaas/tasks/main.yml
index c9fb857..0931f80 100644
--- a/roles/ands_kaas/tasks/main.yml
+++ b/roles/ands_kaas/tasks/main.yml
@@ -1,9 +1,9 @@
---
- name: Provision OpenShift resources & configurations
-# include: only_templates.yml
- include: project.yml
+# include_tasks: only_templates.yml
+ include_tasks: project.yml
run_once: true
- delegate_to: "{{ groups.masters[0] }}"
+# delegate_to: "{{ groups.masters[0] }}"
with_items: "{{ kaas_projects }}"
loop_control:
loop_var: kaas_project
diff --git a/roles/ands_kaas/tasks/ocitem.yml b/roles/ands_kaas/tasks/ocitem.yml
index f21e8cd..addb249 100644
--- a/roles/ands_kaas/tasks/ocitem.yml
+++ b/roles/ands_kaas/tasks/ocitem.yml
@@ -1,13 +1,13 @@
---
- name: OpenShift templates
- include: templates.yml
+ include_tasks: templates.yml
run_once: true
vars:
kaas_template_glob: "{{ ocitem.template }}"
when: ocitem.template is defined
- name: OpenShift commands
- include: oc.yml
- delegate_to: "{{ groups.masters[0] }}"
+ include_tasks: oc.yml
+# delegate_to: "{{ groups.masters[0] }}"
run_once: true
when: ocitem.oc is defined
diff --git a/roles/ands_kaas/tasks/ocscript.yml b/roles/ands_kaas/tasks/ocscript.yml
index 4927de4..6890f43 100644
--- a/roles/ands_kaas/tasks/ocscript.yml
+++ b/roles/ands_kaas/tasks/ocscript.yml
@@ -1,6 +1,6 @@
---
-- include: ocitem.yml
- delegate_to: "{{ groups.masters[0] }}"
+- include_tasks: ocitem.yml
+# delegate_to: "{{ groups.masters[0] }}"
run_once: true
with_items: "{{ kaas_project_config.oc }}"
loop_control:
diff --git a/roles/ands_kaas/tasks/project.yml b/roles/ands_kaas/tasks/project.yml
index 002596b..40b5180 100644
--- a/roles/ands_kaas/tasks/project.yml
+++ b/roles/ands_kaas/tasks/project.yml
@@ -4,73 +4,24 @@
when: "'{{kaas_project_path}}/vars/globals.yml' | is_file"
- name: Load variables
- include_vars: dir="{{kaas_project_path}}/vars" name="kaas_project_config"
+ include_vars: dir="{{kaas_project_path}}/vars" name="var_{{kaas_project}}_config"
when: "'{{kaas_project_path}}/vars' | is_dir"
-- name: Ensure OpenShift template directory exists
- file: path="{{ kaas_template_path }}" state="directory" mode=0755 owner=root group=root
-
-- name: Configure KaaS volumes
- include: volume.yml
- run_once: true
- delegate_to: "{{ groups.masters[0] }}"
- with_dict: "{{ kaas_project_config.volumes | default(kaas_openshift_volumes) }}"
- loop_control:
- loop_var: osv
- vars:
- query: "[*].volumes.{{osv.value.volume}}.mount"
- mntpath: "{{ (ands_storage_domains | json_query(query)) }}"
- path: "{{ mntpath[0] ~ (osv.value.path | default('')) }}"
- name: "{{osv.key}}"
- volume: "{{osv.value}}"
- when: ( mntpath | length ) > 0
-
-- name: Copy static configuration
- include: sync_all.yml
- run_once: true
- delegate_to: "{{ groups.masters[0] }}"
- with_items: "{{ lookup('pipe', search).split('\n') }}"
- loop_control:
- loop_var: osv_path
+- set_fact: "var_{{kaas_project}}_config={{var_empty}}"
vars:
- search: "find {{ kaas_project_path }}/files/ -type d -mindepth 1 -maxdepth 1"
- osv: "{{ osv_path | basename }}"
- pvar: "kaas_{{ osv }}_path"
- local_path: "{{ osv_path }}"
- remote_path: "{{ hostvars[inventory_hostname][pvar] }}"
- when:
- - osv in kaas_openshift_volumes
- - hostvars[inventory_hostname][pvar] is defined
-
-- name: Configure KaaS files
- include: file.yml
- run_once: true
- delegate_to: "{{ groups.masters[0] }}"
- with_items: "{{ kaas_project_config.files | default(ands_openshift_files) }}"
- loop_control:
- loop_var: file
+ var_empty:
+ pods: {}
+ var_name: "var_{{kaas_project}}_config"
+ when: hostvars[inventory_hostname][var_name] is not defined
+
+#- debug: msg="{{kaas_project_path}}"
+#- debug:
+# msg="{{kaas_project_config}}"
+# vars:
+# var_name: "var_{{kaas_project}}_config"
+# kaas_project_config: "{{hostvars[inventory_hostname][var_name]}}"
+
+- include_tasks: do_project.yml
vars:
- pvar: "kaas_{{ file.osv }}_path"
- path: "{{ hostvars[inventory_hostname][pvar] }}/{{ file.path }}"
- when: file.osv in ( kaas_project_config.volumes | default(kaas_openshift_volumes) )
-
-- name: Load OpenSSL keys
- include: keys.yml
- delegate_to: "{{ groups.masters[0] }}"
- run_once: true
- with_dict: "{{ kaas_project_config.pods }}"
- loop_control:
- loop_var: pod
-
-- name: "Run OC script"
- include: ocscript.yml
- delegate_to: "{{ groups.masters[0] }}"
- run_once: true
- when: kaas_project_config.oc is defined
-
-- name: "Configure all templates"
- include: templates.yml
- delegate_to: "{{ groups.masters[0] }}"
- run_once: true
- when: kaas_project_config.oc is undefined
-
+ var_name: "var_{{kaas_project}}_config"
+ kaas_project_config: "{{hostvars[inventory_hostname][var_name]}}"
diff --git a/roles/ands_kaas/tasks/search.yml b/roles/ands_kaas/tasks/search.yml
new file mode 100644
index 0000000..e54c42b
--- /dev/null
+++ b/roles/ands_kaas/tasks/search.yml
@@ -0,0 +1,16 @@
+- name: Copy static configuration
+ include_tasks: sync_all.yml
+ run_once: true
+# delegate_to: "{{ groups.masters[0] }}"
+ with_items: "{{ lookup('pipe', search).split('\n') }}"
+ loop_control:
+ loop_var: osv_path
+ vars:
+ search: "find {{ kaas_project_path }}/files/ -type d -mindepth 1 -maxdepth 1"
+ osv: "{{ osv_path | basename }}"
+ pvar: "kaas_{{ osv }}_path"
+ local_path: "{{ osv_path }}"
+ remote_path: "{{ hostvars[inventory_hostname][pvar] }}"
+ when:
+ - osv in kaas_openshift_volumes
+ - hostvars[inventory_hostname][pvar] is defined
diff --git a/roles/ands_kaas/tasks/sync.yml b/roles/ands_kaas/tasks/sync.yml
index 399cb66..07764ca 100644
--- a/roles/ands_kaas/tasks/sync.yml
+++ b/roles/ands_kaas/tasks/sync.yml
@@ -4,5 +4,5 @@
register: result
- name: "Sync '{{ item_name }}'"
- synchronize: src="{{ item_src }}" dest="{{ remote_path }}/" archive=yes
+ local_action: synchronize src="{{ item_src }}" dest="{{ remote_path }}/" archive=yes
when: (result.stat.exists == False) or (kaas_resync | default(false))
diff --git a/roles/ands_kaas/tasks/sync_all.yml b/roles/ands_kaas/tasks/sync_all.yml
index 58a1710..2c7bae1 100644
--- a/roles/ands_kaas/tasks/sync_all.yml
+++ b/roles/ands_kaas/tasks/sync_all.yml
@@ -2,7 +2,7 @@
- name: "Analyze '{{ local_path | basename }}'"
# debug: msg="{{ local_path }} - {{ item_name }} - {{ item }}"
- include: sync.yml
+ include_tasks: sync.yml
run_once: true
with_items: "{{ lookup('pipe', filesearch).split('\n') }}"
vars:
diff --git a/roles/ands_kaas/tasks/templates.yml b/roles/ands_kaas/tasks/templates.yml
index 75d43f3..e1612bc 100644
--- a/roles/ands_kaas/tasks/templates.yml
+++ b/roles/ands_kaas/tasks/templates.yml
@@ -8,13 +8,15 @@
- "{{ role_path }}/templates/{{ kaas_template_glob | default('*') }}.j2"
- "{{ kaas_project_path }}/templates/{{ kaas_template_glob | default('*') }}.j2"
+#- debug: msg="{{ results }}"
+
- name: "Sort and execute KaaS templates"
- include: "template.yml"
- delegate_to: "{{ groups.masters[0] }}"
+ include_tasks: "template.yml"
+# delegate_to: "{{ groups.masters[0] }}"
run_once: true
with_items: "{{ sorted_tmpl }}"
vars:
- sorted_tmpl: "{{ results | json_query('results[*].stdout_lines') | sum(start=[]) | map('basename') | sort | unique }}"
+ sorted_tmpl: "{{ (results.results[0] is defined) | ternary (results | json_query('results[*].stdout_lines') | sum(start=[]) | map('basename') | sort | unique, []) }}"
loop_control:
loop_var: tmpl_name