deploy_logging.yaml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. ---
  2. - debug: msg="WARNING target_registry is deprecated, use openshift_hosted_logging_image_prefix instead"
  3. when: target_registry is defined and target_registry
  4. - fail: msg="This role requires the following vars to be defined. openshift_hosted_logging_master_public_url, openshift_hosted_logging_hostname, openshift_hosted_logging_elasticsearch_cluster_size"
  5. when: "openshift_hosted_logging_hostname is not defined or
  6. openshift_hosted_logging_elasticsearch_cluster_size is not defined or
  7. openshift_hosted_logging_master_public_url is not defined"
  8. - name: Create temp directory for kubeconfig
  9. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  10. register: mktemp
  11. changed_when: False
  12. - name: Copy the admin client config(s)
  13. command: >
  14. cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  15. changed_when: False
  16. - name: Check for logging project already exists
  17. command: >
  18. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get project logging -o jsonpath='{.metadata.name}'
  19. register: logging_project_result
  20. ignore_errors: True
  21. - name: "Create logging project"
  22. command: >
  23. {{ openshift.common.admin_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig new-project logging
  24. when: logging_project_result.stdout == ""
  25. - name: "Changing projects"
  26. command: >
  27. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig project logging
  28. - name: "Creating logging deployer secret"
  29. command: >
  30. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig secrets new logging-deployer {{ openshift_hosted_logging_secret_vars | default('nothing=/dev/null') }}
  31. register: secret_output
  32. failed_when: "secret_output.rc == 1 and 'exists' not in secret_output.stderr"
  33. - name: "Create templates for logging accounts and the deployer"
  34. command: >
  35. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f {{ examples_base }}/infrastructure-templates/{{ 'enterprise' if openshift_deployment_type == 'openshift-enterprise' else 'origin' }}/logging-deployer.yaml
  36. register: template_output
  37. failed_when: "template_output.rc == 1 and 'exists' not in template_output.stderr"
  38. - name: "Process the logging accounts template"
  39. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig process logging-deployer-account-template | {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f -"
  40. register: process_deployer_accounts
  41. failed_when: process_deployer_accounts.rc == 1 and 'already exists' not in process_deployer_accounts.stderr
  42. - name: "Set permissions for logging-deployer service account"
  43. command: >
  44. {{ openshift.common.admin_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig policy add-cluster-role-to-user oauth-editor system:serviceaccount:logging:logging-deployer
  45. register: permiss_output
  46. failed_when: "permiss_output.rc == 1 and 'exists' not in permiss_output.stderr"
  47. - name: "Set permissions for fluentd"
  48. command: >
  49. {{ openshift.common.admin_binary}} policy add-scc-to-user privileged system:serviceaccount:logging:aggregated-logging-fluentd
  50. register: fluentd_output
  51. failed_when: "fluentd_output.rc == 1 and 'exists' not in fluentd_output.stderr"
  52. - name: "Set additional permissions for fluentd"
  53. command: >
  54. {{ openshift.common.admin_binary}} policy add-cluster-role-to-user cluster-reader system:serviceaccount:logging:aggregated-logging-fluentd
  55. register: fluentd2_output
  56. failed_when: "fluentd2_output.rc == 1 and 'exists' not in fluentd2_output.stderr"
  57. - name: "Create ConfigMap for deployer parameters"
  58. command: >
  59. {{ openshift.common.client_binary}} --config={{ mktemp.stdout }}/admin.kubeconfig create configmap logging-deployer {{ deployer_cmap_params }}
  60. register: deployer_configmap_output
  61. failed_when: "deployer_configmap_output.rc == 1 and 'exists' not in deployer_configmap_output.stderr"
  62. - name: "Process the deployer template"
  63. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig new-app logging-deployer-template {{ oc_new_app_values }}"
  64. register: process_deployer
  65. failed_when: process_deployer.rc == 1 and 'already exists' not in process_deployer.stderr
  66. - name: "Wait for image pull and deployer pod"
  67. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get pods | grep logging-deployer.*Completed"
  68. register: result
  69. until: result.rc == 0
  70. retries: 20
  71. delay: 15
  72. - name: "Process imagestream template"
  73. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig new-app logging-imagestream-template {{ oc_new_app_values }}"
  74. when: tr_or_ohlip is defined and insecure_registry is defined and insecure_registry
  75. register: process_is
  76. failed_when: process_is.rc == 1 and 'already exists' not in process_is.stderr
  77. - name: "Set insecured registry"
  78. command: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig annotate is --all openshift.io/image.insecureRepository=true --overwrite"
  79. when: tr_or_ohlip is defined and insecure_registry is defined and insecure_registry
  80. - name: "Wait for imagestreams to become available"
  81. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get is | grep logging-fluentd"
  82. when: tr_or_ohlip is defined and insecure_registry is defined and insecure_registry
  83. register: result
  84. until: result.rc == 0
  85. failed_when: result.rc == 1 and 'not found' not in result.stderr
  86. retries: 20
  87. delay: 5
  88. - name: "Wait for component pods to be running"
  89. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get pods -l component={{ item }} | grep Running"
  90. with_items:
  91. - es
  92. - kibana
  93. - curator
  94. register: result
  95. until: result.rc == 0
  96. failed_when: result.rc == 1 or 'Error' in result.stderr
  97. retries: 20
  98. delay: 15
  99. - name: "Wait for ops component pods to be running"
  100. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get pods -l component={{ item }} | grep Running"
  101. with_items:
  102. - es-ops
  103. - kibana-ops
  104. - curator-ops
  105. when: openshift_hosted_logging_enable_ops_cluster is defined and openshift_hosted_logging_enable_ops_cluster
  106. register: result
  107. until: result.rc == 0
  108. failed_when: result.rc == 1 or 'Error' in result.stderr
  109. retries: 20
  110. delay: 15
  111. - name: "Wait for fluentd DaemonSet to exist"
  112. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get daemonset logging-fluentd"
  113. register: result
  114. until: result.rc == 0
  115. failed_when: result.rc == 1 or 'Error' in result.stderr
  116. retries: 20
  117. delay: 5
  118. - name: "Deploy fluentd by labeling the node"
  119. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig label node --overwrite=true {{ '-l openshift_hosted_logging_fluentd_nodeselector' if openshift_hosted_logging_fluentd_nodeselector is defined else '--all' }} {{ openshift_hosted_logging_fluentd_nodeselector_label if openshift_hosted_logging_fluentd_nodeselector_label is defined else 'logging-infra-fluentd=true' }}"
  120. - name: "Wait for fluentd to be running"
  121. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get pods -l component=fluentd | grep Running"
  122. register: result
  123. until: result.rc == 0
  124. failed_when: result.rc == 1 or 'Error' in result.stderr
  125. retries: 20
  126. delay: 15
  127. - debug:
  128. msg: "Logging components deployed. Note persistent volume for elasticsearch must be setup manually"
  129. - name: Delete temp directory
  130. file:
  131. name: "{{ mktemp.stdout }}"
  132. state: absent
  133. changed_when: False