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

jinja[invalid] when using a variable to feed the seed parameter of ansible.builtin.random #3769

Closed
snail59 opened this issue Sep 26, 2023 · 0 comments · Fixed by #3773
Closed
Assignees
Labels

Comments

@snail59
Copy link

snail59 commented Sep 26, 2023

Summary

The "idempotent method to generate unique hashes per system is to use a salt that is consistent between runs"
found here: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_filters.html#hashing-and-encrypting-strings-and-passwords works as expected.
But ansible-lint returns an error : The only supported seed types are: None, int, float, str, bytes, and bytearray.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 6.20.0 using ansible-core:2.15.4 ansible-compat:4.1.10 ruamel-yaml:0.17.32 ruamel-yaml-clib:0.2.7

(I tried with version 6.18 and 6.17.1 too)

  • ansible installation method: OS package
  • ansible-lint installation method: OS package
STEPS TO REPRODUCE
run the following playbook.
- name: Demo
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Use seed in random
      ansible.builtin.debug:
        msg: "{{ 65534 | ansible.builtin.random(seed=inventory_hostname) }}"
Desired Behavior

I hoped for this code to pass.

Actual Behavior
  • the output of running ansible-playbook including the command line used:
ansible-playbook test.yml 

PLAY [Demo] ********************************************************************************************************************************************************************************************************************************

TASK [Use seed in random] ******************************************************************************************************************************************************************************************************************
mardi 26 septembre 2023  16:01:05 +0200 (0:00:00.013)       0:00:00.013 ******* 
ok: [localhost] => 
  msg: '43927'
  • the output of running ansible-lint including the command line used
ansible-lint test.yml 
WARNING  Skipped installing old role dependencies due to running in offline mode.
WARNING  Skipped installing collection dependencies due to running in offline mode.
WARNING  Listing 1 violation(s) that are fatal
jinja[invalid]: Unexpected templating type error occurred on ({{ 65534 | random(seed=inventory_hostname) }}): The only supported seed types are: None,
int, float, str, bytes, and bytearray.. The only supported seed types are: None,
int, float, str, bytes, and bytearray.
  • if you're getting a stack trace, also the output of
    ansible-playbook --syntax-check playbook
ansible-playbook --syntax-check test.yml

playbook: test.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants