summaryrefslogtreecommitdiffstats
path: root/roles/openshift_logging_curator/tasks/main.yaml
blob: 414fdbb95a02984584a3c6a8197396c6a70ff758 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
- name: Set default image variables based on deployment_type
  include_vars: "{{ var_file_name }}"
  with_first_found:
    - "{{ openshift_deployment_type }}.yml"
    - "default_images.yml"
  loop_control:
    loop_var: var_file_name

- name: Set curator image facts
  set_fact:
    openshift_logging_curator_image_prefix: "{{ openshift_logging_curator_image_prefix | default(__openshift_logging_curator_image_prefix) }}"
    openshift_logging_curator_image_version: "{{ openshift_logging_curator_image_version | default(__openshift_logging_curator_image_version) }}"

- include_tasks: determine_version.yaml

- name: Ensure that logging curator has nodes to run on
  fail:
    msg: |-
      No schedulable nodes found matching node selector for logging curator - '{{ openshift_logging_curator_nodeselector }}'
  when:
  - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_logging_curator_nodeselector)

# allow passing in a tempdir
- name: Create temp directory for doing work in
  command: mktemp -d /tmp/openshift-logging-ansible-XXXXXX
  register: mktemp
  changed_when: False

- set_fact:
    tempdir: "{{ mktemp.stdout }}"

# This may not be necessary in this role
- name: Create templates subdirectory
  file:
    state: directory
    path: "{{ tempdir }}/templates"
    mode: 0755
  changed_when: False

# we want to make sure we have all the necessary components here

# service account
- name: Create Curator service account
  oc_serviceaccount:
    state: present
    name: "aggregated-logging-curator"
    namespace: "{{ openshift_logging_namespace }}"
    image_pull_secrets: "{{ openshift_logging_image_pull_secret }}"
  when: openshift_logging_image_pull_secret != ''

- name: Create Curator service account
  oc_serviceaccount:
    state: present
    name: "aggregated-logging-curator"
    namespace: "{{ openshift_logging_namespace }}"
  when:
    - openshift_logging_image_pull_secret == ''

# configmap
- copy:
    src: "{{ __base_file_dir }}/curator.yml"
    dest: "{{ tempdir }}/curator.yml"
  changed_when: no

- import_role:
    name: openshift_logging
    tasks_from: patch_configmap_files.yaml
  vars:
    configmap_name: "logging-curator"
    configmap_namespace: "logging"
    configmap_file_names:
      - current_file: "config.yaml"
        new_file: "{{ tempdir }}/curator.yml"

- name: Set Curator configmap
  oc_configmap:
    state: present
    name: "logging-curator"
    namespace: "{{ openshift_logging_namespace }}"
    from_file:
      config.yaml: "{{ tempdir }}/curator.yml"

# secret
- name: Set Curator secret
  oc_secret:
    state: present
    name: "logging-curator"
    namespace: "{{ openshift_logging_namespace }}"
    files:
      - name: ca
        path: "{{ generated_certs_dir }}/ca.crt"
      - name: key
        path: "{{ generated_certs_dir }}/system.logging.curator.key"
      - name: cert
        path: "{{ generated_certs_dir }}/system.logging.curator.crt"

- set_fact:
    curator_name: "{{ 'logging-curator' ~ ( (openshift_logging_curator_ops_deployment | default(false) | bool) | ternary('-ops', '') ) }}"
    curator_component: "{{ 'curator' ~ ( (openshift_logging_curator_ops_deployment | default(false) | bool) | ternary('-ops', '') ) }}"

# DC
# TODO: scale should not exceed 1
- name: Generate Curator deploymentconfig
  template:
    src: "{{ __base_file_dir }}/curator.j2"
    dest: "{{ tempdir }}/templates/curator-dc.yaml"
  vars:
    component: "{{ curator_component }}"
    logging_component: curator
    deploy_name: "{{ curator_name }}"
    image: "{{openshift_logging_curator_image_prefix}}logging-curator:{{openshift_logging_curator_image_version}}"
    es_host: "{{ openshift_logging_curator_es_host }}"
    es_port: "{{ openshift_logging_curator_es_port }}"
    curator_cpu_limit: "{{ openshift_logging_curator_cpu_limit }}"
    curator_cpu_request: "{{ openshift_logging_curator_cpu_request | min_cpu(openshift_logging_curator_cpu_limit | default(none)) }}"
    curator_memory_limit: "{{ openshift_logging_curator_memory_limit }}"
    curator_replicas: "{{ openshift_logging_curator_replicas | default (1) }}"
    curator_node_selector: "{{openshift_logging_curator_nodeselector | default({})}}"
  check_mode: no
  changed_when: no

- name: Set Curator DC
  oc_obj:
    state: present
    name: "{{ curator_name }}"
    namespace: "{{ openshift_logging_namespace }}"
    kind: dc
    files:
      - "{{ tempdir }}/templates/curator-dc.yaml"
    delete_after: true

- name: Delete temp directory
  file:
    name: "{{ tempdir }}"
    state: absent
  changed_when: False