Skip to content

Commit

Permalink
Merge pull request #607 from Checkmk/fix/lookup_folder_examples
Browse files Browse the repository at this point in the history
Folder lookup module - Update and improve the examples.
  • Loading branch information
robin-checkmk committed Jun 3, 2024
2 parents 81ff91f + 5cd290f commit 86f4a0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion changelogs/fragments/lookup_folder.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
breaking_changes:
- Folder lookup module - Return the complete folder information, not only the extensions.
Refer to the module documentation for more details.
To adjust your playbooks, you have to use "{{ my_lookup_result.extensions }}" instead of
"{{ my_lookup_result }}".
30 changes: 15 additions & 15 deletions plugins/lookup/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,23 @@
"""

EXAMPLES = """
- name: Get the attributes of folder /tests
- name: Get the attributes of folders /tests and /snmp
ansible.builtin.debug:
msg: "Attributes of folder /network: {{ attributes }}"
vars:
attributes: "{{
lookup('checkmk.general.folder',
'~tests',
server_url=my_server_url,
site=mysite,
automation_user=myuser,
automation_secret=mysecret,
validate_certs=False
)
}}"
msg: "Extended attributes of folder /network: {{ attributes.extensions }}"
loop: "{{
lookup('checkmk.general.folder',
'~tests', '~snmp',
server_url=my_server_url,
site=mysite,
automation_user=myuser,
automation_secret=mysecret,
validate_certs=False
)
}}"
- name: "Use variables outside the module call."
ansible.builtin.debug:
msg: "Attributes of folder /network: {{ attributes }}"
msg: "Extended attributes of folder /network: {{ attributes.extensions }}"
vars:
ansible_lookup_checkmk_server_url: "http://myserver/"
ansible_lookup_checkmk_site: "mysite"
Expand All @@ -118,7 +117,8 @@
RETURN = """
_list:
description:
- A list of dicts of attributes of the folder(s)
- A dict of attributes of the folder if you query a single folder
- A list of dicts of attributes of the folders if you query multiple folders
type: list
elements: str
"""
Expand Down

0 comments on commit 86f4a0c

Please sign in to comment.