Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing file systems in ansible_mounts

Tags:

ansible

I am trying to iterate over ansible_mounts variable and print the mount points that are gathered during fact checking. Based on the documentation I would have expected the following to work:

- debug: msg={{item.mount}}   
  with_items: ansible_mounts

When I run the playbook with fact gathering enabled I get a number of errors. What is the correct way to print all of the file systems accessible to a host? It looks like ansible_mounts is a list of dictionaries so maybe I need to adjust my syntax? I'm currently running ansible 2.2.

like image 976
Mickster Avatar asked Feb 05 '23 04:02

Mickster


1 Answers

This tasks shows the info you want:

- debug: msg="{{ item.mount }}"
  with_items:
  - "{{ ansible_mounts }}"

or

- debug: var=item.mount
  with_items:
  - "{{ ansible_mounts }}"
like image 152
dgw Avatar answered Mar 23 '23 22:03

dgw