Reinstate docker tag cleanup
This uses a new method of calculating the cutoff time which does not require executing code on the executor. Change-Id: I92e71727e24281a31cb7caf0b78dd17a5aaae129 Co-Authored-By: Clark Boylan <clark.boylan@gmail.com>
This commit is contained in:
parent
abd4ab18a3
commit
2dc89d8347
@ -3,18 +3,18 @@
|
|||||||
url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags?page_size=1000"
|
url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags?page_size=1000"
|
||||||
status_code: 200
|
status_code: 200
|
||||||
register: tags
|
register: tags
|
||||||
# - name: Set cutoff timestamp to 24 hours ago
|
- name: Delete all change tags older than the cutoff
|
||||||
# command: "python3 -c \"import datetime; print((datetime.datetime.utcnow()-datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M:%fZ'))\""
|
no_log: true
|
||||||
# register: cutoff
|
loop: "{{ tags.json.results }}"
|
||||||
# - name: Delete all change tags older than the cutoff
|
loop_control:
|
||||||
# no_log: true
|
loop_var: zj_docker_tag
|
||||||
# loop: "{{ tags.json.results }}"
|
when:
|
||||||
# loop_control:
|
- zj_docker_tag.name.startswith('change_')
|
||||||
# loop_var: zj_docker_tag
|
# Was updated > 24 hours ago:
|
||||||
# when: zj_docker_tag.last_updated < cutoff.stdout and zj_docker_tag.name.startswith('change_')
|
- "{{ ((ansible_date_time.iso8601 | regex_replace('^(....-..-..)T(..:..:..).*Z', '\\1 \\2') | to_datetime) - (zj_docker_tag.last_updated | regex_replace('^(....-..-..)T(..:..:..).*Z', '\\1 \\2') | to_datetime)).seconds > 86400 }}"
|
||||||
# uri:
|
uri:
|
||||||
# url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags/{{ zj_docker_tag.name }}/"
|
url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags/{{ zj_docker_tag.name }}/"
|
||||||
# method: DELETE
|
method: DELETE
|
||||||
# status_code: [200, 204]
|
status_code: [200, 204]
|
||||||
# headers:
|
headers:
|
||||||
# Authorization: "JWT {{ jwt_token.json.token }}"
|
Authorization: "JWT {{ jwt_token.json.token }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user