Wolfgang Kulhanek
2019-08-08 d37c1627458de230d9e277b00d506eb64278d0b2
commit | author | age
2fcfc6 1 # vim: set ft=ansible
EMJ 2 ---
3 # Implement your Workload deployment tasks here
4
32de6f 5 - name: Create OpenShift Objects for Logging
95986a 6   ignore_errors: yes
2fcfc6 7   k8s:
EMJ 8     state: present
32de6f 9     merge_type:
WK 10     - strategic-merge
11     - merge
12     definition: "{{ lookup('file', item ) | from_yaml }}"
13   loop:
14   - ./files/namespace.yaml
15   - ./files/operatorgroup.yaml
16   - ./files/elasticsearch_catalog_source.yaml
17   - ./files/elasticsearch_subscription.yaml
18   - ./files/logging_catalog_source.yaml
19   - ./files/logging_subscription.yaml
2fcfc6 20
d37c16 21 - name: Wait for Elasticsearch CRD
2fcfc6 22   k8s_facts:
EMJ 23     api_version: apiextensions.k8s.io/v1beta1
24     kind: CustomResourceDefinition
d37c16 25     name: elasticsearches.logging.openshift.io
WK 26   register: r_elasticsearch_crd
a50d1a 27   retries: 20
1ad15d 28   delay: 10
d37c16 29   ignore_errors: yes
WK 30   until: r_elasticsearch_crd.resources | list | length == 1
2fcfc6 31
d37c16 32 - name: Notify user if Elasticsearch deployment failed
WK 33   when: not r_elasticsearch_crd.resources | list | length == 1
7e2e95 34   debug:
d37c16 35     msg: "user.info: *** Elasticsearch operator could not be installed ***"
WK 36
37 - name: Wait for Logging CRD
38   k8s_facts:
39     api_version: apiextensions.k8s.io/v1beta1
40     kind: CustomResourceDefinition
41     name: clusterloggings.logging.openshift.io
42   register: r_logging_crd
43   retries: 20
44   delay: 10
45   ignore_errors: yes
46   until: r_logging_crd.resources | list | length == 1
47
48 - name: Notify user if Logging deployment failed
49   when: not r_logging_crd.resources | list | length == 1
50   debug:
51     msg: "user.info: *** Logging operator could not be installed ***"
2fcfc6 52
7e2e95 53 - name: Deploy Logging
d37c16 54   when:
WK 55   - r_logging_crd.resources | list | length == 1
56   - r_elasticsearch_crd.resources | list | length == 1
7e2e95 57   block:
WK 58   - name: Create OpenShift Objects for ClusterLogging
59     k8s:
60       state: present
61       merge_type:
62       - strategic-merge
63       - merge
64       definition: "{{ lookup('template', item ) | from_yaml }}"
d37c16 65     ignore_errors: yes
7e2e95 66     loop:
WK 67     - ./templates/cluster_logging.j2
68
d37c16 69   - name: Sleep to give the status field a chance to populate
WK 70     when: _logging_wait_for_deployment | bool
71     pause:
72       seconds: 60
73   
74   - name: Wait until Elasticsearch Cluster Status is green
75     when: _logging_wait_for_deployment| bool
76     k8s_facts:
77       api_version: logging.openshift.io/v1
78       kind: ClusterLogging
79       name: instance
80       namespace: openshift-logging
81     register: r_logging
82     retries: 30
7e2e95 83     delay: 10
d37c16 84     ignore_errors: yes
WK 85     until: 
86     - r_logging.resources[0].status.logStore.elasticsearchStatus[0].clusterHealth == "green"
2fcfc6 87
EMJ 88 # Leave this as the last task in the playbook.
89 - name: workload tasks complete
90   debug:
91     msg: "Workload Tasks completed successfully."
95986a 92   when: not silent|bool