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
---
- name: Check the path
stat: path={{ dir_agente }}
register: p
- fail: msg="Path exists and is not a directory"
when: p.stat.exists == True and p.stat.isdir == False
- name: creamos el path del agente
become: yes
become_user: root
file: state=directory path={{ dir_agente }} mode=0755
owner={{patrol_user}} group={{patrol_group}}
when: p.stat.exists == False
What i have no idea is how to continue, i'm looking module mount but don't
really get how to check if a Fs mounted or not, to check if the Fs is
mounted i've found several examples but they dont really seem right or i
cant get them to work, for example
vars:
- myvolume: /backup
tasks:
- debug: msg="The dir is a mount point"
with_items: ansible_mounts
when: item.mount == myvolume
Could someone give me some directions on how to check if:
- The Fs "patrol_fs" already exists
- the fs is mounted on that path "dir_agente" or if its mounted somewhere
else or if theres a Fs mounted on dir_agente and it's not patrol_fs as
expected?
Thanks a lot for any help i can get
--
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/6150eab3-5943-4f55-85d1-c26b964c5a32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.