# Stuck on a playbook development - Fs

**URL:** <https://forum.ansible.com/t/stuck-on-a-playbook-development-fs/22673>\
**Category:** Ansible Developer\
**Tags:** ubuntu\
**Created:** [September 29, 2016, 7:16am UTC](https://forum.ansible.com/t/stuck-on-a-playbook-development-fs/22673 "2016-09-29T07:16:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Lopez\_Laguna](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Miguel\_Lopez\_Laguna](https://forum.ansible.com/u/Miguel_Lopez_Laguna)\
**Post date:** [September 29, 2016, 7:16am UTC](https://forum.ansible.com/t/stuck-on-a-playbook-development-fs/22673/1 "2016-09-29T07:16:10Z")

</div>

Hi, first of all i would like to introduce myself, i work with linux and AIX systems and I’m trying to have some automation over the servers farm

I’m new to ansible and i’ve been reading the docs and i get how playbooks works but i’m still pretty new with all this so i’m learning everyday about modules and how to use them.

Problem comes as i have a tight agenda and i’m getting stuck with some tasks i don’t know how to get over with, basically because i lack the knowlegde of the modules to use or how yo use them.

What i’m trying to do is a playbook to install some agents, so i have to do several tasks like creating users, checking Fs and install the agent

The Playbook i’ve created is still a work in progress as it’s on a very early stage

-rw-r–r-- 1 ansible ansible 141 sep 28 16:48 patrol.yml

drwxr-xr-x 5 ansible ansible 40 sep 28 14:03 roles

drwxr-xr-x 2 ansible ansible 38 sep 28 17:25 vars

./roles/fs/tasks/main.yml

./roles/patrol/meta/main.yml

./roles/patrol/tasks/main.yml

./roles/users/tasks/main.yml

./vars:

total 8

-rw-r–r-- 1 ansible ansible 24 sep 28 17:25 aix.yml

-rw-r–r-- 1 ansible ansible 24 sep 28 17:25 linux.yml

-rw-r–r-- 1 ansible ansible 808 sep 28 13:54 comunes.yml

On vars i have comunes as the first variables:

is\_aix: “‘{{ ansible\_distribution|lower }}’ == ‘aix’”

is\_linux: “‘{{ ansible\_system|lower }}’ == ‘linux’”

is\_centos: “‘{{ ansible\_distribution|lower }}’ == ‘centos’”

is\_ubuntu: “‘{{ ansible\_distribution|lower }}’ == ‘ubuntu’”

is\_redhat: “‘{{ ansible\_distribution|lower }}’ == ‘redhat’”

is\_redhat6: “‘{{ ansible\_distribution|lower }}’ == ‘redhat’ and ‘{{ ansible\_distribution\_major\_version }}’ == ‘6’”

is\_redhat65: “‘{{ ansible\_distribution|lower }}’ == ‘redhat’ and ‘{{ ansible\_distribution\_version }}’ == ‘6.5’”

is\_aix5: “‘{{ ansible\_system|lower }}’ == ‘aix’ and ‘{{ ansible\_distribution\_version }}’ == ‘5’”

is\_aix6: “‘{{ ansible\_system|lower }}’ == ‘aix’ and ‘{{ ansible\_distribution\_version }}’ == ‘6’”

is\_aix7: “‘{{ ansible\_system|lower }}’ == ‘aix’ and ‘{{ ansible\_distribution\_version }}’ == ‘7’”

And on aix and linux must go specific variables based on the OS platform, like var dir\_agente with the installation path. The main playbook is patrol.yml

- hosts: masteraix71

vars\_files:

- vars/comunes.yml

- “vars/{{ ansible\_system|lower }}.yml”

roles:

- users

- fs

- patrol

Through meta patrol depends on users and fs, my problem is with the fs role, as it has to check the Fs to use, some checks are:

- The path exists and is a dir

- The volume exists on LVM

- The volume is mounted and on fstab

The first one i’m doing it through stat so it fails if the file exist and its not a directory and create the mount point if it doesn’t exist

---

<div class="post-metadata">

**Author:** ![Miguel\_Lopez\_Laguna](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Miguel\_Lopez\_Laguna](https://forum.ansible.com/u/Miguel_Lopez_Laguna)\
**Post date:** [September 29, 2016, 7:59am UTC](https://forum.ansible.com/t/stuck-on-a-playbook-development-fs/22673/2 "2016-09-29T07:59:53Z")

</div>

From what i read on mount module creating the mount point ir unnecessary as it seems to create it if needed when using state=mounted

absent = remove from fstab, unmount, remove mount point  
present = add to fstab (this does not create a mount point so subsequent commands or reboots could error on this line)  
mounted = create mount point (if needed), add to fstab, mount (remount if existing and changed)  
unmounted = unmount (this leaves the fstab file unchanged. subsequent commands or reboots will remount this)

---

<div class="post-metadata">

**Author:** ![Miguel\_Lopez\_Laguna](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Miguel\_Lopez\_Laguna](https://forum.ansible.com/u/Miguel_Lopez_Laguna)\
**Post date:** [September 29, 2016, 11:54am UTC](https://forum.ansible.com/t/stuck-on-a-playbook-development-fs/22673/3 "2016-09-29T11:54:54Z")

</div>

Hi,  
Still working on it, i’ve found that my bigger problem is that i was doing my tests against an AIX server and not everything works as expected, for instance the facts do not include the mounts (ansible\_mounts) so i was unable to make it work.

In order to avoid this i’ll start working just with linux servers so i can try again with AIX once i have everything working as expected on Linux

So, what i’ve done so far… after checking my mount point point i want to check if it has a Fs over it:

- debug: msg=“The dir is a mount point {{ item.mount }}”

with\_items: ‘{{ ansible\_mounts|default() }}’

register: montaje

when: is\_linux and item.mount == ‘{{ dir\_agente }}’

this gives me the info but it doesn’t do anything really, is there a way to use the info and act according to the output?

For now i’ll try to do the same check using mount module but i have to find how to mount it only if it not already mounted

- mount: xxxxxxxxxxxxx

with\_items: ‘{{ ansible\_mounts|default() }}’

when: is\_linux and ‘{{ dir\_agente }}’ not included in item.mount —\> is there something similar to this?

I know i could use mount directly as it only updates the info if there’s no change but what happens if the server has a non standar volume name and tries to mount a new Fs over the old one?

Just thinking to myself as i’m doing some test in order to find a working configuration

---

<div class="post-metadata">

**Author:** ![willthames](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@willthames](https://forum.ansible.com/u/willthames)\
**Post date:** [September 30, 2016, 2:23am UTC](https://forum.ansible.com/t/stuck-on-a-playbook-development-fs/22673/4 "2016-09-30T02:23:36Z")

</div>

This list is for development of Ansible itself, rather than problems you might have developing ansible configuration management.

The ansible-project list is a more appropriate list for your questions.

Will

---

<div class="post-metadata">

**Author:** ![Miguel\_Lopez\_Laguna](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Miguel\_Lopez\_Laguna](https://forum.ansible.com/u/Miguel_Lopez_Laguna)\
**Post date:** [September 30, 2016, 6:42am UTC](https://forum.ansible.com/t/stuck-on-a-playbook-development-fs/22673/5 "2016-09-30T06:42:20Z")

</div>

I didn’t realized there was another list , sorry for inconvenience and thanks for pointing me in the right direction 😃
