move most important config to ansible

This commit is contained in:
Johannes Knopp
2025-09-06 15:44:39 +02:00
parent 7770c4b5e4
commit 14e4d4fe3e
49 changed files with 179 additions and 327 deletions

View File

@ -1,20 +1,19 @@
default_roles: default_roles:
# === Core System Tools (Recommended) === # === Core System Tools (Recommended) ===
- system # Essential system configurations and tools - system # Essential system configurations and tools
- fonts # Developer-friendly fonts (Nerd Fonts) # - fonts # Developer-friendly fonts (Nerd Fonts)
# === Development Core === # === Development Core ===
- git # Version control system # - git # Version control system
- neovim # Modern text editor (or use 'vim') - nvim # Modern text editor (or use 'vim')
- tmux # Terminal multiplexer for session management # - tmux # Terminal multiplexer for session management
#
# === Shell Environment === # === Shell Environment ===
- zsh # Modern shell with oh-my-zsh - zsh # Modern shell with oh-my-zsh
# - ssh
temp:
# === Development Languages === # === Development Languages ===
- nvm # Node Version Manager
- npm # Node Package Manager
- go # Go programming language
# - rust # Rust programming language # - rust # Rust programming language
# - ruby # Ruby programming language # - ruby # Ruby programming language
# - lua # Lua programming language # - lua # Lua programming language
@ -22,81 +21,55 @@ default_roles:
- docker # Container platform - docker # Container platform
# === System Monitoring === # === System Monitoring ===
- btop # Modern system monitor (better than htop)
# - neofetch # System information display
# - nerdfetch # Alternative system info with ASCII art
# - ncdu # Disk usage analyzer
# === Terminal Emulators === # === Terminal Emulators ===
- ghostty
# - kitty # GPU-accelerated terminal # - kitty # GPU-accelerated terminal
# - warp # Modern terminal with AI features # - warp # Modern terminal with AI features
# === Productivity Tools === # === Productivity Tools ===
# - obsidian # Knowledge management and note-taking # - obsidian # Knowledge management and note-taking
# - raycast # macOS launcher and productivity tool
# - hammerspoon # macOS automation and window management
# - taskfile # Modern task runner (alternative to make)
# - tldr # Simplified command documentation
# - slides # Terminal-based presentation tool
# === Communication & Media === system_packages:
# - discord # Team communication # Network
# - spotify # Music streaming - curl
- wget
- rsync
- nmap
# - nslookup
# - dig
# === Network & Remote Access === # archive/compression
# - ssh # SSH client configuration - unzip
# - sshfs # Mount remote filesystems via SSH - tar
# - tmate # Terminal sharing for pair programming
# === macOS Specific === # text processing
# - aldente # Battery charge limiter for macOS - jq
- ripgrep
- fd
# === Linux Specific === # utilities
# - flatpak # Universal Linux package manager - btop
# - nala # Better apt frontend for Ubuntu/Debian - which
# - fzf
- bat
- eza
- tealdeer
- neofetch
# === Browser Tools === # dev
# - brave # Privacy-focused web browser - nvm
- go
- discord # Team communication
# === Cloud & Infrastructure CLIs ===
# - aws # Amazon Web Services CLI
# - azure # Microsoft Azure CLI
# - nomad # HashiCorp Nomad (alternative to Kubernetes)
# === Container Alternatives === # TODO
# - orbstack # Docker Desktop alternative for macOS aur_packages:
- autojump
- spotify
- qownnotes
- stripe-cli
- pgformatter-git
# - jetbrains-toolbox
# === Additional Terminal Emulators === config_dir: "{{ ansible_facts.env.HOME }}/.config"
# - alacritty # Cross-platform GPU-accelerated terminal
# - ghostty # Fast, feature-rich terminal emulator
# === Development Tools ===
# - just # Command runner (modern alternative to make)
# - goreleaser # Go application release automation
# === Kubernetes Ecosystem ===
# - kind # Kubernetes in Docker for local testing
# - kwctl # Kubernetes policy engine management
# === Network & VPN Tools ===
# - wireguard # Modern VPN solution
# === Alternative Shells ===
# - bash # Traditional bash shell configuration
# - pwsh # PowerShell for cross-platform scripting
# - zellij # Terminal workspace manager (alternative to tmux)
# === Package Managers ===
# - whalebrew # Homebrew but with Docker images
# === Windows Specific ===
# - winget # Windows package manager (Windows only)
# === Fun Stuff ===
# - asciiquarium # Animated ASCII aquarium for your terminal
# === Security & Authentication ===
# - 1password # 1Password CLI integration
# === Network Analysis ===
# - tshark # Command-line network protocol analyzer

View File

@ -1,2 +1,2 @@
[local] [local]
localhost ansible_connection=local localhost ansible_connection=local ansible_user=johannes

View File

@ -5,123 +5,24 @@
become: false become: false
vars: vars:
dotfiles_dir: "{{ ansible_env.HOME }}/dotfiles" dotfiles_dir: "{{ ansible_env.HOME }}/dotfiles"
# roles:
# - zsh
pre_tasks:
- name: Create btrfs snapshot before changes
shell: |
sudo btrfs subvolume snapsho / /.snapshots/before-dotfiles-$(date +%Y%m%d-%H%M%S)
tags: [snapshot]
become: true
become_method: sudo
tasks: tasks:
- name: Install packages with pacman - name: Install enabled roles
become: true ansible.builtin.include_role:
pacman: name: "{{ item }}"
name: apply:
- neovim tags:
- zsh - install
- git
- openssh
state: present
- name: Install oh-my-zsh from AUR
kewlfft.aur.aur:
name: oh-my-zsh-git
state: present
- name: Create necessary directories
file:
path: "{{ item }}"
state: directory
mode: '0755'
loop: loop:
- "{{ ansible_env.HOME }}/.config" "{{ default_roles }}"
- "{{ ansible_env.HOME }}/.ssh" # when: default_roles is defined
- name: Check if neovim config exists
stat:
path: "{{ dotfiles_dir }}/nvim"
register: nvim_config
- name: Symlink neovim config
file:
src: "{{ dotfiles_dir }}/nvim"
dest: "{{ ansible_env.HOME }}/.config/nvim"
state: link
force: true
when: nvim_config.stat.exists
- name: Check if zsh config exists
stat:
path: "{{ dotfiles_dir }}/zsh/.zshrc"
register: zsh_config
- name: Symlink zsh config
file:
src: "{{ dotfiles_dir }}/zsh/.zshrc"
dest: "{{ ansible_env.HOME }}/.zshrc"
state: link
force: true
when: zsh_config.stat.exists
- name: Change default shell to zsh
become: true
user:
name: "{{ ansible_env.USER }}"
shell: /usr/bin/zsh
- name: Symlink SSH askpass config
file:
src: "{{ dotfiles_dir }}/ssh_askpass.conf"
dest: "{{ ansible_env.HOME }}/.ssh/askpass.conf"
state: link
force: true
when: zsh_config.stat.exists
- name: Check if git config exists
stat:
path: "{{ dotfiles_dir }}/git/.gitconfig"
register: git_config
- name: Symlink global git config
file:
src: "{{ dotfiles_dir }}/git/.gitconfig"
dest: "{{ ansible_env.HOME }}/.gitconfig"
state: link
force: true
when: git_config.stat.exists
- name: Check if kde config exists
stat:
path: "{{ dotfiles_dir }}/kde"
register: kde_config
- name: Find KDE config files in dotfiles
find:
paths: "{{ dotfiles_dir }}/kde"
patterns: "*"
file_type: file
register: kde_configs
when: kde_config.stat.exists
- name: Symlink KDE config files
file:
src: "{{ item.path }}"
dest: "{{ ansible_env.HOME }}/.config/{{ item.path | basename }}"
state: link
force: true
loop: "{{ kde_configs.files }}"
when: kde_configs.files is defined
- name: Install yay if not present (for AUR packages)
block:
- name: Check if yay is installed
command: which yay
register: yay_check
failed_when: false
changed_when: false
- name: Install yay from AUR
become: true
shell: |
cd /tmp
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si --noconfirm
cd ..
rm -rf yay
when: yay_check.rc != 0

View File

@ -6,7 +6,7 @@ local opts = { noremap = true, silent = true }
-- INSERT MODE -- INSERT MODE
-- map `ctrl + backspace` to delete previous word in insert mode -- map `ctrl + backspace` to delete previous word in insert mode
keymap.set('i', '<C-H>', '<C-W>', opts) keymap.set('i', '<C-BS>', '<C-W>', opts)
-- map `ctrl + delete` to delete next word in insert mode -- map `ctrl + delete` to delete next word in insert mode
keymap.set('i', '<C-Del>', '<C-o>dw', opts) keymap.set('i', '<C-Del>', '<C-o>dw', opts)

12
roles/nvim/tasks/main.yml Normal file
View File

@ -0,0 +1,12 @@
---
- name: Install neovim
package:
name: neovim
state: present
- name: Symlink neovim
file:
src: "{{ role_path }}/files"
dest: "{{ config_dir }}/nvim"
state: link
force: true

View File

@ -0,0 +1,20 @@
---
- name: Update package cache (Arch-based systems)
pacman:
update_cache: yes
when: ansible_os_family == "Archlinux"
become: yes
- name: Install system packages
package:
name: "{{ system_packages }}"
state: present
become: yes
- name: Ensure .config directory exists
file:
path: "{{ config_dir }}"
state: directory
mode: '0755'
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"

52
roles/zsh/files/.zshrc Normal file
View File

@ -0,0 +1,52 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
# Path to your Oh My Zsh installation.
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="bira"
zstyle ':omz:update' mode reminder # just remind me to update when it's time
COMPLETION_WAITING_DOTS="true"
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
fzf-zsh-plugin
)
source $ZSH/oh-my-zsh.sh
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='nvim'
fi
# TODO prettier solution?
DOTFILES_ZSH_DIR="${0:A:h}"
for zsh_file in "$DOTFILES_ZSH_DIR"/*.zsh; do
[[ -r "$zsh_file" ]] && source "$zsh_file"
done
# TODO source all files with .zsh suffix
# source ./aliases.zsh
# source ./dev_env.zsh
# source ./tools.zsh
# TODO
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
if [[ -n "$MACHINE_TYPE" && -f "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" ]]; then
source "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh"
fi
alias drun='docker run -it --network=host --device=/dev/kfd --device=/dev/dri --group-add=video --ipc=host --cap-add=SYS_PTRACE --security-opt seccomp=unconfined'

24
roles/zsh/tasks/main.yaml Normal file
View File

@ -0,0 +1,24 @@
---
- name: Install zsh
package:
name: zsh
state: present
- name: Install oh-my-zsh
shell: |
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended
args:
creates: "{{ ansible_env.HOME }}/.oh-my-zsh"
- name: Check for custom zshrc
stat:
path: "{{ role_path }}/files/.zshrc"
register: custom_zshrc
- name: Symlink custom zshrc
file:
src: "{{ role_path }}/files/.zshrc"
dest: "{{ ansible_env.HOME }}/.zshrc"
state: link
force: yes
when: custom_zshrc.stat.exists

View File

@ -1,130 +0,0 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
# Path to your Oh My Zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time Oh My Zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="bira"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
fzf-zsh-plugin
)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='nvim'
fi
# Compilation flags
# export ARCHFLAGS="-arch $(uname -m)"
# Set personal aliases, overriding those provided by Oh My Zsh libs,
# plugins, and themes. Aliases can be placed here, though Oh My Zsh
# users are encouraged to define aliases within a top-level file in
# the $ZSH_CUSTOM folder, with .zsh extension. Examples:
# - $ZSH_CUSTOM/aliases.zsh
# - $ZSH_CUSTOM/macos.zsh
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# bindkey '^R' history-incremental-search-backward
# TODO source all files with .zsh suffix
source ~/dotfiles/zsh/aliases.zsh
source ~/dotfiles/zsh/dev_env.zsh
source ~/dotfiles/zsh/tools.zsh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
if [[ -n "$MACHINE_TYPE" && -f "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" ]]; then
source "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh"
fi
alias drun='docker run -it --network=host --device=/dev/kfd --device=/dev/dri --group-add=video --ipc=host --cap-add=SYS_PTRACE --security-opt seccomp=unconfined'