add_container_provider.yml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ---
  2. - name: Ensure OpenShift facts module is available
  3. import_role:
  4. role: openshift_facts
  5. - name: Ensure OpenShift facts are loaded
  6. openshift_facts:
  7. - name: Ensure we use openshift_master_cluster_public_hostname if it is available
  8. set_fact:
  9. l_cluster_hostname: "{{ openshift.master.cluster_public_hostname }}"
  10. when:
  11. - openshift.master.cluster_public_hostname is defined
  12. - name: Ensure we default to the first master if openshift_master_cluster_public_hostname is unavailable
  13. set_fact:
  14. l_cluster_hostname: "{{ openshift.master.cluster_hostname }}"
  15. when:
  16. - l_cluster_hostname is not defined
  17. - name: Ensure the management SA Secrets are read
  18. oc_serviceaccount_secret:
  19. state: list
  20. service_account: management-admin
  21. namespace: management-infra
  22. register: sa
  23. - name: Ensure the management SA bearer token is identified
  24. set_fact:
  25. management_token: "{{ sa.results | lib_utils_oo_filter_sa_secrets }}"
  26. - name: Ensure the SA bearer token value is read
  27. oc_secret:
  28. state: list
  29. name: "{{ management_token }}"
  30. namespace: management-infra
  31. decode: true
  32. no_log: True
  33. register: sa_secret
  34. - name: Ensure the SA bearer token value is saved
  35. set_fact:
  36. management_bearer_token: "{{ sa_secret.results.decoded.token }}"
  37. - name: Ensure we have the public route to the management service
  38. oc_route:
  39. state: list
  40. name: httpd
  41. namespace: openshift-management
  42. register: route
  43. - name: Ensure the management service route is saved
  44. set_fact:
  45. management_route: "{{ route.results.0.spec.host }}"
  46. - name: Ensure this cluster is a container provider
  47. uri:
  48. url: "https://{{ management_route }}/api/providers"
  49. body_format: json
  50. method: POST
  51. user: "{{ openshift_management_username }}"
  52. password: "{{ openshift_management_password }}"
  53. validate_certs: no
  54. # Docs on formatting the BODY of the POST request:
  55. # http://manageiq.org/docs/reference/latest/api/reference/providers.html#specifying-connection-configurations
  56. body:
  57. connection_configurations:
  58. - authentication: {auth_key: "{{ management_bearer_token }}", authtype: bearer, type: AuthToken}
  59. endpoint: {role: default, security_protocol: ssl-without-validation, verify_ssl: 0}
  60. hostname: "{{ l_cluster_hostname }}"
  61. name: "{{ openshift_management_project }}"
  62. port: "{{ openshift.master.api_port }}"
  63. type: "ManageIQ::Providers::Openshift::ContainerManager"