summaryrefslogtreecommitdiffstats
path: root/roles/openshift_metrics/tasks/install_metrics.yaml
blob: f05c8968d021642acb8192d515f952c9680924a4 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
- include_tasks: pre_install.yaml

- name: Install Metrics
  include_tasks: "install_{{ include_file }}.yaml"
  with_items:
    - support
    - heapster
    - hawkular
    - cassandra
  loop_control:
    loop_var: include_file
  when: not openshift_metrics_heapster_standalone | bool

- name: Install Heapster Standalone
  include_tasks: install_heapster.yaml
  when: openshift_metrics_heapster_standalone | bool

- name: Install Hawkular OpenShift Agent (HOSA)
  include_tasks: install_hosa.yaml
  when: openshift_metrics_install_hawkular_agent | default(false) | bool

- find:
    paths: "{{ mktemp.stdout }}/templates"
    patterns: "^(?!metrics-hawkular-openshift-agent).*.yaml"
    use_regex: true
  register: object_def_files
  changed_when: no

- slurp:
    src: "{{item.path}}"
  register: object_defs
  with_items: "{{object_def_files.files}}"
  changed_when: no

- name: Create objects
  include_tasks: oc_apply.yaml
  vars:
    kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
    namespace: "{{ openshift_metrics_project }}"
    file_name: "{{ item.source }}"
    file_content: "{{ item.content | b64decode | from_yaml }}"
  with_items: "{{ object_defs.results }}"

- find:
    paths: "{{ mktemp.stdout }}/templates"
    patterns: "^metrics-hawkular-openshift-agent.*.yaml"
    use_regex: true
  register: hawkular_agent_object_def_files
  when: openshift_metrics_install_hawkular_agent | bool
  changed_when: no

- slurp:
    src: "{{item.path}}"
  register: hawkular_agent_object_defs
  with_items: "{{ hawkular_agent_object_def_files.files }}"
  when: openshift_metrics_install_hawkular_agent | bool
  changed_when: no

- name: Create Hawkular Agent objects
  include_tasks: oc_apply.yaml
  vars:
    kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
    namespace: "{{ openshift_metrics_hawkular_agent_namespace }}"
    file_name: "{{ item.source }}"
    file_content: "{{ item.content | b64decode | from_yaml }}"
  with_items: "{{ hawkular_agent_object_defs.results }}"
  when: openshift_metrics_install_hawkular_agent | bool

- include_tasks: update_master_config.yaml
  when: not openshift.common.version_gte_3_9

# Update asset config in openshift-web-console namespace
- name: Add metrics route information to web console asset config
  include_role:
    name: openshift_web_console
    tasks_from: update_console_config.yml
  vars:
    console_config_edits:
      - key: clusterInfo#metricsPublicURL
        value: "https://{{ openshift_metrics_hawkular_hostname}}/hawkular/metrics"
  when:
    - openshift_web_console_install | default(true) | bool
    - openshift.common.version_gte_3_9

- command: >
    {{openshift_client_binary}}
    --config={{mktemp.stdout}}/admin.kubeconfig
    get rc
    -l metrics-infra
    -o name
    -n {{openshift_metrics_project}}
  register: existing_metrics_rc
  changed_when: no

- name: Scaling down cluster to recognize changes
  include_tasks: stop_metrics.yaml
  when: existing_metrics_rc.stdout_lines | length > 0

- name: Scaling up cluster
  include_tasks: start_metrics.yaml
  tags: openshift_metrics_start_cluster
  when:
    - openshift_metrics_start_cluster | default(true) | bool