From 1c85809ab147dffbaa351046b203078a20eb70e2 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 8 Feb 2023 07:27:47 +1100 Subject: [PATCH] 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 --- roles/promote-docker-image/tasks/promote-cleanup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/promote-docker-image/tasks/promote-cleanup.yaml b/roles/promote-docker-image/tasks/promote-cleanup.yaml index 9b877a14b..f5c4a0274 100644 --- a/roles/promote-docker-image/tasks/promote-cleanup.yaml +++ b/roles/promote-docker-image/tasks/promote-cleanup.yaml @@ -11,7 +11,7 @@ when: - zj_docker_tag.name.startswith('change_') or zj_docker_tag.name.startswith(zuul.pipeline) # 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: url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags/{{ zj_docker_tag.name }}/" method: DELETE