summaryrefslogtreecommitdiffstats
path: root/roles/openshift_logging_curator/tasks/main.yaml
blob: b4ddf45d9b18b137ba54813775de9307568fa839 (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
---
- include: determine_version.yaml

# 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: curator.yml
    dest: "{{ tempdir }}/curator.yml"
  when: curator_config_contents is undefined
  changed_when: no

- copy:
    content: "{{ curator_config_contents }}"
    dest: "{{ tempdir }}/curator.yml"
  when: curator_config_contents is defined
  changed_when: no

- 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: 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 }}"
    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