Skip to content

Instantly share code, notes, and snippets.

@patrickmslatteryvt
Last active February 23, 2017 22:55
Show Gist options
  • Save patrickmslatteryvt/97c8140d79f0161be53fc65b872f23c6 to your computer and use it in GitHub Desktop.
Save patrickmslatteryvt/97c8140d79f0161be53fc65b872f23c6 to your computer and use it in GitHub Desktop.
docker_login until failures
# Task
- name: "Log into hub.docker.com"
become: yes
become_user: automation
docker_login:
username: "{{ docker_hub_username }}"
password: "{{ docker_hub_password }}"
email: "{{ docker_hub_email }}"
register: docker_login_result
# until: docker_login_result.login_result.Status == "Login Succeeded"
until: docker_login_result.find("Login Succeeded") != -1
retries: 10
delay: 15
# On success
changed: [host.domain.com] => {
"attempts": 1,
"changed": true,
"invocation": {
"module_args": {
"api_version": null,
"cacert_path": null,
"cert_path": null,
"config_path": "~/.docker/config.json",
"debug": false,
"docker_host": null,
"email": "user@domain.com",
"filter_logger": false,
"key_path": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"reauthorize": false,
"registry_url": "https://index.docker.io/v1/",
"ssl_version": null,
"state": "present",
"timeout": null,
"tls": null,
"tls_hostname": null,
"tls_verify": null,
"username": "user"
}
},
"login_result": {
"IdentityToken": "",
"Status": "Login Succeeded"
}
}
# On failure
fatal: [hostname.domain.com]: FAILED! => {
"failed": true,
"msg": "The conditional check 'docker_login_result.login_result.Status == \"Login Succeeded\"' failed.
The error was: error while evaluating conditional (docker_login_result.login_result.Status == \"Login Succeeded\"):
'dict object' has no attribute 'login_result'"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment