registry_auth.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. ---
  2. # We need to setup some variables as this play might be called directly
  3. # from outside of the role.
  4. - set_fact:
  5. oreg_auth_credentials_path: "{{ r_openshift_master_data_dir }}/.docker"
  6. when: oreg_auth_credentials_path is not defined
  7. - set_fact:
  8. oreg_host: "{{ oreg_url.split('/')[0] if (oreg_url is defined and '.' in oreg_url.split('/')[0]) else '' }}"
  9. when: oreg_host is not defined
  10. - name: Check for credentials file for registry auth
  11. stat:
  12. path: "{{ oreg_auth_credentials_path }}"
  13. when: oreg_auth_user is defined
  14. register: master_oreg_auth_credentials_stat
  15. - name: Create credentials for registry auth
  16. command: "docker --config={{ oreg_auth_credentials_path }} login -u {{ oreg_auth_user }} -p {{ oreg_auth_password }} {{ oreg_host }}"
  17. when:
  18. - oreg_auth_user is defined
  19. - (not master_oreg_auth_credentials_stat.stat.exists or oreg_auth_credentials_replace) | bool
  20. register: master_oreg_auth_credentials_create
  21. notify:
  22. - restart master api
  23. - restart master controllers
  24. # Container images may need the registry credentials
  25. - name: Setup ro mount of /root/.docker for containerized hosts
  26. set_fact:
  27. l_bind_docker_reg_auth: True
  28. when:
  29. - openshift.common.is_containerized | bool
  30. - oreg_auth_user is defined
  31. - (master_oreg_auth_credentials_stat.stat.exists or oreg_auth_credentials_replace or master_oreg_auth_credentials_create.changed) | bool