main.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ---
  2. ######################################################################
  3. # Users, projects, and privileges
  4. - name: Ensure the CFME user exists
  5. oc_user:
  6. state: present
  7. username: "{{ openshift_cfme_user }}"
  8. - name: Ensure the CFME namespace exists with CFME user as admin
  9. oc_project:
  10. state: present
  11. name: "{{ openshift_cfme_project }}"
  12. display_name: "{{ openshift_cfme_project_description }}"
  13. admin: "{{ openshift_cfme_user }}"
  14. - name: Ensure the CFME namespace service account is privileged
  15. oc_adm_policy_user:
  16. namespace: "{{ openshift_cfme_project }}"
  17. user: "{{ openshift_cfme_service_account }}"
  18. resource_kind: scc
  19. resource_name: privileged
  20. state: present
  21. ######################################################################
  22. # NFS
  23. # In the case that we are not running on a cloud provider, volumes must be statically provisioned
  24. - include: nfs.yml
  25. when: not (openshift_cloudprovider_kind is defined and (openshift_cloudprovider_kind == 'aws' or openshift_cloudprovider_kind == 'gce'))
  26. ######################################################################
  27. # CFME App Template
  28. #
  29. # Note, this is different from the create_pvs.yml tasks in that the
  30. # application template does not require any jinja2 evaluation.
  31. #
  32. # TODO: Handle the case where the server template is updated in
  33. # openshift-ansible and the change needs to be landed on the managed
  34. # cluster.
  35. - name: Check if the CFME Server template has been created already
  36. oc_obj:
  37. namespace: "{{ openshift_cfme_project }}"
  38. state: list
  39. kind: template
  40. name: manageiq
  41. register: miq_server_check
  42. - name: Copy over CFME Server template
  43. copy:
  44. src: miq-template.yaml
  45. dest: "{{ template_dir }}/miq-template.yaml"
  46. - name: Ensure the server template was read from disk
  47. debug:
  48. var=r_openshift_cfme_miq_template_content
  49. - name: Ensure CFME Server Template exists
  50. oc_obj:
  51. namespace: "{{ openshift_cfme_project }}"
  52. kind: template
  53. name: "manageiq"
  54. state: present
  55. content: "{{ r_openshift_cfme_miq_template_content }}"
  56. ######################################################################
  57. # Let's do this
  58. - name: Ensure the CFME Server is created
  59. oc_process:
  60. namespace: "{{ openshift_cfme_project }}"
  61. template_name: manageiq
  62. create: True
  63. params:
  64. APPLICATION_IMG_NAME: "{{ openshift_cfme_application_img_name }}"
  65. POSTGRESQL_IMG_NAME: "{{ openshift_cfme_postgresql_img_name }}"
  66. MEMCACHED_IMG_NAME: "{{ openshift_cfme_memcached_img_name }}"
  67. APPLICATION_IMG_TAG: "{{ openshift_cfme_application_img_tag }}"
  68. POSTGRESQL_IMG_TAG: "{{ openshift_cfme_postgresql_img_tag }}"
  69. MEMCACHED_IMG_TAG: "{{ openshift_cfme_memcached_img_tag }}"
  70. register: cfme_new_app_process
  71. run_once: True
  72. when:
  73. # User said to install CFME in their inventory
  74. - openshift_cfme_install_app | bool
  75. # # The server app doesn't exist already
  76. # - not miq_server_check.results.results.0
  77. - debug:
  78. var: cfme_new_app_process
  79. ######################################################################
  80. # Various cleanup steps
  81. # TODO: Not sure what to do about this right now. Might be able to
  82. # just delete it? This currently warns about "Unable to find
  83. # '<TEMP_DIR>' in expected paths."
  84. - name: Ensure the temporary PV/App templates are erased
  85. file:
  86. path: "{{ item }}"
  87. state: absent
  88. with_fileglob:
  89. - "{{ template_dir }}/*.yaml"
  90. - name: Ensure the temporary PV/app template directory is erased
  91. file:
  92. path: "{{ template_dir }}"
  93. state: absent
  94. ######################################################################
  95. - name: Status update
  96. debug:
  97. msg: >
  98. CFME has been deployed. Note that there will be a delay before
  99. it is fully initialized.