main.yaml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ---
  2. - include: determine_version.yaml
  3. # allow passing in a tempdir
  4. - name: Create temp directory for doing work in
  5. command: mktemp -d /tmp/openshift-logging-ansible-XXXXXX
  6. register: mktemp
  7. changed_when: False
  8. - set_fact:
  9. tempdir: "{{ mktemp.stdout }}"
  10. # This may not be necessary in this role
  11. - name: Create templates subdirectory
  12. file:
  13. state: directory
  14. path: "{{ tempdir }}/templates"
  15. mode: 0755
  16. changed_when: False
  17. # we want to make sure we have all the necessary components here
  18. # service account
  19. - name: Create Curator service account
  20. oc_serviceaccount:
  21. state: present
  22. name: "aggregated-logging-curator"
  23. namespace: "{{ openshift_logging_namespace }}"
  24. image_pull_secrets: "{{ openshift_logging_image_pull_secret }}"
  25. when: openshift_logging_image_pull_secret != ''
  26. - name: Create Curator service account
  27. oc_serviceaccount:
  28. state: present
  29. name: "aggregated-logging-curator"
  30. namespace: "{{ openshift_logging_namespace }}"
  31. when:
  32. - openshift_logging_image_pull_secret == ''
  33. # configmap
  34. - copy:
  35. src: curator.yml
  36. dest: "{{ tempdir }}/curator.yml"
  37. when: curator_config_contents is undefined
  38. changed_when: no
  39. - copy:
  40. content: "{{ curator_config_contents }}"
  41. dest: "{{ tempdir }}/curator.yml"
  42. when: curator_config_contents is defined
  43. changed_when: no
  44. - name: Set Curator configmap
  45. oc_configmap:
  46. state: present
  47. name: "logging-curator"
  48. namespace: "{{ openshift_logging_namespace }}"
  49. from_file:
  50. config.yaml: "{{ tempdir }}/curator.yml"
  51. # secret
  52. - name: Set Curator secret
  53. oc_secret:
  54. state: present
  55. name: "logging-curator"
  56. namespace: "{{ openshift_logging_namespace }}"
  57. files:
  58. - name: ca
  59. path: "{{ generated_certs_dir }}/ca.crt"
  60. - name: key
  61. path: "{{ generated_certs_dir }}/system.logging.curator.key"
  62. - name: cert
  63. path: "{{ generated_certs_dir }}/system.logging.curator.crt"
  64. - set_fact:
  65. curator_name: "{{ 'logging-curator' ~ ( (openshift_logging_curator_ops_deployment | default(false) | bool) | ternary('-ops', '') ) }}"
  66. curator_component: "{{ 'curator' ~ ( (openshift_logging_curator_ops_deployment | default(false) | bool) | ternary('-ops', '') ) }}"
  67. # DC
  68. # TODO: scale should not exceed 1
  69. - name: Generate Curator deploymentconfig
  70. template:
  71. src: curator.j2
  72. dest: "{{ tempdir }}/templates/curator-dc.yaml"
  73. vars:
  74. component: "{{ curator_component }}"
  75. logging_component: curator
  76. deploy_name: "{{ curator_name }}"
  77. image: "{{openshift_logging_curator_image_prefix}}logging-curator:{{openshift_logging_curator_image_version}}"
  78. es_host: "{{ openshift_logging_curator_es_host }}"
  79. es_port: "{{ openshift_logging_curator_es_port }}"
  80. curator_cpu_limit: "{{ openshift_logging_curator_cpu_limit }}"
  81. curator_cpu_request: "{{ openshift_logging_curator_cpu_request | min_cpu(openshift_logging_curator_cpu_limit | default(none)) }}"
  82. curator_memory_limit: "{{ openshift_logging_curator_memory_limit }}"
  83. curator_replicas: "{{ openshift_logging_curator_replicas | default (1) }}"
  84. curator_node_selector: "{{openshift_logging_curator_nodeselector | default({})}}"
  85. check_mode: no
  86. changed_when: no
  87. - name: Set Curator DC
  88. oc_obj:
  89. state: present
  90. name: "{{ curator_name }}"
  91. namespace: "{{ openshift_logging_namespace }}"
  92. kind: dc
  93. files:
  94. - "{{ tempdir }}/templates/curator-dc.yaml"
  95. delete_after: true
  96. - name: Delete temp directory
  97. file:
  98. name: "{{ tempdir }}"
  99. state: absent
  100. changed_when: False