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

Avoid "unable to evaluate string as dictionary" with args rule #3150

Merged
merged 1 commit into from Mar 7, 2023

Conversation

ssbarnea
Copy link
Member

@ssbarnea ssbarnea commented Mar 7, 2023

Fixes: #3128

@ssbarnea ssbarnea requested review from a team as code owners March 7, 2023 14:43
@github-actions github-actions bot added the bug label Mar 7, 2023
@ssbarnea ssbarnea merged commit eda1aba into main Mar 7, 2023
28 of 30 checks passed
@ssbarnea ssbarnea deleted the fix/jinja2 branch March 7, 2023 15:04
@Et7f3
Copy link
Contributor

Et7f3 commented Mar 8, 2023

Do you prefer this test ?

---
- hosts: all
  name: Something
  connection: local
  vars:
    tcp_flags:
      flags: ALL
      flags_set:
        - ACK
        - RST
        - SYN
        - FIN
  check_mode: true
  tasks:
    - name: Set tcp flags
      ansible.builtin.iptables:
        chain: OUTPUT
        jump: DROP
        protocol: tcp
        tcp_flags: "{{ tcp_flags }}"

Do you want a PR to add it somewhere ?

@ssbarnea
Copy link
Member Author

ssbarnea commented Mar 8, 2023

@Et7f3 I tried this one too, no errors with code from main branch, reported all green.

@Et7f3
Copy link
Contributor

Et7f3 commented Mar 8, 2023

I reproduced with

ansible-lint 6.14.1 using ansible 2.14.3

(and reverting this PR)

I can send you a nix expression so you can fully reproduce my setup ? Or you prefer other way to reproduce (nix is better IMO) ?

@Et7f3 Et7f3 mentioned this pull request Mar 8, 2023
12 tasks
@Et7f3
Copy link
Contributor

Et7f3 commented Mar 8, 2023

Here is a reproduction:

let
  # Not dependent of nixpkgs so you can use the global one <nixpkgs>
  nixpkgs = builtins.fetchTarball {
    url = "https://github.com/Et7f3/nixpkgs/archive/repro_bug_ansible_lint~.tar.gz";
  };
in
{...}@args: with import nixpkgs args; (pkgs.runCommandCC or pkgs.runCommand) "shell" {
  buildInputs = with pkgs; [
    git
    ansible
    # Here we revert this PR
    (ansible-lint.overrideAttrs (_: {
      patches = pkgs.fetchpatch {
        url = "https://patch-diff.githubusercontent.com/raw/ansible/ansible-lint/pull/3150.patch";
        hash = "sha256-CMmZbeu3zK5Zj7P2PEvcmHsvKV4FqEa53jhFnCIFV38=";
        revert = true;
      };
    }))
  ];
  shellHook = ''
    # nix on ubuntu
    export LANG=en_US.UTF-8
    if test -f /usr/lib/locale/locale-archive
    then
      export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive
    fi
  '';
} "
mkdir -p failure
cd failure
git init .
ansible-lint --version
cat > playbook.yml <<EOF
---
- hosts: all
  name: Something
  connection: local
  vars:
    tcp_flags:
      flags: ALL
      flags_set:
        - ACK
        - RST
        - SYN
        - FIN
  check_mode: true
  tasks:
    - name: Set tcp flags
      ansible.builtin.iptables:
        chain: OUTPUT
        jump: DROP
        protocol: tcp
        tcp_flags: \"{{ tcp_flags }}\"
EOF
ansible-lint playbook.yml"

put this in a shell.nix and nix-shell --pure shell.nix (the pure is optional but isolate better) You can call sh $buildCommandPath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive; args[module]: unable to evaluate string as dictionary (warning)
2 participants