deploy_logging.yaml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ---
  2. - 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"
  3. when: "openshift_hosted_logging_hostname is not defined or
  4. openshift_hosted_logging_elasticsearch_cluster_size is not defined or
  5. openshift_hosted_logging_master_public_url is not defined"
  6. - name: Create temp directory for kubeconfig
  7. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  8. register: mktemp
  9. changed_when: False
  10. - name: Copy the admin client config(s)
  11. command: >
  12. cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  13. changed_when: False
  14. - name: "Create logging project"
  15. command: >
  16. {{ openshift.common.admin_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig new-project logging
  17. - name: "Changing projects"
  18. command: >
  19. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig project logging
  20. - name: "Creating logging deployer secret"
  21. command: >
  22. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig secrets new logging-deployer {{ openshift_hosted_logging_secret_vars | default('nothing=/dev/null') }}
  23. register: secret_output
  24. failed_when: "secret_output.rc == 1 and 'exists' not in secret_output.stderr"
  25. - name: "Copy serviceAccount file"
  26. copy:
  27. dest: /tmp/logging-deployer-sa.yaml
  28. src: "{{role_path}}/files/logging-deployer-sa.yaml"
  29. force: yes
  30. - name: "Create logging-deployer service account"
  31. command: >
  32. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f /tmp/logging-deployer-sa.yaml
  33. register: deployer_output
  34. failed_when: "deployer_output.rc == 1 and 'exists' not in deployer_output.stderr"
  35. - name: "Set permissions for logging-deployer service account"
  36. command: >
  37. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig policy add-role-to-user edit system:serviceaccount:logging:logging-deployer
  38. register: permiss_output
  39. failed_when: "permiss_output.rc == 1 and 'exists' not in permiss_output.stderr"
  40. - name: "Set permissions for fluentd"
  41. command: >
  42. {{ openshift.common.admin_binary}} policy add-scc-to-user privileged system:serviceaccount:logging:aggregated-logging-fluentd
  43. register: fluentd_output
  44. failed_when: "fluentd_output.rc == 1 and 'exists' not in fluentd_output.stderr"
  45. - name: "Set additional permissions for fluentd"
  46. command: >
  47. {{ openshift.common.admin_binary}} policy add-cluster-role-to-user cluster-reader system:serviceaccount:logging:aggregated-logging-fluentd
  48. register: fluentd2_output
  49. failed_when: "fluentd2_output.rc == 1 and 'exists' not in fluentd2_output.stderr"
  50. - name: "Create deployer template"
  51. command: >
  52. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f /usr/share/openshift/examples/infrastructure-templates/enterprise/logging-deployer.yaml -n openshift
  53. register: template_output
  54. failed_when: "template_output.rc == 1 and 'exists' not in template_output.stderr"
  55. - name: "Process the deployer template"
  56. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig process logging-deployer-template -n openshift -v {{ oc_process_values }} | {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f -"
  57. - name: "Wait for image pull and deployer pod"
  58. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get pods | grep logging-deployer.*Completed"
  59. register: result
  60. until: result.rc == 0
  61. retries: 15
  62. delay: 10
  63. - name: "Process support template"
  64. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig process logging-support-template | {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f -"
  65. - name: "Set insecured registry"
  66. command: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig annotate is --all openshift.io/image.insecureRepository=true --overwrite"
  67. when: "target_registry is defined and insecure_registry == 'true'"
  68. - name: "Wait for imagestreams to become available"
  69. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get is | grep logging-fluentd"
  70. register: result
  71. until: result.rc == 0
  72. failed_when: result.rc == 1 and 'not found' not in result.stderr
  73. retries: 20
  74. delay: 10
  75. - name: "Wait for replication controllers to become available"
  76. shell: "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get rc | grep logging-fluentd-1"
  77. register: result
  78. until: result.rc == 0
  79. failed_when: result.rc == 1 and 'not found' not in result.stderr
  80. retries: 20
  81. delay: 10
  82. - name: "Scale fluentd deployment config"
  83. command: >
  84. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig scale dc/logging-fluentd --replicas={{ fluentd_replicas | default('1') }}
  85. - debug:
  86. msg: "Logging components deployed. Note persistant volume for elasticsearch must be setup manually"
  87. - name: Delete temp directory
  88. file:
  89. name: "{{ mktemp.stdout }}"
  90. state: absent
  91. changed_when: False