Archive Legacy Setup And Add Ansible Control Plane
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
bash_config_file: /etc/profile.d/homelab.sh
|
||||
bash_config_bashrc: /etc/bash.bashrc
|
||||
bash_config_legacy_user: ada
|
||||
bash_config_legacy_home: "/home/{{ bash_config_legacy_user }}"
|
||||
bash_config_legacy_profile_files:
|
||||
- /etc/profile.d/custom_bash.sh
|
||||
@@ -0,0 +1,63 @@
|
||||
- name: Install unified HomeLab bash config
|
||||
ansible.builtin.template:
|
||||
src: homelab.sh.j2
|
||||
dest: "{{ bash_config_file }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
|
||||
- name: Ensure system bashrc sources managed config
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ bash_config_bashrc }}"
|
||||
create: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
marker: "# {mark} ANSIBLE MANAGED HOMELAB BASH CONFIG"
|
||||
block: |
|
||||
if [ -f /etc/profile.d/homelab.sh ]; then
|
||||
. /etc/profile.d/homelab.sh
|
||||
fi
|
||||
|
||||
- name: List bash users with local home directories
|
||||
ansible.builtin.shell: >-
|
||||
getent passwd | awk -F: '$7 ~ /\/bash$/ && $6 ~ /^\// { print $1 ":" $6 }'
|
||||
register: bash_config_bash_users_raw
|
||||
changed_when: false
|
||||
|
||||
- name: Ensure bash users source managed system config
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ item.split(':')[1] }}/.bashrc"
|
||||
create: true
|
||||
owner: "{{ item.split(':')[0] }}"
|
||||
group: "{{ item.split(':')[0] }}"
|
||||
mode: "0644"
|
||||
marker: "# {mark} ANSIBLE MANAGED HOMELAB SYSTEM BASH CONFIG"
|
||||
block: |
|
||||
if [ -f /etc/profile.d/homelab.sh ]; then
|
||||
. /etc/profile.d/homelab.sh
|
||||
fi
|
||||
loop: "{{ bash_config_bash_users_raw.stdout_lines }}"
|
||||
|
||||
- name: Check legacy per-user bashrc
|
||||
ansible.builtin.stat:
|
||||
path: "{{ bash_config_legacy_home }}/.bashrc"
|
||||
register: bash_config_legacy_bashrc
|
||||
|
||||
- name: Remove legacy per-user bashrc source block
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ bash_config_legacy_home }}/.bashrc"
|
||||
marker: "# {mark} ANSIBLE MANAGED HOMELAB BASH CONFIG"
|
||||
state: absent
|
||||
when: bash_config_legacy_bashrc.stat.exists
|
||||
|
||||
- name: Remove legacy per-user bash config file
|
||||
ansible.builtin.file:
|
||||
path: "{{ bash_config_legacy_home }}/.bashrc.d/homelab.sh"
|
||||
state: absent
|
||||
|
||||
- name: Remove legacy profile scripts that conflict with unified config
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop: "{{ bash_config_legacy_profile_files }}"
|
||||
@@ -0,0 +1,44 @@
|
||||
# Managed by Ansible: HomeLab unified bash config.
|
||||
|
||||
export EDITOR="${EDITOR:-vim}"
|
||||
export PAGER="${PAGER:-less}"
|
||||
export LESS="${LESS:--FRSX}"
|
||||
export HISTCONTROL="ignoreboth:erasedups"
|
||||
export HISTSIZE=50000
|
||||
export HISTFILESIZE=100000
|
||||
shopt -s histappend 2>/dev/null || true
|
||||
shopt -s checkwinsize 2>/dev/null || true
|
||||
|
||||
case ":$PATH:" in
|
||||
*":$HOME/.local/bin:"*) ;;
|
||||
*) export PATH="$HOME/.local/bin:$PATH" ;;
|
||||
esac
|
||||
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
alias grep='grep --color=auto'
|
||||
alias ip='ip --color=auto'
|
||||
alias df='df -h'
|
||||
alias du='du -h'
|
||||
alias free='free -h'
|
||||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
alias please='sudo $(history -p !!)'
|
||||
|
||||
alias gs='git status --short --branch'
|
||||
alias gd='git diff'
|
||||
alias gl='git log --oneline --decorate -10'
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
alias sctl='systemctl'
|
||||
alias jctl='journalctl'
|
||||
fi
|
||||
|
||||
if [ -n "$PS1" ]; then
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
PS1='\[\e[31m\]\u@\h\[\e[0m\]:\[\e[34m\]\w\[\e[0m\]# '
|
||||
else
|
||||
PS1='\[\e[32m\]\u@\h\[\e[0m\]:\[\e[34m\]\w\[\e[0m\]\$ '
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user