main.yaml 4.1 KB

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