Created
December 8, 2016 19:52
-
-
Save Voronenko/81750ada56425b268dd23f4bfda5185b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
""" | |
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Test play | |
hosts: all | |
tasks: | |
- 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" | |
- debug: msg="Nice to meet you http://github.com/voronenko" | |
when: 1==1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ ansible_bug ./run.sh | |
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] => { | |
"msg": "Nice to meet you http://github.com/voronenko" | |
} | |
PLAY RECAP ********************************************************************* | |
localhost : ok=12 changed=2 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
""" | |
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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment