# Unable to  access variables from host\_vars dir however can access the same variables when specified in roles/defaults/mail.yml

**URL:** <https://forum.ansible.com/t/unable-to-access-variables-from-host-vars-dir-however-can-access-the-same-variables-when-specified-in-roles-defaults-mail-yml/32382>\
**Category:** Ansible Project\
**Created:** [March 4, 2020, 1:24pm UTC](https://forum.ansible.com/t/unable-to-access-variables-from-host-vars-dir-however-can-access-the-same-variables-when-specified-in-roles-defaults-mail-yml/32382 "2020-03-04T13:24:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vishal\_Bobade](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@Vishal\_Bobade](https://forum.ansible.com/u/Vishal_Bobade)\
**Post date:** [March 4, 2020, 1:24pm UTC](https://forum.ansible.com/t/unable-to-access-variables-from-host-vars-dir-however-can-access-the-same-variables-when-specified-in-roles-defaults-mail-yml/32382/1 "2020-03-04T13:24:28Z")

</div>

I have created multiple inventory files specific to dev , qa etc env. under inventory dir.

inventory/dev.domain.net.yml

Any suggestions, would help as I am stucked here…

---

<div class="post-metadata">

**Author:** ![Sagar\_Mujumale](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Sagar\_Mujumale](https://forum.ansible.com/u/Sagar_Mujumale)\
**Post date:** [March 4, 2020, 1:40pm UTC](https://forum.ansible.com/t/unable-to-access-variables-from-host-vars-dir-however-can-access-the-same-variables-when-specified-in-roles-defaults-mail-yml/32382/2 "2020-03-04T13:40:36Z")

</div>

Whats the problem? where do you stuck. Please post more information.

---

<div class="post-metadata">

**Author:** ![Vishal\_Bobade](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@Vishal\_Bobade](https://forum.ansible.com/u/Vishal_Bobade)\
**Post date:** [March 4, 2020, 1:49pm UTC](https://forum.ansible.com/t/unable-to-access-variables-from-host-vars-dir-however-can-access-the-same-variables-when-specified-in-roles-defaults-mail-yml/32382/3 "2020-03-04T13:49:44Z")

</div>

```auto
TASK [ansible-manage-lvm : manage_lvm | creating new LVM volume group(s)] ******
e[0;31mfatal: [grafana]: FAILED! => {"msg": "'config_lv_name' is undefined"}e[0m
e[0;31me[0m

```

I am gettin the above error when I am trying to create and procure lvm stuff on my new environment. I want to mention all the variables as a part of host\_vars like below:

```auto
# lvm variables

vg_name: "VolGroup01"
config_lv_name: "LogVol10"
data_lv_name: "LogVol11"
lvm_disk_name: "/dev/nvme2n1"
config_mntp: "/opt/tools"
data_mntp: "/data"
config_lv_size: "50G"
data_lv_size: "100G"

```

```auto

```

```auto

```

```auto
I am trying to use them as below :

```

```auto

```

```auto
lvm_groups:
      - vgname: "{{ vg_name }}"
        disks: 
          - "{{ lvm_disk_name }}"
        create: true
        lvnames:
          - lvname: "{{ config_lv_name }}"
            size: "{{ config_lv_size }}"
            create: true ## Mention "false" in case of lvm removal
            filesystem: xfs
            mount: true
            mntp: "{{ config_mntp }}"
            
          - lvname: "LogVol11"
            size: "{{ data_lv_size }}"
            create: true ## Mention "false" in case of lvm removal
            filesystem: xfs
            mount: true
            mntp: "{{ data_mntp }}"

    manage_lvm: true

```

---

<div class="post-metadata">

**Author:** ![Vishal\_Bobade](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@Vishal\_Bobade](https://forum.ansible.com/u/Vishal_Bobade)\
**Post date:** [March 4, 2020, 3:39pm UTC](https://forum.ansible.com/t/unable-to-access-variables-from-host-vars-dir-however-can-access-the-same-variables-when-specified-in-roles-defaults-mail-yml/32382/4 "2020-03-04T15:39:08Z")

</div>

@sagarmujumale - any idea on this?

---

<div class="post-metadata">

**Author:** ![anil\_gouranna](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@anil\_gouranna](https://forum.ansible.com/u/anil_gouranna)\
**Post date:** [March 5, 2020, 2:04pm UTC](https://forum.ansible.com/t/unable-to-access-variables-from-host-vars-dir-however-can-access-the-same-variables-when-specified-in-roles-defaults-mail-yml/32382/5 "2020-03-05T14:04:28Z")

</div>

i think you will have to provide the path using vars\_files in the playbook and then run.

---

<div class="post-metadata">

**Author:** ![klingac](https://avatars.discourse-cdn.com/v4/letter/k/ecd19e/32.png) [@klingac](https://forum.ansible.com/u/klingac)\
**Post date:** [March 6, 2020, 4:05pm UTC](https://forum.ansible.com/t/unable-to-access-variables-from-host-vars-dir-however-can-access-the-same-variables-when-specified-in-roles-defaults-mail-yml/32382/6 "2020-03-06T16:05:00Z")

</div>

Are you using `--limit` param for ansible-playbook?

Dne středa 4. března 2020 14:49:44 UTC+1 Vishal Bobade napsal(a):
