summaryrefslogtreecommitdiffstats
path: root/roles/ands_kaas/tasks/project.yml
blob: f1c596b464cdf26f70cfed2749e2c7d637834645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
- name: Load global variables
  include_vars: "{{kaas_project_path}}/vars/globals.yml" 
  when: path | is_file
  vars:
    path: "{{ kaas_project_path }}/vars/globals.yml"

- name: Load variables
  include_vars: dir="{{kaas_project_path}}/vars" name="var_{{kaas_project}}_config"
  when: path | is_dir
  vars:
    path: "{{ kaas_project_path }}/vars"

- set_fact: "var_{{kaas_project}}_config={{var_empty}}"
  vars:
    var_empty:
      pods: {}
      builders: {}
    var_name: "var_{{kaas_project}}_config"
  when: hostvars[inventory_hostname][var_name] is not defined
  

- name: Get information about block volumes
  delegate_to: "{{ groups.masters[0] }}"
  shell: gluster-block info {{ item.value.volume }}/{{ item.key }} | grep -oP '^GBID:\s*\K.*'
  register: iqn_info
  with_dict: "{{ kaas_block_volumes }}"
  when: item.value.project == kaas_project

- 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
  with_dict: "{{ kaas_block_volumes }}"
  when: item.value.project == kaas_project


- set_fact: 
    kaas_block_iqn: "{{ {} }}"
    kaas_block_portals: "{{ {} }}"

- set_fact: "kaas_block_iqn={{ kaas_block_iqn | combine({item.item.key: item.stdout}) }}"
  with_items: "{{ iqn_info.results }}"

- set_fact: "kaas_block_portals={{ kaas_block_portals | combine({item.item.key: item.stdout_lines}) }}"
  with_items: "{{ portal_info.results }}"


#- 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_{{ 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_local_volumes: "{{ kaas_project_config.local_volumes | default({}) }}"
    kaas_project_builders:      "{{ kaas_project_config.builders | 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 }}"
    kaas_project_script:        "{{ kaas_project_config.oc | default(ands_none) }}"