"""
"""
from __future__ import (absolute_import, division, print_function)
from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase
__metaclass__ = type
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
result="single_row"
return [result]
============================================
Multiple
============================================
"""
"""
from __future__ import (absolute_import, division, print_function)
from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase
__metaclass__ = type
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
result=[ "row1", "row2"]
return [result]
============================================
Play:
============================================
- block:
- name: Lookup 1
set_fact:
lookup1: "{{lookup('single')}}"
- debug: var="lookup1"
- name: Lookup 2
set_fact:
lookup2: "{{lookup('multiple')}}"
- debug: var="lookup2"
- set_fact:
previously_it_was_working: "{{lookup1[0]}}"
- set_fact:
now_only_this_working: "{{lookup2[0]}}"
- debug: msg="This debug should not be skipped {{previously_it_was_working}}"
- debug: msg="This debug should not be skipped too {{now_only_this_working}}"
- shell: "echo This might be errored but not skipped {{previously_it_was_working}}. And was working in Ansible 2.1"
- shell: "echo This might be errored too but definitely not skipped {{now_only_this_working}}}. And was working in Ansible 2.1"
when: 1==1
============================================
Expected result: returned array in both cases.
Side effect: in more complex production play actions like below now sometimes are just skipped?
- debug: msg="This debug should not be skipped {{previously_it_was_working}}"
- shell: "echo This might be errored but not skipped {{previously_it_was_working}}. And was working in Ansible 2.1"
Instead I have play:
=======================
ansible 2.2.0.0
config file =
configured module search path = Default w/o overrides
PLAY [Test play] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [Lookup 1] ****************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"lookup1": "single_row"
}
TASK [Lookup 2] ****************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"lookup2": [
"row1",
"row2"
]
}
TASK [set_fact] ****************************************************************
ok: [localhost]
TASK [set_fact] ****************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "This debug should not be skipped s"
}
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "This debug should not be skipped too row1"
}
TASK [command] *****************************************************************
changed: [localhost]
TASK [command] *****************************************************************
changed: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
}
PLAY RECAP *********************************************************************
localhost : ok=12 changed=2 unreachable=0 failed=0
========================