main.yaml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ---
  2. - fail: msg="This role requires the following vars to be defined: master_url, kibana_hostname, es_cluster_size"
  3. when: "kibana_hostname is not defined or
  4. es_cluster_size is not defined or
  5. master_url is not defined"
  6. - name: "Checking for logging project"
  7. command: oc get project logging
  8. register: logging_project
  9. failed_when: "'FAILED' in logging_project.stderr"
  10. tags:
  11. - cleanup
  12. - name: "Create logging project"
  13. command: oadm new-project logging
  14. when: logging_project.rc != 0
  15. tags:
  16. - build
  17. - name: "Changing projects"
  18. command: oc project logging
  19. tags:
  20. - cleanup
  21. - name: "Cleanup any previous logging infrastructure"
  22. command: oc delete all --selector logging-infra={{ item }}
  23. with_items:
  24. - kibana
  25. - fluentd
  26. - elasticsearch
  27. ignore_errors: yes
  28. tags:
  29. - cleanup
  30. - name: "Cleanup existing support infrastructure"
  31. command: oc delete all,sa,oauthclient --selector logging-infra=support
  32. ignore_errors: yes
  33. tags:
  34. - cleanup
  35. - name: "Cleanup existing secrets"
  36. command: oc delete secret logging-fluentd logging-elasticsearch logging-es-proxy logging-kibana logging-kibana-proxy logging-kibana-ops-proxy
  37. ignore_errors: yes
  38. register: clean_result
  39. failed_when: clean_result.rc == 1 and 'not found' not in clean_result.stderr
  40. tags:
  41. - cleanup
  42. - name: "Cleanup existing logging deployers"
  43. command: oc delete pods --all
  44. tags:
  45. - cleanup
  46. - name: "Creating logging deployer secret"
  47. command: oc secrets new logging-deployer {{ logging_secret_vars | default('nothing=/dev/null') }}
  48. register: secret_output
  49. failed_when: "secret_output.rc == 1 and 'exists' not in secret_output.stderr"
  50. tags:
  51. - build
  52. - name: "Copy serviceAccount file"
  53. copy: dest=/tmp/logging-deployer-sa.yaml
  54. src={{role_path}}/files/logging-deployer-sa.yaml
  55. force=yes
  56. tags:
  57. - build
  58. - name: "Create logging-deployer service account"
  59. shell: oc create -f /tmp/logging-deployer-sa.yaml
  60. register: deployer_output
  61. failed_when: "deployer_output.rc == 1 and 'exists' not in deployer_output.stderr"
  62. tags:
  63. - build
  64. - name: "Set permissions for logging-deployer service account"
  65. command: oc policy add-role-to-user edit system:serviceaccount:logging:logging-deployer
  66. register: permiss_output
  67. failed_when: "permiss_output.rc == 1 and 'exists' not in permiss_output.stderr"
  68. tags:
  69. - build
  70. - name: "Set permissions for fluentd"
  71. command: oadm policy add-scc-to-user privileged system:serviceaccount:logging:aggregated-logging-fluentd
  72. register: fluentd_output
  73. failed_when: "fluentd_output.rc == 1 and 'exists' not in fluentd_output.stderr"
  74. tags:
  75. - build
  76. - name: "Set additional permissions for fluentd"
  77. command: oadm policy add-cluster-role-to-user cluster-reader system:serviceaccount:logging:aggregated-logging-fluentd
  78. register: fluentd2_output
  79. failed_when: "fluentd2_output.rc == 1 and 'exists' not in fluentd2_output.stderr"
  80. tags:
  81. - build
  82. - name: "Make sure to remove stale deployer template"
  83. command: oc delete template logging-deployer-template -n openshift
  84. register: delete_ouput
  85. failed_when: delete_ouput.rc == 1 and 'exists' not in delete_ouput.stderr
  86. tags:
  87. - build
  88. - name: "Create deployer template"
  89. command: oc create -f /usr/share/openshift/examples/infrastructure-templates/enterprise/logging-deployer.yaml -n openshift
  90. register: template_output
  91. failed_when: "template_output.rc == 1 and 'exists' not in template_output.stderr"
  92. tags:
  93. - build
  94. - name: "Clear out any previous pods"
  95. command: oc delete pods --all
  96. tags:
  97. - build
  98. - name: "Process the deployer template with an registry other than registry.access.redhat.com"
  99. shell: oc process logging-deployer-template -n openshift -v KIBANA_HOSTNAME={{ kibana_hostname | quote }},ES_CLUSTER_SIZE={{ es_cluster_size | quote }},PUBLIC_MASTER_URL={{ master_url | quote }},IMAGE_PREFIX={{ target_registry | quote }}/ | oc create -f -
  100. when: target_registry is defined
  101. tags:
  102. - build
  103. - name: "Process the default deployer template"
  104. shell: oc process logging-deployer-template -n openshift -v KIBANA_HOSTNAME={{ kibana_hostname | quote }},ES_CLUSTER_SIZE={{ es_cluster_size | quote }},PUBLIC_MASTER_URL={{ master_url | quote }} | oc create -f -
  105. when: target_registry is not defined
  106. tags:
  107. - build
  108. - name: "Wait for image pull and deployer pod"
  109. action: shell oc get pods | grep logging-deployer.*Completed
  110. register: result
  111. until: result.rc == 0
  112. retries: 15
  113. delay: 10
  114. tags:
  115. - build
  116. - name: "Process support template"
  117. shell: oc process logging-support-template | oc create -f -
  118. tags:
  119. - build
  120. - name: "Set insecured registry"
  121. command: oc annotate is --all openshift.io/image.insecureRepository=true --overwrite
  122. when: "target_registry is defined and insecure_registry == 'true'"
  123. tags:
  124. - build
  125. - name: "Scale fluentd deployment config"
  126. command: oc scale dc/logging-fluentd --replicas={{ fluentd_replicas | default('1') }}
  127. tags:
  128. - build
  129. - name: "Wait for imagestreams to become available"
  130. action: shell oc get is | grep logging-fluentd
  131. register: result
  132. until: result.rc == 0
  133. failed_when: result.rc == 1 and 'not found' not in result.stderr
  134. retries: 15
  135. delay: 5
  136. tags:
  137. - build
  138. - name: "Wait for replication controllers to become available"
  139. action: shell oc get rc | grep logging-fluentd-1
  140. register: result
  141. until: result.rc == 0
  142. failed_when: result.rc == 1 and 'not found' not in result.stderr
  143. retries: 15
  144. delay: 5
  145. tags:
  146. - build
  147. - name: "Scale fluentd replication controller"
  148. command: oc scale rc/logging-fluentd-1 --replicas={{ fluentd_replicas | default('1') }}
  149. tags:
  150. - build
  151. - debug: msg="Logging components deployed. Note persistant volume for elasticsearch must be setup manually"
  152. tags:
  153. - build