Files
role-common-packages/tasks/base-package-auxiliary-settings-tmux.yml
hygienic-books c57840bb11 fix(role): Delete tmux global config only if it exists
Do a aanity check if tmux global config exists.
2025-08-25 00:06:15 +02:00

32 lines
1.6 KiB
YAML

# 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: '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 Arch Linux and ''tmux-resurrect'' package is absent and system-wide config file ''{{ tmux_global_config_file }}'' is present remove config block from file'
when: '(ansible_facts[''os_family''] | lower == ''archlinux'') and (''tmux-resurrect'' not in ansible_facts.packages) and (role_common_packages__tmux_global_config_file_stats.stat.exists)'
ansible.builtin.blockinfile:
marker: '# {mark} ANSIBLE MANAGED BLOCK - tmux-resurrect'
path: '{{ tmux_global_config_file }}'
state: 'absent'
block: '{{ tmux_global_config_resurrect }}'
- name: 'If ''{{ tmux_global_config_file }}'' exists and is 0 bytes delete it'
when: '(role_common_packages__tmux_global_config_file_stats.stat.exists) and (role_common_packages__tmux_global_config_file_stats.stat.size == 0)'
ansible.builtin.file:
path: '{{ tmux_global_config_file }}'
state: 'absent'