diff --git a/changelogs/fragments/lookup_folder.yml b/changelogs/fragments/lookup_folder.yml index dc1599cd1..0a058da21 100644 --- a/changelogs/fragments/lookup_folder.yml +++ b/changelogs/fragments/lookup_folder.yml @@ -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 }}". diff --git a/plugins/lookup/folder.py b/plugins/lookup/folder.py index 0cf53d4e6..e4e058bb8 100644 --- a/plugins/lookup/folder.py +++ b/plugins/lookup/folder.py @@ -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" @@ -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 """