diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_exec_tmux/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_exec_tmux/ansible/shared.yml new file mode 100644 index 00000000000..8a64b5ea8b2 --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_exec_tmux/ansible/shared.yml @@ -0,0 +1,33 @@ +# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol +# reboot = false +# strategy = configure +# complexity = low +# disruption = low + +- name: "{{{ rule_title }}}: Determine If the Tmux Launch Script Is Present in /etc/bashrc" + ansible.builtin.find: + paths: '/etc' + patterns: 'bashrc' + contains: '.*case "$name" in sshd|login) exec tmux ;; esac.*' + register: tmux_in_bashrc + +- name: "{{{ rule_title }}}: Determine If the Tmux Launch Script Is Present in /etc/profile.d/*.sh" + ansible.builtin.find: + paths: '/etc/profile.d' + patterns: '*.sh' + contains: .*case "$name" in sshd|login) exec tmux ;; esac.* + register: tmux_in_profile_d + +- name: "{{{ rule_title }}}: Insert the Correct Script into /etc/profile.d/tmux.sh" + ansible.builtin.blockinfile: + path: '/etc/profile.d/tmux.sh' + block: | + if [ "$PS1" ]; then + parent=$(ps -o ppid= -p $$) + name=$(ps -o comm= -p $parent) + case "$name" in sshd|login) exec tmux ;; esac + fi + create: true + when: + - tmux_in_bashrc is defined and tmux_in_bashrc.matched == 0 + - tmux_in_profile_d is defined and tmux_in_profile_d.matched == 0