main.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. # Service settings
  23. - name: Ensure bulk image import limit is tuned
  24. yedit:
  25. src: /etc/origin/master/master-config.yaml
  26. key: 'imagePolicyConfig.maxImagesBulkImportedPerRepository'
  27. value: "{{ openshift_cfme_maxImagesBulkImportedPerRepository | int() }}"
  28. state: present
  29. backup: True
  30. register: master_config_updated
  31. notify:
  32. - restart master
  33. - meta: flush_handlers
  34. ######################################################################
  35. # NFS
  36. - name: Ensure the /exports/ directory exists
  37. file:
  38. path: /exports/
  39. state: directory
  40. mode: 0755
  41. owner: root
  42. group: root
  43. - name: Ensure the miq-pv0X export directories exist
  44. file:
  45. path: "/exports/{{ item }}"
  46. state: directory
  47. mode: 0775
  48. owner: root
  49. group: root
  50. with_items: "{{ openshift_cfme_pv_exports }}"
  51. - name: Ensure the NFS exports for CFME PVs exist
  52. copy:
  53. src: openshift_cfme.exports
  54. dest: /etc/exports.d/openshift_cfme.exports
  55. register: nfs_exports_updated
  56. - name: Ensure the NFS export table is refreshed if exports were added
  57. command: exportfs -ar
  58. when:
  59. - nfs_exports_updated.changed
  60. ######################################################################
  61. # Create the required CFME PVs. Check out these online docs if you
  62. # need a refresher on includes looping with items:
  63. # * http://docs.ansible.com/ansible/playbooks_loops.html#loops-and-includes-in-2-0
  64. # * http://stackoverflow.com/a/35128533
  65. #
  66. # TODO: Handle the case where a PV template is updated in
  67. # openshift-ansible and the change needs to be landed on the managed
  68. # cluster.
  69. - include: create_pvs.yml
  70. with_items: "{{ openshift_cfme_pv_data }}"
  71. ######################################################################
  72. # CFME App Template
  73. #
  74. # Note, this is different from the create_pvs.yml tasks in that the
  75. # application template does not require any jinja2 evaluation.
  76. #
  77. # TODO: Handle the case where the server template is updated in
  78. # openshift-ansible and the change needs to be landed on the managed
  79. # cluster.
  80. - name: Check if the CFME Server template has been created already
  81. oc_obj:
  82. namespace: "{{ openshift_cfme_project }}"
  83. state: list
  84. kind: template
  85. name: manageiq
  86. register: miq_server_check
  87. - name: Copy over CFME Server template
  88. copy:
  89. src: miq-template.yaml
  90. dest: "{{ template_dir }}/miq-template.yaml"
  91. - name: Ensure the server template was read from disk
  92. debug:
  93. var=r_openshift_cfme_miq_template_content
  94. - name: Ensure CFME Server Template exists
  95. oc_obj:
  96. namespace: "{{ openshift_cfme_project }}"
  97. kind: template
  98. name: "manageiq"
  99. state: present
  100. content: "{{ r_openshift_cfme_miq_template_content }}"
  101. ######################################################################
  102. # Let's do this
  103. - name: Ensure the CFME Server is created
  104. oc_process:
  105. namespace: "{{ openshift_cfme_project }}"
  106. template_name: manageiq
  107. create: True
  108. register: cfme_new_app_process
  109. run_once: True
  110. when:
  111. # User said to install CFME in their inventory
  112. - openshift_cfme_install_app | bool
  113. # # The server app doesn't exist already
  114. # - not miq_server_check.results.results.0
  115. - debug:
  116. var: cfme_new_app_process
  117. ######################################################################
  118. # Various cleanup steps
  119. # TODO: Not sure what to do about this right now. Might be able to
  120. # just delete it? This currently warns about "Unable to find
  121. # '<TEMP_DIR>' in expected paths."
  122. - name: Ensure the temporary PV/App templates are erased
  123. file:
  124. path: "{{ item }}"
  125. state: absent
  126. with_fileglob:
  127. - "{{ template_dir }}/*.yaml"
  128. - name: Ensure the temporary PV/app template directory is erased
  129. file:
  130. path: "{{ template_dir }}"
  131. state: absent
  132. ######################################################################
  133. - name: Status update
  134. debug:
  135. msg: >
  136. CFME has been deployed. Note that there will be a delay before
  137. it is fully initialized.