add_container_provider.yml 2.0 KB

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