I trying to get a list of Docker images tags from Docker Hub using Ansible, this is how it works using curl
:
curl --silent --get --data-urlencode "service=registry.docker.io" \
--data-urlencode "scope=repository:onlyoffice/documentserver-ee:pull" \
https://auth.docker.io/token | jq -r '.token'
The above returns a ${TOKEN}
than can be used for a second request:
curl -s --header "Authorization: Bearer ${TOKEN}" \
https://registry.hub.docker.com/v2/onlyoffice/documentserver-ee/tags/list \
| jq
The above returns JSON:
{
"name": "onlyoffice/documentserver-ee",
"tags": [
"3.5.0-199",
"5.6",
"5.6.4",
"5.6.4.20",
"5.6.5",
"5.6.5.3",
"6.0",
"6.0.0",
"6.0.0.105",
"6.0.1",
"6.0.1.32",
"6.0.2",
"6.0.2.5",
"6.1",
"6.1.0",
"6.1.0.83",
"6.1.1",
"6.1.1.53",
"6.2",
"6.2.0",
"6.2.0.123",
"6.2.1",
"6.2.1.24",
"6.2.2",
"6.2.2.21",
"6.3",
"6.3.0",
"6.3.0.111",
"6.3.1",
"6.3.1.32",
"6.3.2",
"6.3.2.2",
"6.4",
"6.4.0",
"6.4.0.121",
"6.4.1",
"6.4.1.45",
"6.4.2",
"6.4.2.6",
"7.0",
"7.0.0",
"7.0.0.132",
"7.0.1",
"7.0.1.37",
"7.1",
"7.1.0",
"7.1.0.215",
"7.1.1",
"7.1.1.23",
"7.2",
"7.2.0",
"7.2.0.204",
"7.2.1",
"7.2.1.34",
"7.2.2",
"7.2.2.56",
"7.3",
"7.3.0",
"7.3.0.184",
"7.3.2",
"7.3.2.8",
"7.3.3",
"7.3.3.50",
"7.4",
"7.4.0",
"7.4.0.1",
"7.4.1",
"7.4.1.1",
"7.5",
"7.5.0",
"7.5.0.1",
"7.5.1",
"7.5.1.1",
"latest",
"latest-arm64"
]
}
However if I try to replicate this using the ansible.builtin.uri module it fails:
- name: Get a Authorization token from auth.docker.io for onlyoffice/documentserver-ee
ansible.builtin.uri:
url: https://auth.docker.io/token
method: GET
body_format: form-urlencoded
body:
service: "registry.docker.io"
scope: "repository:onlyoffice/documentserver-ee:pull"
return_content: true
check_mode: false
changed_when: false
register: workspace_docker_hub_documentserver_ee_auth
- name: Debug workspace_docker_hub_documentserver_ee_auth
ansible.builtin.debug:
var: workspace_docker_hub_documentserver_ee_auth
verbosity: "{% if ansible_check_mode | bool %}0{% else %}1{% endif %}"
- name: Get the tag list for onlyoffice/documentserver-ee
ansible.builtin.uri:
url: https://registry.hub.docker.com/v2/onlyoffice/documentserver-ee/tags/list
method: GET
force_basic_auth: false
use_netrc: false
headers:
Authorization: "Bearer {{ workspace_docker_hub_documentserver_ee_auth.json.token }}"
return_content: true
check_mode: false
changed_when: false
register: workspace_docker_hub_documentserver_ee_tag_list
- name: Debug workspace_docker_hub_documentserver_ee_tag_list
ansible.builtin.debug:
var: workspace_docker_hub_documentserver_ee_tag_list
verbosity: "{% if ansible_check_mode | bool %}0{% else %}1{% endif %}"
The above results in:
TASK [workspace : Get a Authorization token from auth.docker.io for onlyoffice/documentserver-ee] ******************************************************************************************************************************************************************************
ok: [workspace.webarch.org.uk]
TASK [workspace : Debug workspace_docker_hub_documentserver_ee_auth] ***********************************************************************************************************************************************************************************************************
ok: [workspace.webarch.org.uk] =>
workspace_docker_hub_documentserver_ee_auth:
changed: false
connection: close
content: |-
{"token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsIng1YyI6WyJNSUlFRmpDQ0F2NmdBd0lCQWdJVVZOajJRbU1JWnUzeGl0NUJ1RTlvRWdoVU5KUXdEUVlKS29aSWh2Y05BUUVMQlFBd2dZWXhDekFKQmdOVkJBWVRBbFZUTVJNd0VRWURWUVFJRXdwRFlXeHBabTl5Ym1saE1SSXdFQVlEVlFRSEV3bFFZV3h2SUVGc2RHOHhGVEFUQmdOVkJBb1RERVJ2WTJ0bGNpd2dTVzVqTGpFVU1CSUdBMVVFQ3hNTFJXNW5hVzVsWlhKcGJtY3hJVEFmQmdOVkJBTVRHRVJ2WTJ0bGNpd2dTVzVqTGlCRmJtY2dVbTl2ZENCRFFUQWVGdzB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Mjg0NjM2LCJzdWIiOiIifQ.oKzlvoISvztrAgvCqywtyNgGOLgGg7g04_2WMYq3t1utSX9XAT_cwrvdY1gSx5oTsgHDCT4hvcPhw9XzzDPBGMHYbmaVuBYv5YDXXImV9A7236KpkEjen1ZlH14TsoiRL3ba9zdo_6whK4_twDZ4KgvvRU7VnApEBAv3aTVgBLTvcYtKlHVrzWHEM0Yy3tj09cF5KHwAFaNrh1PMuFbOy7Dio3iT-ww9QR0dzC_HwHDDlenRjMzeURJdiauqXlVs_iqpb4vacvL0K6WdGKeES7AzzPnlO9CCKsoty1R70EnRs0O3pcJiu-jybHtXZgSq6l58Wyr3_0klmD5Oy9E_PA","expires_in":300,"issued_at":"2024-01-26T16:02:16.573922745Z"}
content_type: application/json
cookies: {}
cookies_string: ''
date: Fri, 26 Jan 2024 16:02:16 GMT
elapsed: 0
failed: false
json:
access_token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsIng1YyI6WyJNSUlFRmpDQ0F2NmdBd0lCQWdJVVZOajJRbU1JWnUzeGl0NUJ1RTlvRWdoVU5KUXdEUVlKS29aSWh2Y05BUUVMQlFBd2dZWXhDekFKQmdOVkJBWVRBbFZUTVJNd0VRWURWUVFJRXdwRFlXeHBabTl5Ym1saE1SSXdFQVlEVlFRSEV3bFFZV3h2SUVGc2RHOHhGVEFUQmdOVkJBb1RERVJ2WTJ0bGNpd2dTVzVqTGpFVU1CSUdBMVVFQ3hNTFJXNW5hVzVsWlhKcGJtY3hJVEFmQmdOVkJBTVRHRVJ2WTJ0bGNpd2dTVzVqTGlCRmJtY2dVbTl2ZENCRFFUQWVGdzB5TkRBeE1UWXdOak0yTURCYUZ3MHlOVEF4TVRVd05qTTJNREJhTUlHRk1Rc3dDUVlEVlFRR0V3SlZVekVUTUJFR0ExVUVDQk1LUTJGc2FXWnZjbTVwWVRFU01CQUdBMVVFQnhNSlVHRnNieUJCYkhSdk1SVXdFd1lEVlFRS0V3eEViMk5yWlhJc0lFbHVZeTR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4_twDZ4KgvvRU7VnApEBAv3aTVgBLTvcYtKlHVrzWHEM0Yy3tj09cF5KHwAFaNrh1PMuFbOy7Dio3iT-ww9QR0dzC_HwHDDlenRjMzeURJdiauqXlVs_iqpb4vacvL0K6WdGKeES7AzzPnlO9CCKsoty1R70EnRs0O3pcJiu-jybHtXZgSq6l58Wyr3_0klmD5Oy9E_PA
msg: OK (unknown bytes)
redirected: false
status: 200
strict_transport_security: max-age=31536000
transfer_encoding: chunked
url: https://auth.docker.io/token
x_trace_id: d9c4d8c02d40f8489e9f4d5a7ea206b6
TASK [workspace : Get the tag list for onlyoffice/documentserver-ee] ***********************************************************************************************************************************************************************************************************
fatal: [workspace.webarch.org.uk]: FAILED! => changed=false
connection: close
content: |-
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"onlyoffice/documentserver-ee","Action":"pull"}]}]}
content_length: '171'
content_type: application/json
date: Fri, 26 Jan 2024 16:02:18 GMT
docker_distribution_api_version: registry/2.0
elapsed: 0
json:
errors:
- code: UNAUTHORIZED
detail:
- Action: pull
Class: ''
Name: onlyoffice/documentserver-ee
Type: repository
message: authentication required
msg: 'Status code was 401 and not [200]: HTTP Error 401: Unauthorized'
redirected: false
status: 401
strict_transport_security: max-age=31536000
url: https://registry.hub.docker.com/v2/onlyoffice/documentserver-ee/tags/list
www_authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:onlyoffice/documentserver-ee:pull",error="invalid_token"
Have I made a stupid mistake or does anyone have a better suggestion than using the command
module and curl
to get around this issue?
I’m stumped!
This is the version that works using curl
:
- name: Get a Authorization token from auth.docker.io for onlyoffice/documentserver-ee
ansible.builtin.command: >-
curl --silent --get --data-urlencode "service=registry.docker.io"
--data-urlencode "scope=repository:onlyoffice/documentserver-ee:pull"
https://auth.docker.io/token
check_mode: false
changed_when: false
register: workspace_docker_hub_documentserver_ee_curl_auth
- name: Set a fact for the JSON returned from auth.docker.io for onlyoffice/documentserver-ee
ansible.builtin.set_fact:
workspace_docker_hub_documentserver_ee_curl_auth_json: "{{ workspace_docker_hub_documentserver_ee_curl_auth.stdout | ansible.builtin.from_json }}"
- name: Get the tag list for onlyoffice/documentserver-ee using curl
ansible.builtin.command: >-
curl -s --header "Authorization: Bearer {{ workspace_docker_hub_documentserver_ee_curl_auth_json.token }}"
https://registry.hub.docker.com/v2/onlyoffice/documentserver-ee/tags/list
check_mode: false
changed_when: false
register: workspace_docker_hub_documentserver_ee_curl_tag_list
- name: Set a fact for the onlyoffice/documentserver-ee tags
ansible.builtin.set_fact:
workspace_docker_hub_documentserver_ee_tags: "{{ (workspace_docker_hub_documentserver_ee_curl_tag_list.stdout | ansible.builtin.from_json).tags }}"
- name: Debug workspace_docker_hub_documentserver_ee_tags
ansible.builtin.debug:
var: workspace_docker_hub_documentserver_ee_tags
verbosity: "{% if ansible_check_mode | bool %}0{% else %}1{% endif %}"
The curl
version results in:
TASK [workspace : Debug workspace_docker_hub_documentserver_ee_tags] ***********************************************************************************************************************************************************************************************************
ok: [workspace.webarch.org.uk] =>
workspace_docker_hub_documentserver_ee_tags:
- 3.5.0-199
- '5.6'
- 5.6.4
- 5.6.4.20
- 5.6.5
- 5.6.5.3
- '6.0'
- 6.0.0
- 6.0.0.105
- 6.0.1
- 6.0.1.32
- 6.0.2
- 6.0.2.5
- '6.1'
- 6.1.0
- 6.1.0.83
- 6.1.1
- 6.1.1.53
- '6.2'
- 6.2.0
- 6.2.0.123
- 6.2.1
- 6.2.1.24
- 6.2.2
- 6.2.2.21
- '6.3'
- 6.3.0
- 6.3.0.111
- 6.3.1
- 6.3.1.32
- 6.3.2
- 6.3.2.2
- '6.4'
- 6.4.0
- 6.4.0.121
- 6.4.1
- 6.4.1.45
- 6.4.2
- 6.4.2.6
- '7.0'
- 7.0.0
- 7.0.0.132
- 7.0.1
- 7.0.1.37
- '7.1'
- 7.1.0
- 7.1.0.215
- 7.1.1
- 7.1.1.23
- '7.2'
- 7.2.0
- 7.2.0.204
- 7.2.1
- 7.2.1.34
- 7.2.2
- 7.2.2.56
- '7.3'
- 7.3.0
- 7.3.0.184
- 7.3.2
- 7.3.2.8
- 7.3.3
- 7.3.3.50
- '7.4'
- 7.4.0
- 7.4.0.1
- 7.4.1
- 7.4.1.1
- '7.5'
- 7.5.0
- 7.5.0.1
- 7.5.1
- 7.5.1.1
- latest
- latest-arm64