main.yaml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. ---
  2. - fail:
  3. msg: Application logs destination is required
  4. when: not openshift_logging_mux_app_host or openshift_logging_mux_app_host == ''
  5. - fail:
  6. msg: Operations logs destination is required
  7. when: not openshift_logging_mux_ops_host or openshift_logging_mux_ops_host == ''
  8. - include: determine_version.yaml
  9. # allow passing in a tempdir
  10. - name: Create temp directory for doing work in
  11. command: mktemp -d /tmp/openshift-logging-ansible-XXXXXX
  12. register: mktemp
  13. changed_when: False
  14. - set_fact:
  15. tempdir: "{{ mktemp.stdout }}"
  16. - name: Create templates subdirectory
  17. file:
  18. state: directory
  19. path: "{{ tempdir }}/templates"
  20. mode: 0755
  21. changed_when: False
  22. # we want to make sure we have all the necessary components here
  23. # create service account
  24. - name: Create Mux service account
  25. oc_serviceaccount:
  26. state: present
  27. name: "aggregated-logging-mux"
  28. namespace: "{{ openshift_logging_mux_namespace }}"
  29. image_pull_secrets: "{{ openshift_logging_image_pull_secret }}"
  30. when: openshift_logging_image_pull_secret != ''
  31. - name: Create Mux service account
  32. oc_serviceaccount:
  33. state: present
  34. name: "aggregated-logging-mux"
  35. namespace: "{{ openshift_logging_mux_namespace }}"
  36. when:
  37. - openshift_logging_image_pull_secret == ''
  38. # set service account scc
  39. - name: Set privileged permissions for Mux
  40. oc_adm_policy_user:
  41. namespace: "{{ openshift_logging_mux_namespace }}"
  42. resource_kind: scc
  43. resource_name: privileged
  44. state: present
  45. user: "system:serviceaccount:{{ openshift_logging_mux_namespace }}:aggregated-logging-mux"
  46. # set service account permissions
  47. - name: Set cluster-reader permissions for Mux
  48. oc_adm_policy_user:
  49. namespace: "{{ openshift_logging_mux_namespace }}"
  50. resource_kind: cluster-role
  51. resource_name: cluster-reader
  52. state: present
  53. user: "system:serviceaccount:{{ openshift_logging_mux_namespace }}:aggregated-logging-mux"
  54. # set hostmount-anyuid permissions
  55. - name: Set hostmount-anyuid permissions for Mux
  56. oc_adm_policy_user:
  57. namespace: "{{ openshift_logging_mux_namespace }}"
  58. resource_kind: scc
  59. resource_name: hostmount-anyuid
  60. state: present
  61. user: "system:serviceaccount:{{ openshift_logging_mux_namespace }}:aggregated-logging-mux"
  62. # create Mux configmap
  63. - copy:
  64. src: fluent.conf
  65. dest: "{{mktemp.stdout}}/fluent-mux.conf"
  66. when: fluentd_mux_config_contents is undefined
  67. changed_when: no
  68. - copy:
  69. src: secure-forward.conf
  70. dest: "{{mktemp.stdout}}/secure-forward-mux.conf"
  71. when: fluentd_mux_securefoward_contents is undefined
  72. changed_when: no
  73. - copy:
  74. content: "{{fluentd_mux_config_contents}}"
  75. dest: "{{mktemp.stdout}}/fluent-mux.conf"
  76. when: fluentd_mux_config_contents is defined
  77. changed_when: no
  78. - copy:
  79. content: "{{fluentd_mux_secureforward_contents}}"
  80. dest: "{{mktemp.stdout}}/secure-forward-mux.conf"
  81. when: fluentd_mux_secureforward_contents is defined
  82. changed_when: no
  83. - name: Set Mux configmap
  84. oc_configmap:
  85. state: present
  86. name: "logging-mux"
  87. namespace: "{{ openshift_logging_mux_namespace }}"
  88. from_file:
  89. fluent.conf: "{{ tempdir }}/fluent-mux.conf"
  90. secure-forward.conf: "{{ tempdir }}/secure-forward-mux.conf"
  91. # create Mux secret
  92. - name: Set logging-mux secret
  93. oc_secret:
  94. state: present
  95. name: logging-mux
  96. namespace: "{{ openshift_logging_mux_namespace }}"
  97. files:
  98. - name: ca
  99. path: "{{ generated_certs_dir }}/ca.crt"
  100. - name: key
  101. path: "{{ generated_certs_dir }}/system.logging.mux.key"
  102. - name: cert
  103. path: "{{ generated_certs_dir }}/system.logging.mux.crt"
  104. - name: shared_key
  105. path: "{{ generated_certs_dir }}/mux_shared_key"
  106. # services
  107. - name: Set logging-mux service for external communication
  108. oc_service:
  109. state: present
  110. name: "logging-mux"
  111. namespace: "{{ openshift_logging_mux_namespace }}"
  112. selector:
  113. component: mux
  114. provider: openshift
  115. # labels:
  116. # - logging-infra: 'support'
  117. ports:
  118. - name: mux-forward
  119. port: "{{ openshift_logging_mux_port }}"
  120. targetPort: "mux-forward"
  121. # externalIPs:
  122. # - "{{ ansible_eth0.ipv4.address }}"
  123. when: openshift_logging_mux_allow_external | bool
  124. - name: Set logging-mux service for internal communication
  125. oc_service:
  126. state: present
  127. name: "logging-mux"
  128. namespace: "{{ openshift_logging_mux_namespace }}"
  129. selector:
  130. component: mux
  131. provider: openshift
  132. # labels:
  133. # - logging-infra: 'support'
  134. ports:
  135. - name: mux-forward
  136. port: "{{ openshift_logging_mux_port }}"
  137. targetPort: "mux-forward"
  138. when: not openshift_logging_mux_allow_external | bool
  139. # create Mux DC
  140. - name: Generating mux deploymentconfig
  141. template:
  142. src: mux.j2
  143. dest: "{{mktemp.stdout}}/templates/logging-mux-dc.yaml"
  144. vars:
  145. component: mux
  146. logging_component: mux
  147. deploy_name: "logging-{{ component }}"
  148. image: "{{ openshift_logging_image_prefix }}logging-fluentd:{{ openshift_logging_image_version }}"
  149. es_host: "{{ openshift_logging_mux_app_host }}"
  150. es_port: "{{ openshift_logging_mux_app_port }}"
  151. ops_host: "{{ openshift_logging_mux_ops_host }}"
  152. ops_port: "{{ openshift_logging_mux_ops_port }}"
  153. mux_cpu_limit: "{{ openshift_logging_mux_cpu_limit }}"
  154. mux_memory_limit: "{{ openshift_logging_mux_memory_limit }}"
  155. replicas: "{{ openshift_logging_mux_replicas | default(0) }}"
  156. mux_node_selector: "{{ openshift_logging_mux_nodeselector | default({}) }}"
  157. check_mode: no
  158. changed_when: no
  159. - name: Set logging-mux DC
  160. oc_obj:
  161. state: present
  162. name: logging-mux
  163. namespace: "{{ openshift_logging_mux_namespace }}"
  164. kind: dc
  165. files:
  166. - "{{ tempdir }}/templates/logging-mux-dc.yaml"
  167. delete_after: true
  168. # Scale up Mux
  169. - name: Start Mux
  170. oc_scale:
  171. kind: dc
  172. name: "logging-mux"
  173. namespace: "{{ openshift_logging_mux_namespace }}"
  174. replicas: "{{ openshift_logging_mux_replicas | default (1) }}"
  175. - name: Delete temp directory
  176. file:
  177. name: "{{ tempdir }}"
  178. state: absent
  179. changed_when: False