summaryrefslogtreecommitdiffstats
path: root/roles/container_runtime/tasks/registry_auth.yml
blob: 4f1abd59a6a13259e1bfd32eb91e5f526f2a01e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
- name: Check for credentials file for registry auth
  stat:
    path: "{{ docker_cli_auth_config_path }}/config.json"
  when: oreg_auth_user is defined
  register: docker_cli_auth_credentials_stat

- name: Create credentials for docker cli registry auth
  command: "docker --config={{ docker_cli_auth_config_path }} login -u {{ oreg_auth_user }} -p {{ oreg_auth_password }} {{ oreg_host }}"
  register: openshift_docker_credentials_create_res
  retries: 3
  delay: 5
  until: openshift_docker_credentials_create_res.rc == 0
  when:
  - not openshift_docker_alternative_creds | bool
  - oreg_auth_user is defined
  - (not docker_cli_auth_credentials_stat.stat.exists or oreg_auth_credentials_replace) | bool
  no_log: True

# docker_creds is a custom module from lib_utils
# 'docker login' requires a docker.service running on the local host, this is an
# alternative implementation for non-docker hosts.  This implementation does not
# check the registry to determine whether or not the credentials will work.
- name: Create credentials for docker cli registry auth (alternative)
  docker_creds:
    path: "{{ docker_cli_auth_config_path }}"
    registry: "{{ oreg_host }}"
    username: "{{ oreg_auth_user }}"
    password: "{{ oreg_auth_password }}"
  when:
  - openshift_docker_alternative_creds | bool
  - oreg_auth_user is defined
  - (not docker_cli_auth_credentials_stat.stat.exists or oreg_auth_credentials_replace) | bool
  no_log: True