News for hackers. Stuff that matters.
Re:Replacing Ansible with salt-ssh by crmrc114 on Thursday October 22, 2020 @10:27AM (#24858368)
You lost me when you when the author failed to properly understand how to use {{ item }} by defining with_items:

https://www.educba.com/ansible-with_items/

Let me fix his code here: https://pastebin.com/PQDAnHiJ

I use with_items at least once a day in this manner.

Re:Replacing Ansible with salt-ssh by Spivak on Thursday October 22, 2020 @12:50PM (#24860112)
That’s not right either. It’s super wasteful since newer versions of Ansible don’t magic loops into a single call to your package manager anymore. You have to pass the list as a single item.

    - name: Install stuff.
      package:
        name: [git, httpd]
Re:Replacing Ansible with salt-ssh by crmrc114 on Thursday October 22, 2020 @12:57PM (#24860195)
Agreed, great callout for the example use case, my point was simply using the items list which could even be used for something like shell or win_shell
Re:Replacing Ansible with salt-ssh by emmelaich on Thursday October 22, 2020 @08:26PM (#24864886)
Note that it was possible to install multiple packages in one call by passing the whole list to yum/apt. This was undocumented but happened to work.

You just had to supply the list as space separated. i.e.

   package: {{ packages|join(' ') }}
or similar
Re:Replacing Ansible with salt-ssh by deeblering4 on Thursday October 22, 2020 @01:54PM (#24860967)
Is this the case too with other resources, like users? I noticed that those loops can become pretty time consuming as the user list gets larger.
Re:Replacing Ansible with salt-ssh by geerlingguy on Thursday October 22, 2020 @01:59PM (#24861052)
It depends on the module; the user module works on one entity at a time, so you have to loop at the task level, which does take a little longer that trying to pass through a batch of user data at once.
Re:Replacing Ansible with salt-ssh by spyc on Thursday October 22, 2020 @05:02PM (#24863264)
The article uses with_list rather than with_items but even with with_items, that syntax would be working and define {{ item }} fine.

Please check the docs of with_list at https://docs.ansible.com/ansible/latest/user_guide/playbooks... .

Re:Replacing Ansible with salt-ssh by Arnavion on Thursday October 22, 2020 @01:58PM (#24861034)
Their point is not about how to pass in those parameters to the `package` task. They want to reuse the list of items as the value of the tags list, which they can't without duplicating the list.
Re:Replacing Ansible with salt-ssh by crmrc114 on Thursday October 22, 2020 @04:55PM (#24863204)
Or they could define the list of packages as an array once? https://stackoverflow.com/questions/23507589/is-it-possible-...

Then just point the module to the array, like in the linked example.

edit; Check out Spivak's solution in the comments below. Interrogate the host and find out what is needed, then apply the install- saves you all the time of getting back 'ok' results.