Hmm, annoying. I was hoping to be able to say "if this isn't a list, and isn't a dict, then it might be a string" but instead "is sequence" returns true for list and dict and string... https://gist.github.com/JonTheNiceGuy/d19c26ed6ff7621fde1e84ceda8a473f
Last active
December 6, 2019 14:38
-
-
Save JonTheNiceGuy/d19c26ed6ff7621fde1e84ceda8a473f to your computer and use it in GitHub Desktop.
This file contains 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
--- | |
- hosts: localhost | |
gather_facts: false | |
vars: | |
a_list: ['1', '2', '3'] | |
a_dict: {'a': 'value', 'b': 'value'} | |
a_string: "abc123" | |
a_list_of_dicts: [{'a': 'value'}, {'a': 'value'}] | |
tasks: | |
- debug: | |
msg: | | |
[ | |
"a_list is a list? {{ a_list is sequence() }}", | |
"a_list is a dict? {{ a_list is mapping() }}", | |
"a_list is neither? {{ (not a_list is sequence()) and (not a_list is mapping()) }}", | |
"", | |
"a_dict is a list? {{ a_dict is sequence() }}", | |
"a_dict is a dict? {{ a_dict is mapping() }}", | |
"a_dict is neither? {{ (not a_dict is sequence()) and (not a_dict is mapping()) }}", | |
"", | |
"a_string is a list? {{ a_string is sequence() }}", | |
"a_string is a dict? {{ a_string is mapping() }}", | |
"a_string is neither? {{ (not a_string is sequence()) and (not a_string is mapping()) }}", | |
"", | |
"a_list_of_dicts is a list? {{ a_list_of_dicts is sequence() }}", | |
"a_list_of_dicts is a dict? {{ a_list_of_dicts is mapping() }}", | |
"a_list_of_dicts is neither? {{ (not a_list_of_dicts is sequence()) and (not a_list_of_dicts is mapping()) }}" | |
] | |
This file contains 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
[WARNING]: No inventory was parsed, only implicit localhost is available | |
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' | |
PLAY [localhost] ******************************************************************************************************************* | |
TASK [debug] *********************************************************************************************************************** | |
ok: [localhost] => { | |
"msg": [ | |
"a_list is a list? True", | |
"a_list is a dict? False", | |
"a_list is neither? False", | |
"", | |
"a_dict is a list? False", | |
"a_dict is a dict? True", | |
"a_dict is neither? False", | |
"", | |
"a_string is a list? False", | |
"a_string is a dict? False", | |
"a_string is neither? True", | |
"", | |
"a_list_of_dicts is a list? True", | |
"a_list_of_dicts is a dict? False", | |
"a_list_of_dicts is neither? False" | |
] | |
} | |
PLAY RECAP ************************************************************************************************************************* | |
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
This file contains 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
[WARNING]: No inventory was parsed, only implicit localhost is available | |
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' | |
PLAY [localhost] ******************************************************************************************************************* | |
TASK [debug] *********************************************************************************************************************** | |
ok: [localhost] => { | |
"msg": [ | |
"a_list is a list? True", | |
"a_list is a dict? False", | |
"a_list is neither? False", | |
"", | |
"a_dict is a list? True", | |
"a_dict is a dict? True", | |
"a_dict is neither? False", | |
"", | |
"a_string is a list? True", | |
"a_string is a dict? False", | |
"a_string is neither? False", | |
"", | |
"a_list_of_dicts is a list? True", | |
"a_list_of_dicts is a dict? False", | |
"a_list_of_dicts is neither? False" | |
] | |
} | |
PLAY RECAP ************************************************************************************************************************* | |
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment