main.yaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. when: curator_config_contents is undefined
  49. changed_when: no
  50. - copy:
  51. content: "{{ curator_config_contents }}"
  52. dest: "{{ tempdir }}/curator.yml"
  53. when: curator_config_contents is defined
  54. changed_when: no
  55. - name: Set Curator configmap
  56. oc_configmap:
  57. state: present
  58. name: "logging-curator"
  59. namespace: "{{ openshift_logging_namespace }}"
  60. from_file:
  61. config.yaml: "{{ tempdir }}/curator.yml"
  62. # secret
  63. - name: Set Curator secret
  64. oc_secret:
  65. state: present
  66. name: "logging-curator"
  67. namespace: "{{ openshift_logging_namespace }}"
  68. files:
  69. - name: ca
  70. path: "{{ generated_certs_dir }}/ca.crt"
  71. - name: key
  72. path: "{{ generated_certs_dir }}/system.logging.curator.key"
  73. - name: cert
  74. path: "{{ generated_certs_dir }}/system.logging.curator.crt"
  75. - set_fact:
  76. curator_name: "{{ 'logging-curator' ~ ( (openshift_logging_curator_ops_deployment | default(false) | bool) | ternary('-ops', '') ) }}"
  77. curator_component: "{{ 'curator' ~ ( (openshift_logging_curator_ops_deployment | default(false) | bool) | ternary('-ops', '') ) }}"
  78. # DC
  79. # TODO: scale should not exceed 1
  80. - name: Generate Curator deploymentconfig
  81. template:
  82. src: curator.j2
  83. dest: "{{ tempdir }}/templates/curator-dc.yaml"
  84. vars:
  85. component: "{{ curator_component }}"
  86. logging_component: curator
  87. deploy_name: "{{ curator_name }}"
  88. image: "{{openshift_logging_curator_image_prefix}}logging-curator:{{openshift_logging_curator_image_version}}"
  89. es_host: "{{ openshift_logging_curator_es_host }}"
  90. es_port: "{{ openshift_logging_curator_es_port }}"
  91. curator_cpu_limit: "{{ openshift_logging_curator_cpu_limit }}"
  92. curator_cpu_request: "{{ openshift_logging_curator_cpu_request | min_cpu(openshift_logging_curator_cpu_limit | default(none)) }}"
  93. curator_memory_limit: "{{ openshift_logging_curator_memory_limit }}"
  94. curator_replicas: "{{ openshift_logging_curator_replicas | default (1) }}"
  95. curator_node_selector: "{{openshift_logging_curator_nodeselector | default({})}}"
  96. check_mode: no
  97. changed_when: no
  98. - name: Set Curator DC
  99. oc_obj:
  100. state: present
  101. name: "{{ curator_name }}"
  102. namespace: "{{ openshift_logging_namespace }}"
  103. kind: dc
  104. files:
  105. - "{{ tempdir }}/templates/curator-dc.yaml"
  106. delete_after: true
  107. - name: Delete temp directory
  108. file:
  109. name: "{{ tempdir }}"
  110. state: absent
  111. changed_when: False