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

Setting name to an empty list #68

Closed
pmav99 opened this issue Nov 8, 2021 · 1 comment
Closed

Setting name to an empty list #68

pmav99 opened this issue Nov 8, 2021 · 1 comment

Comments

@pmav99
Copy link

pmav99 commented Nov 8, 2021

Hi

When you specify an empty list to name, then a error is raised. E.g.:

---

- name: "install aur packages"
  hosts: "localhost"
  connection: "local"
  become: True

  vars:
    # aur_pkgs: []    # This fails with an explicit fail message
    aur_pkgs:      # This raises an exception

roles:
    - name: "Install AUR packages"
      kewlfft.aur.aur:
        name: "{{ aur_pkgs }}"
        use: "yay"
        state: "present"
      become_user: "aur_builder"

Obviously, not a huge issue, but this behavior is different from what e.g. ansible.builtin.package does. so i was a bit surprised by it.

FWIW, my use case is having a playbook template which contains something like this:

  vars:
    remove_pkgs:
    pkgs:
    aur_pkgs:

  tasks:
    - name: "Uninstall packages"
      ansible.builtin.package:
        name: "{{ remove_pkgs }}"
        state: "absent"

    - name: "Install packages"
      ansible.builtin.package:
        name: "{{ pkgs }}"
        state: "present"

    - name: "Install AUR packages"
      kewlfft.aur.aur:
        name: "{{ aur_pkgs }}"
        use: "yay"
        state: "present"
      become_user: "aur_builder"

and where I fill in the variables with values as necessary. As it is, I need to comment out the AUR stuff. Again, not a huge deal, but I don't really see why the playbook should fail.

I could make a PR if you agree with this behavior change

Related commit: 95aa8f3

@kewlfft
Copy link
Owner

kewlfft commented Nov 8, 2021

I haven't looked into it into details but in general I agree to follow the behavior of ansible.builtin.package
OK with the PR and if you can clarify how it will react after vs before the PR

@kewlfft kewlfft closed this as completed Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants