Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible remediation for configure_bashrc_exec_tmux #10584

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved
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