promote-docker-image: double-quote regexes

Change Ibc84e4f3fb18331ff6e2eb01037254be65dc53f5 removed the {{ from
this, which Ansible does warn about.  However it then started failing.

Upon local testing, I could see

 The conditional check 'ansible_date_time.iso8601 |
 regex_replace('^(....-..-..)T(..:..:..).*Z', '\\1 \\2') |
 to_datetime' failed. The error was: time data '\\x01 \\x02' does not
 match format '%Y-%m-%d %H:%M:%S

So for whatever reason, without the surrounding {{ }} the
regex_replace is getting turned into the string "\\1 \\2" -- not the
first and second results of the match.  Double quoting seems to fix
this.

Change-Id: I689385a3eb8b9ce373ff579c72cd29e46ebcaf8b
This commit is contained in:
Ian Wienand 2023-02-08 07:27:47 +11:00
parent 28ea1bbc8b
commit 1c85809ab1
No known key found for this signature in database

View File

@ -11,7 +11,7 @@
when: when:
- zj_docker_tag.name.startswith('change_') or zj_docker_tag.name.startswith(zuul.pipeline) - zj_docker_tag.name.startswith('change_') or zj_docker_tag.name.startswith(zuul.pipeline)
# Was updated > 24 hours ago: # Was updated > 24 hours ago:
- "((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" - "((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