feat(role): Add package-specific global config files
Packages can now have a global (i.e. system-wide) config defined and applied. If package is missing the config file is deleted. This is helpful for example for Git where we want to define helpful aliases for every logged in user and for tmux where every user should have access to the tmux-resurrect session manager etc.
This commit is contained in:
31
tasks/base-package-auxiliary-settings-tmux.yml
Normal file
31
tasks/base-package-auxiliary-settings-tmux.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
- name: 'If Arch Linux and if ''tmux-resurrect'' and ''tmux'' packages are present auto-load tmux-resurrect on tmux start system-wide'
|
||||
when: '(ansible_facts[''os_family''] | lower == ''archlinux'') and (''tmux-resurrect'' in ansible_facts.packages) and (''tmux'' in ansible_facts.packages)'
|
||||
ansible.builtin.blockinfile:
|
||||
marker: '# {mark} ANSIBLE MANAGED BLOCK - tmux-resurrect'
|
||||
path: '{{ tmux_global_config_file }}'
|
||||
append_newline: true
|
||||
prepend_newline: true
|
||||
state: 'present'
|
||||
create: true
|
||||
block: '{{ tmux_global_config_resurrect }}'
|
||||
|
||||
- name: 'If Arch Linux and ''tmux-resurrect'' package is absent never auto-load tmux-resurrect on tmux start system-wide'
|
||||
when: '(ansible_facts[''os_family''] | lower == ''archlinux'') and (''tmux-resurrect'' not in ansible_facts.packages)'
|
||||
ansible.builtin.blockinfile:
|
||||
marker: '# {mark} ANSIBLE MANAGED BLOCK - tmux-resurrect'
|
||||
path: '{{ tmux_global_config_file }}'
|
||||
state: 'absent'
|
||||
block: '{{ tmux_global_config_resurrect }}'
|
||||
|
||||
- name: 'Get stats of ''{{ tmux_global_config_file }}'''
|
||||
ansible.builtin.stat:
|
||||
path: '{{ tmux_global_config_file }}'
|
||||
register: 'role_common_packages__tmux_global_config_file_stats'
|
||||
|
||||
- name: 'If ''{{ tmux_global_config_file }}'' is 0 bytes delete it'
|
||||
when: 'role_common_packages__tmux_global_config_file_stats.stat.size == 0'
|
||||
ansible.builtin.file:
|
||||
path: '{{ tmux_global_config_file }}'
|
||||
state: 'absent'
|
||||
|
Reference in New Issue
Block a user