install_fluentd.yaml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ---
  2. - set_fact: fluentd_ops_host={{ (openshift_logging_use_ops | bool) | ternary(openshift_logging_es_ops_host, openshift_logging_es_host) }}
  3. check_mode: no
  4. - set_fact: fluentd_ops_port={{ (openshift_logging_use_ops | bool) | ternary(openshift_logging_es_ops_port, openshift_logging_es_port) }}
  5. check_mode: no
  6. - name: Generating Fluentd daemonset
  7. template: src=fluentd.j2 dest={{mktemp.stdout}}/templates/logging-fluentd.yaml
  8. vars:
  9. daemonset_name: logging-fluentd
  10. daemonset_component: fluentd
  11. daemonset_container_name: fluentd-elasticsearch
  12. daemonset_serviceAccount: aggregated-logging-fluentd
  13. ops_host: "{{ fluentd_ops_host }}"
  14. ops_port: "{{ fluentd_ops_port }}"
  15. fluentd_nodeselector_key: "{{openshift_logging_fluentd_nodeselector.keys()[0]}}"
  16. fluentd_nodeselector_value: "{{openshift_logging_fluentd_nodeselector.values()[0]}}"
  17. check_mode: no
  18. changed_when: no
  19. - name: "Check fluentd privileged permissions"
  20. command: >
  21. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  22. get scc/privileged -o jsonpath='{.users}'
  23. register: fluentd_privileged
  24. check_mode: no
  25. changed_when: no
  26. - name: "Set privileged permissions for fluentd"
  27. command: >
  28. {{ openshift.common.admin_binary}} --config={{ mktemp.stdout }}/admin.kubeconfig policy
  29. add-scc-to-user privileged system:serviceaccount:{{openshift_logging_namespace}}:aggregated-logging-fluentd
  30. register: fluentd_output
  31. failed_when: fluentd_output.rc == 1 and 'exists' not in fluentd_output.stderr
  32. check_mode: no
  33. when: fluentd_privileged.stdout.find("system:serviceaccount:{{openshift_logging_namespace}}:aggregated-logging-fluentd") == -1
  34. - name: "Check fluentd cluster-reader permissions"
  35. command: >
  36. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  37. get clusterrolebinding/cluster-readers -o jsonpath='{.userNames}'
  38. register: fluentd_cluster_reader
  39. check_mode: no
  40. changed_when: no
  41. - name: "Set cluster-reader permissions for fluentd"
  42. command: >
  43. {{ openshift.common.admin_binary}} --config={{ mktemp.stdout }}/admin.kubeconfig policy
  44. add-cluster-role-to-user cluster-reader system:serviceaccount:{{openshift_logging_namespace}}:aggregated-logging-fluentd
  45. register: fluentd2_output
  46. failed_when: fluentd2_output.rc == 1 and 'exists' not in fluentd2_output.stderr
  47. check_mode: no
  48. when: fluentd_cluster_reader.stdout.find("system:serviceaccount:{{openshift_logging_namespace}}:aggregated-logging-fluentd") == -1