question on LVM exists or not

139 views
Skip to first unread message

subbamma natla

unread,
Mar 16, 2022, 7:08:02 PM3/16/22
to ansible...@googlegroups.com
why am I getting output when " when: ansible_facts['lvm']['lvs']['lv_mysql'] is not defined"
---
- hosts: database
  gather_facts: yes
  tasks:
  - name: check lv_mysql exists
    debug:
      msg: "LV_MYSQL not there"
    when: ansible_facts['lvm']['lvs']['lv_mysql'] is not defined

  - name: check lv_mysql exists
    debug:
      msg: "LV_MYSQL is there"
    when: ansible_facts['lvm']['lvs']['lv_mysql'] is defined
output:
TASK [check lv_mysql exists] **********************************************************************************************************
ok: [mhost5] => {
    "msg": "LV_MYSQL not there"
}

TASK [check lv_mysql exists] **********************************************************************************************************
skipping: [mhost5]

John Petro

unread,
Mar 16, 2022, 9:45:44 PM3/16/22
to ansible...@googlegroups.com
Well,
  Someone else might have a clearer answer, but the way you coded it, the task would be skipped if ln_mysql is not defined.  Did you try adding some verbosity to the ansible-playbook command?  When something like this happens to me, I go right for the -vvvv and that will usually point me in the right direction.

--John

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJVhugJz5Wn%2BjokOWtAcN2p2guHTqM%2BrxV%2BztLYpQ-Zy%2BtYD_A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages