djonasson.xdg_bds
Ansible Role: XDG BDS
This Ansible role sets up the XDG Base Directory Specification shell variables and directories.
Requirements
No special requirements.
Role Variables
The variables for this role are found in defaults/main.yml
with these defaults:
xdg_configure_state
: presentThis indicates whether the settings will be written using the blockinfile module. Possible values are [present, absent].
xdg_marker
: "# {mark} ANSIBLE MANAGED BLOCK (djonasson.xdg_bds)"The marker line template for identifying blocks in configuration files.
xdg_data_home
: "{{ ansible_user_dir }}/.local/share"This sets the base directory where user-specific data files should be kept. If it is not set, the default will be
$HOME/.local/share
.xdg_config_home
: "{{ ansible_user_dir }}/.config"This sets the base directory for user-specific configuration files. If not set, the default will be
$HOME/.config
.xdg_state_home
: "{{ ansible_user_dir }}/.local/state"This defines where user-specific state files should be stored. If not set, the default will be
$HOME/.local/state
.The state files hold data that should be kept between application restarts but isn't crucial enough to go into
$XDG_DATA_HOME
. It may include:- Action history (like logs and recent files)
- Current application state that can be reused after restart (like views and layouts)
User-specific executable files should go in $HOME/.local/bin
. This directory should be included in the UNIX $PATH
environment variable.
As $HOME
may be shared across different architectures, having compiled binaries in $HOME/.local/bin
can lead to issues when switching systems. Keep this in mind.
xdg_data_dirs
: "/usr/local/share/:/usr/share"This is the prioritized list of directories where system data files will be searched, in addition to
$XDG_DATA_HOME
. Each directory is separated by a colon ':'.If not set, the default value will be
/usr/local/share/:/usr/share/
.xdg_config_dirs
: "/etc/xdg"This is the ordered list of directories for searching configuration files, besides
$XDG_CONFIG_HOME
. Each directory is separated by a colon ':'.If not set, the default is
/etc/xdg
.
The order indicates importance; the first directory listed is the most important. If the same information exists in multiple locations, the one in the more important directory takes precedence.
xdg_cache_home
: "{{ ansible_user_dir }}/.cache"This defines where user-specific non-essential data files should be stored. If not set, the default will be
$HOME/.cache
.xdg_runtime_dir
:This defines where non-essential runtime files (like sockets or named pipes) should be stored. The directory must be owned by the user and have a strict access setting (0700).
The lifetime of this directory should match the user session. It must be created upon the first login and removed when the user fully logs out. If the user logs in multiple times, they should always access the same directory, and it should persist through their session.
This directory must not be shared with other systems and must support the complete set of standard file functionalities.
If
$XDG_RUNTIME_DIR
is not set, applications should use a fallback directory and display a warning message. This directory is meant for communication and synchronization, and larger files should not be placed here.
Dependencies
None.
Example Playbook
- hosts: localhost
roles:
- role: djonasson.xdg_bds
License
MIT
Author
This Ansible role was created by Daniel Jonasson.
Ansible role to configure XDG Base Directory Specification shell variables and directories.
ansible-galaxy install djonasson.xdg_bds