image-builder: capi image-builder broken

Looks like due to PR https://github.com/kubernetes-sigs/image-builder/pull/68 merged

particularly

  set_fact:
    ecr: "{{ kubernetes_container_registry is regex('^[0-9]{12}.dkr.ecr.[^.]+.amazonaws.com\/') }}"

error log:

[0;32m    ubuntu-1804: ERROR! Syntax Error while loading YAML.[0m
[0;32m    ubuntu-1804:   found unknown escape character[0m
[0;32m    ubuntu-1804:[0m
[0;32m    ubuntu-1804: The error appears to be in '/home/imgbuilder-ova/workspace/run-image-builder/62/image-builder/images/capi/ansible/roles/kubernetes/tasks/main.yml': line 40, column 92, but may[0m
[0;32m    ubuntu-1804: be elsewhere in the file depending on the exact syntax problem.[0m
[0;32m    ubuntu-1804:[0m
[0;32m    ubuntu-1804: The offending line appears to be:[0m
[0;32m    ubuntu-1804:[0m
[0;32m    ubuntu-1804:   set_fact:[0m
[0;32m    ubuntu-1804:     ecr: "{{ kubernetes_container_registry is regex('^[0-9]{12}.dkr.ecr.[^.]+.amazonaws.com\/') }}"[0m
[0;32m    ubuntu-1804:                                                                                            ^ here[0m
[0;32m    ubuntu-1804: We could be wrong, but this one looks like it might be an issue with[0m
[0;32m    ubuntu-1804: missing quotes. Always quote template expression brackets when they[0m
[0;32m    ubuntu-1804: start a value. For instance:[0m

cc @aaroniscode

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (21 by maintainers)

Most upvoted comments

Doing apt-get update && apt-get upgrade on Ubuntu 18.04 still gets me python 2.7.15+ so we’d have to update it outside of apt… I’d prefer avoiding that and changing the regexp to work with 2.7.15 if possible.

I’m 100% in agreement. I think swapping the " and ' in the Ansible command works. Going to put in a PR

btw, @CecileRobertMichon Thank you for sharing your result.

@aaroniscode I also think you could simplify the regex to dkr\.ecr\..+\.amazonaws\.com if that helps (although maybe it still doesn’t like the slashes).

@figo if you take my small playbook above and run it like ansible-playbook -vv test.yml, you should see something like this (or an error):

ansible-playbook -vv test.yml
ansible-playbook 2.9.2
  config file = None
  configured module search path = ['/Users/andy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.9.2/libexec/lib/python3.7/site-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.7.5 (default, Nov  1 2019, 02:16:32) [Clang 11.0.0 (clang-1100.0.33.8)]
No config file found; using defaults
[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAYBOOK: test.yml *********************************************************************************************************************************************************************************************************************************
1 plays in test.yml

PLAY [127.0.0.1] ***********************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************************************************************************************
task path: /private/tmp/ansible/test.yml:2
ok: [127.0.0.1]
META: ran handlers

TASK [andy] ****************************************************************************************************************************************************************************************************************************************
task path: /private/tmp/ansible/test.yml:7
ok: [127.0.0.1] => {"ansible_facts": {"ecr": true}, "changed": false}
META: ran handlers
META: ran handlers

PLAY RECAP *****************************************************************************************************************************************************************************************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0