Why cron jobs didn’t be set correctly by Ansible playbook?

I created this playbook to set crontab:

- name: Set PATH to crontab   cron:     name: PATH     env: yes     user: barman     job: /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/var/lib/barman/.local/bin:/var/lib/barman/bin:/usr/pgsql-10/bin/  - name: Automatically run backup for App1   cron:     name: "Run Backup for App1"     minute: "0"     hour: "3"     user: barman     job: "barman cron && barman backup app1"  - name: Automatically run backup for App2   cron:     name: "Run Backup for App2"     minute: "0"     hour: "4"     user: barman     job: "barman cron && barman backup app2" 

But I only found this under /etc/cron.d/barman file:

# m h  dom mon dow   user     command   * *    *   *   *   barman   [ -x /usr/bin/barman ] && /usr/bin/barman -q cron 

It seems didn’t set task correctly.

Ansible display realtime shell stdout

I want see the realtime shell stdout, instead of registering in a variable and then display once it is completed.

Example Playbook – test.yml

- name: Testing RUN Shell Command   hosts: localhost   connection: local    tasks:   - name: Runnig Update     shell: apt update 

Default Output

$   ansible-playbook  test.yml   PLAY [Testing RUN Shell Command] ******************************************************************************************************  TASK [Gathering Facts] **************************************************************************************************************** ok: [localhost]  TASK [Runnig Update] ****************************************************************************************************************** changed: [localhost]  PLAY RECAP **************************************************************************************************************************** localhost                  : ok=2    changed=1    unreachable=0    failed=0     

But I want to see what it is doing like when we run the apt update in terminal

$   sudo apt update Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease Hit:2 http://dl.google.com/linux/chrome/deb stable Release                                                                             Hit:3 http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu bionic InRelease                                                               Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                                            Hit:6 http://in.archive.ubuntu.com/ubuntu bionic InRelease                                                                             Hit:7 http://ppa.launchpad.net/canonical-chromium-builds/stage/ubuntu bionic InRelease                                                 ------OUTPUT REMOVED---------- 

I see that there is already discussion going on at github issue and look like that is not possible.

Is there any trick get the realtime stdout with help ansible Callback?

Incremental variable in ansible azure

Any ideas on how to make the variable increment every time I play my playbook so I can reuse my playbook for multiple projects? For example, I want my resource group name to be called “rg1”. The next time I play my playbook after the existence of “rg1”, I want the newly created resource group to be called “rg2”.

e.g.

first play:

rg=rg1

second play:

rg= rg2

Thank you!

use select and map with ansible

I have a dictionnary and I would like to select le vg_name vgapplis and calculate the sum size_FS. I tried this but it does not work. An idea ?

  • set_fact: FS_vgapplis:”{{ FS | select(”search”, ”\bvgapplis\b”)| map(attribute=’size_FS’)|list|sum }}”

FS: – nom_FS: /appm/oracle/product nom_LV: lv_product size_FS: 5 owner_FS: oracle group_FS: dba vg_name: vgapplis

- nom_FS: /appm/oracle/product/12.1.0.2   nom_LV: lv_12102   size_FS: 15   owner_FS: oracle   group_FS: dba   vg_name: vgapplis  - nom_FS: /apps/oracle/logs   nom_LV: lvlogs   size_FS: 5   owner_FS: oracle   group_FS: dba   vg_name: vglogs 

Thank you

Arithmetics operation with item with ansible

I would like to add each item in a loop.

For example :

Variables: FS: – nom_FS: /apps/oracle/{{ SID | lower }}/syst01 nom_LV: “lv{{ TRIGRAMME | lower }}syst01” size_FS: 20 owner_FS: oracle group_FS: dba vg_name: vgdata

- nom_FS: /apps/oracle/{{ SID | lower }}/syst02   nom_LV: "lv{{ TRIGRAMME | lower }}syst02"   size_FS: 20   owner_FS: oracle   group_FS: dba   vg_name: vgdata 

Playbook: – name: size FS shell: /bin/echo “({{item.size_FS.0}}+{{item.item.size_FS.1}})” | bc register: check_size_disk with_items: “{{ FS }}”

I tried other things without success…

Could you help me please ?

Philippe

Can’t enable NFS on two-node Ansible provisioned GlusterFS cluster

I have two nodes (running Armbian Bionic, based on Ubuntu 18.04) set up to create a distributed Gluster storage, provisioned via Ansible.

I think the relevant part of the Ansible playbook is this:

    - name: Configure gluster volume       gluster_volume:         state: present         name: "{{ gluster_volume_name }}"         brick: "{{ gluster_brick_dir }}"         cluster: "{{ groups.glustergroup | join(',') }}"         host: "{{ inventory_hostname }}"         force: yes       run_once: true 

Where glustergroup is the list of the two nodes in my Ansible inventory file.

On both nodes, when I run gluster volume info I see that the volume was created successfully, and it can be mounted via mount -t glusterfs. Here’s the output of gluster volume info:

Volume Name: [my volume name] Type: Distribute Volume ID: edbc9b23-6252-4725-9652-e46c280dae2b Status: Started Snapshot Count: 0 Number of Bricks: 2 Transport-type: tcp Bricks: Brick1: [node 1]:/bricks/brick0 Brick2: [node 2]:/bricks/brick0 Options Reconfigured: transport.address-family: inet nfs.disable: on 

I noticed that nfs.disable: on, but I want my clients to mount the volume via NFS. So, I ran gluster volume set [my volume name] nfs.disable off, then rebooted the nodes for good measure.

Now, I can see this from gluster volume status:

Status of volume: [my volume name] Gluster process                             TCP Port  RDMA Port  Online  Pid ------------------------------------------------------------------------------ Brick [node 1]:/bricks/brick0            49152     0          Y       2338  Brick [node 2]:/bricks/brick0              49152     0          Y       1526  NFS Server on localhost                     N/A       N/A        N       N/A   NFS Server on [node 2]                     N/A       N/A        N       N/A 

Notice that the NFS Servers are still not online in either node.

What else do I need to do to turn on NFS support, so that clients can mount this volume via /etc/fstab? Is there anything I can/should modify in the Ansible playbook to enable this? Thank you.

Reject in ansible list variable

I have such a variable:

apps:  - {name: kapitalism, extension: .war}  - {name: socialism, extension: .war}  - {name: somethingelse, extension: .ear} 

And I need to make another one based on it, which will not include some of the list. I’m trying this:

- name: Reject this please   set_fact:     apps: "{{ apps | map(attribute='name') | reject('search',item.name) | list }}"   when: "item.name.find('socialism') != -1"   with_items: "{{ apps }}" 

But here I get such a problem that the extension parameter is lost and I get the variable:

apps: [u'kapitalism', u'somethingelse'] 

How to make a variable like this:

apps:  - {name: kapitalism, extension: .war}  - {name: somethingelse, extension: .ear} 

?

Ayuda con Playbooks de ansible y Ansible Tower

estoy realizando un proyecto de fin de curso sobre Ansible, ya tengo todo configurado en las maquinas virtuales (Ubuntu 16) tanto servidor como cliente, sin embargo no se que playbooks interesantes podria mostrar de cara la presentación, existe alguna página con ejemplos donde poder sacar algunos interesantes para mostrar, o me podeis hacer alguna recomendacion?

Por otro lado ya tengo instalado Tower pero no tengo ni idea de como usarlo, existe algun tutorial de su funcionamiento, como añadir los clientes para trabajar al inventario, como ejecutar playbooks,etc… no he encontrado nada en español.