Thanks a lot

On 07/27/2017 07:25 PM, Kai Stian Olstad wrote:
On 27. juli 2017 18:42, Frank Thommen wrote:
Hi,

I was looking for a way to run the distro-dependent package manager
w/o too many "when"s and I found this (on
https://ansible-tips-and-tricks.readthedocs.io/en/latest/os-dependent-tasks/installing_packages/#installing-packages):


- name: install basic package
   action: >
     {{ ansible_pkg_mgr }} name=vim state=present update_cache=yes

However I cannot find this "action" module mentioned anywhere in the
whole Ansible documentation

https://docs.ansible.com/ansible/latest/playbooks_intro.html#tasks-list
https://docs.ansible.com/ansible/latest/playbooks_intro.html#action-shorthand

Shame on me. I overlooked it in the very basic intro page... :-}



In short, it's an old syntax not encourage used anymore.


and I also don't understand, why the ">" is needed at that point.

It's an yaml indicator character, ">" indicate that the lines can be
broken to multiple lines.

Yes, that I know that, but I just don't understand, why

- name: install basic package
   action: {{ ansible_pkg_mgr }} name=vim state=present update_cache=yes

or

- name: install basic package
   action: "{{ ansible_pkg_mgr }}" name=vim state=present update_cache=yes

Wouldn't work (both fail with YAML syntax error)



 Is this an obsolete feature or a very new one, which is not
documented yet?  What exactly can one do with it?

I think you need to use action if the module name is a variable as in
you example.
I think these two examples would fail.

  - name: install basic package
    {{ ansible_pkg_mgr }}: name=vim state=present update_cache=yes

and

  - name: install basic package
    {{ ansible_pkg_mgr }}:
      name: vim
      state: present
      update_cache: yes

Indeed they fail, and there doesn't seem to be a useable replacement in the current syntax. :-(

frank


--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e5329e7d-47dd-639f-94fa-a7f8454f47d8%40drosera.ch.
For more options, visit https://groups.google.com/d/optout.

Reply via email to