# Gather Data using ansible playbook

**URL:** <https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018>\
**Category:** Ansible Project\
**Created:** [November 20, 2021, 9:48am UTC](https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018 "2021-11-20T09:48:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhiroxxx](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Abhiroxxx](https://forum.ansible.com/u/Abhiroxxx)\
**Post date:** [November 20, 2021, 9:48am UTC](https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018/1 "2021-11-20T09:48:33Z")

</div>

Hello Guys,

Can someone let me know how can we gather filesystem extension from one task and how can we use that result as variable in next task in ansible playbook.? Thanks in advance…

Regard’s  
Abhi

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [November 20, 2021, 10:34am UTC](https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018/2 "2021-11-20T10:34:25Z")

</div>

I have no idea what a “filesystem extension” is, nor how to gather it.  
But once you’ve done that, register it so you can use it in subsequent tasks.

---

<div class="post-metadata">

**Author:** ![Abhiroxxx](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Abhiroxxx](https://forum.ansible.com/u/Abhiroxxx)\
**Post date:** [November 20, 2021, 1:34pm UTC](https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018/3 "2021-11-20T13:34:30Z")

</div>

Hi,

Getting below error while using register output in subsequent tasks.

[WARNING]: The value [‘xfs’] (type list) in a string field was converted to u"[‘xfs’]" (type string). If this does not look like what you expect, quote the  
entire value to ensure it does not change.  
fatal: [[stlbnisldaprh01.va.neustar.com](http://stlbnisldaprh01.va.neustar.com)]: FAILED! =\> {“changed”: false, “msg”: “value of fstype must be one of: ext4, ext3, f2fs, btrfs, vfat, ocfs2, ext4dev, swap, reiserfs, lvm, xfs, ext2, got: [‘xfs’]”}

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [November 20, 2021, 3:28pm UTC](https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018/4 "2021-11-20T15:28:37Z")

</div>

Instead of have people guess what your playbook might look like based on an error, post it

---

<div class="post-metadata">

**Author:** ![Abhiroxxx](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Abhiroxxx](https://forum.ansible.com/u/Abhiroxxx)\
**Post date:** [November 20, 2021, 6:28pm UTC](https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018/5 "2021-11-20T18:28:45Z")

</div>

Here I am posting that playbook. please check it and suggest me…

tasks:

- name: lvm Extend  
shell: “/usr/sbin/lvextend -L +{{ extend\_lv\_size }} /dev/mapper/{{ vg\_name }}-{{ lv\_name }}”

- name: lvm Extend  
shell: “/usr/bin/df -hT | grep {{ Mount\_point }} | cut -d. -f1 | awk ‘{print $2}’”  
register: fs

- name: ‘Extend the FS’  
filesystem:  
fstype: “{{ fs }}”  
dev: “/dev/mapper/{{ vg\_name }}-{{ lv\_name }}”  
resizefs: yes

- name: Check Mounted points on hosts  
shell: “df -hT | grep {{ Mount\_point }}”  
register: df

- debug: var=df.stdout\_lines

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [November 20, 2021, 11:30pm UTC](https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018/6 "2021-11-20T23:30:36Z")

</div>

> Here I am posting that playbook. please check it and suggest me…

Suggestion 1: don’t use the same meaningless names for several different tasks. Use something that explains what they do.  
Suggestion 2: use the lvol module instead of shell commands

---

<div class="post-metadata">

**Author:** ![Nuno\_Jordao](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@Nuno\_Jordao](https://forum.ansible.com/u/Nuno_Jordao)\
**Post date:** [November 21, 2021, 2:08am UTC](https://forum.ansible.com/t/gather-data-using-ansible-playbook/36018/7 "2021-11-21T02:08:19Z")

</div>

The variable you set in the register is an Ansible structure, you cant use it directly like you did here:

- name: lvm Extend  
shell: “/usr/bin/df -hT | grep {{ Mount\_point }} | cut -d. -f1 | awk ‘{print $2}’”  
**register: fs**

- name: ‘Extend the FS’  
filesystem:  
**fstype: “{{ fs }}”**  
dev: “/dev/mapper/{{ vg\_name }}-{{ lv\_name }}”  
resizefs: yes

You must check the manual and see its structure. In that case, maybe you want “fs.stdout”.

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html)

Regards.
