Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWX task fail with AnsibleUnsafeBytes for yaml collapsed string #15161

Closed
5 of 11 tasks
jon-nfc opened this issue May 1, 2024 · 1 comment
Closed
5 of 11 tasks

AWX task fail with AnsibleUnsafeBytes for yaml collapsed string #15161

jon-nfc opened this issue May 1, 2024 · 1 comment

Comments

@jon-nfc
Copy link

jon-nfc commented May 1, 2024

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to security@ansible.com instead.)

Bug Summary

A yaml collapsed string with jinja fails with error AnsibleUnsafeBytes.__format__. unsupported format string passed to AnsibleUnsafeBytes.__format__ when it should not have for a string. this task does not fail when run via CLI.

AWX version

23.9.0

Select the relevant components

  • UI
  • UI (tech preview)
  • API
  • Docs
  • Collection
  • CLI
  • Other

Installation method

kubernetes

Modifications

no

Ansible version

2.16.1

Operating system

k3s 1.29

Web browser

No response

Steps to reproduce

use the foollowing task in play:

- name: Download K3s Binary
  ansible.builtin.uri:
    url: |-
      https://github.com/k3s-io/k3s/releases/download/
        {{- node_k3s.desired_version | urlencode -}}
      /k3s
      {%- if cpu_arch.key == 'aarch64' -%}
      -arm64
      {%- endif %}
    method: GET
    return_content: false
    status_code:
      - 200
      - 304
    dest: "/tmp/k3s.{{ cpu_arch.key }}"
    mode: "744"
  changed_when: not ansible_check_mode
  check_mode: false
  delay: 10
  retries: 3
  register: k3s_download_files
  delegate_to: localhost
  failed_when: >
    (lookup('ansible.builtin.file', '/tmp/k3s.' + cpu_arch.key) | hash('sha256') | string) != node_k3s.desired_hash
      and
    (
      k3s_download_files.status | int != 200
        or
      k3s_download_files.status | int != 304
    )
  run_once: true
  when: ansible_os_family == 'Debian'
  loop: "{{ nfc_kubernetes_install_architectures | dict2items }}"
  loop_control:
    loop_var: cpu_arch
  vars:
    ansible_connection: local

where:

cpu_arch:
  key: aarch64

Expected results

A yaml collapsed string |- or >- by never return error AnsibleUnsafeBytes.__format__. unsupported. when the type is clearly a yaml string

Actual results

error:

msg: >-
  Unexpected templating type error occurred on
  (https://github.com/k3s-io/k3s/releases/download/
    {{- node_k3s.desired_version | urlencode -}}
  /k3s

  {%- if cpu_arch.key == 'aarch64' -%}

  -arm64

  {%- endif %}): unsupported format string passed to
  AnsibleUnsafeBytes.__format__. unsupported format string passed to
  AnsibleUnsafeBytes.__format__

Additional information

No response

@jon-nfc jon-nfc changed the title AWX task fail with AnsibleUnsafeBytes when cli doesn't AWX task fail with AnsibleUnsafeBytes for yaml collapsed string May 1, 2024
nfc-robot pushed a commit to nofusscomputing/ansible_collection_kubernetes that referenced this issue May 2, 2024
nfc-robot pushed a commit to nofusscomputing/ansible_collection_kubernetes that referenced this issue May 2, 2024
nfc-robot pushed a commit to nofusscomputing/ansible_collection_kubernetes that referenced this issue May 2, 2024
nfc-robot added a commit to nofusscomputing/ansible_collection_kubernetes that referenced this issue May 2, 2024
nfc-robot pushed a commit to nofusscomputing/execution_environment that referenced this issue May 2, 2024
nfc-robot pushed a commit to nofusscomputing/ansible_collection_kubernetes that referenced this issue May 2, 2024
This reverts commit 9fa3b23.

The bug was within awx-core 2.16.1 as upgrading to 2.16.6 fixed the problem

!63 !61 nofusscomputing/projects/ansible/execution_environment!255 closes ansible/awx#15161
@jon-nfc
Copy link
Author

jon-nfc commented May 2, 2024

closing as issue was corrected by updating to ansible-core 2.16.6 from 2.16.1

nfc-robot pushed a commit to nofusscomputing/ansible_collection_kubernetes that referenced this issue May 2, 2024
This reverts commit 9fa3b23.

The bug was within awx-core 2.16.1 as upgrading to 2.16.6 fixed the problem

!63 !61 nofusscomputing/projects/ansible/execution_environment!255 closes ansible/awx#15161
@jon-nfc jon-nfc closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant