community.general.xdg_mime module – Set default handler for MIME types, for applications using XDG tools
Note
This module is part of the community.general collection (version 10.7.3).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.xdg_mime.
New in community.general 10.7.0
Synopsis
- This module allows configuring the default handler for specific MIME types when you use applications that rely on XDG.
Parameters
Parameter | Comments |
|---|---|
handler string / required | Sets the default handler for the specified MIME types. The desktop file must be installed in the system. If the desktop file is not installed, the module does not fail, but the handler is not set either. You must pass a handler in the form |
mime_types list / elements=string / required | One or more MIME types for which a default handler is set. |
Attributes
Attribute | Support | Description |
|---|---|---|
check_mode | Support: full | Can run in |
diff_mode | Support: none | Will return details on what has changed (or possibly needs changing in |
Notes
Note
- This module is a thin wrapper around
xdg-mimetool. - See man xdg-mime(1) for more details.
See Also
See also
- C(xdg-mime) command manual page
-
Manual page for the command.
- xdg-utils Documentation
-
Reference documentation for xdg-utils.
Examples
- name: Set Chrome as the default handler for HTTPS
community.general.xdg_mime:
mime_types: x-scheme-handler/https
handler: google-chrome.desktop
register: result
- name: Set Chrome as the default handler for both HTTP and HTTPS
community.general.xdg_mime:
mime_types:
- x-scheme-handler/http
- x-scheme-handler/https
handler: google-chrome.desktop
register: result
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
current_handlers list / elements=string | Currently set handlers for the passed MIME types. Returned: success Sample: |
version string | Version of the Returned: always Sample: |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/xdg_mime_module.html