1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-21 19:11:30 +01:00

ansible: cleanup setup playbook

This commit is contained in:
bretello 2024-01-03 15:21:17 +01:00
parent 208057ce91
commit bcad9f77aa
Signed by: brethil
GPG Key ID: 876AAC6290170FE7

View File

@ -1,10 +1,10 @@
--- ---
- hosts: all - name: Setup dotfiles
become: true hosts: all
vars_files: vars_files:
- ../ansible-packages.yml - ../ansible-packages.yml
vars: vars:
DOTFILES: "$HOME/.dotfiles" dotfiles_path: "$HOME/.dotfiles"
tasks: tasks:
- name: Install required system packages (debian) - name: Install required system packages (debian)
@ -13,18 +13,19 @@
update_cache: yes update_cache: yes
pkg: "{{ packages + packages_debian }}" pkg: "{{ packages + packages_debian }}"
when: ansible_facts['os_family'] == "Debian" when: ansible_facts['os_family'] == "Debian"
become: true
- name: Install required system packages (arch) - name: Install required system packages (arch)
pacman: pacman:
update_cache: yes update_cache: yes
name: "{{ packages + packages_archlinux }}" name: "{{ packages + packages_archlinux }}"
when: ansible_facts['os_family'] == "Archlinux" when: ansible_facts['os_family'] == "Archlinux"
become: true
- name: dotfiles repo - name: Clone dotfiles repo
git: git:
repo: https://git.decapod.one/brethil/dotfiles repo: https://git.decapod.one/brethil/dotfiles
dest: "{{ DOTFILES }}" dest: "{{ dotfiles_path }}"
version: master
when: local_development is not defined when: local_development is not defined
- name: directories - name: directories
@ -42,30 +43,32 @@
- "$HOME/.ssh/" - "$HOME/.ssh/"
- "$HOME/.ssh/sockets" - "$HOME/.ssh/sockets"
- name: antibody # TODO: antibody is available on apt(debian)/brew/pacman - name: Install antibody
shell: | shell: |
set -euo pipefail set -euo pipefail
curl -sfL https://git.io/antibody | sh -s - -b $HOME/bin/ curl -sfL https://git.io/antibody | sh -s - -b $HOME/bin/
$HOME/bin/antibody bundle "{{ DOTFILES }}/antibody_plugins.txt" $HOME/bin/antibody bundle "{{ dotfiles_path }}/antibody_plugins.txt"
args: args:
executable: /bin/bash executable: /bin/bash
creates: /usr/local/bin/antibody creates: bin/antibody
- name: zsh as default shell - name: Set zsh as default shell
user: user:
name: "{{ ansible_user }}" name: "{{ ansible_user }}"
shell: /usr/bin/zsh shell: /usr/bin/zsh
become: true
- name: zsh config - name: Update zshrc
blockinfile: blockinfile:
path: $HOME/.zshrc path: $HOME/.zshrc
marker: "# {mark} brethil dotfiles" marker: "# {mark} brethil dotfiles"
block: | block: |
export DOTFILES={{ DOTFILES }} export DOTFILES={{ dotfiles_path }}
source $DOTFILES/brethil_dotfile.sh source $DOTFILES/brethil_dotfile.sh
create: true create: true
mode: 600
- name: ssh config - name: Update .ssh/config
blockinfile: blockinfile:
path: $HOME/.ssh/config path: $HOME/.ssh/config
marker: "# {mark} brethil dotfiles" marker: "# {mark} brethil dotfiles"
@ -82,12 +85,11 @@
Host * Host *
ServerAliveInterval 300 ServerAliveInterval 300
create: true create: true
- name: dotfiles symlink - name: dotfiles symlinks
file: file:
src: "{{ DOTFILES }}/{{ item.key }}" src: "{{ dotfiles_path }}/{{ item.key }}"
dest: "{{ item.value }}" dest: "{{ item.value }}"
state: link state: link
force: yes force: yes
@ -101,19 +103,19 @@
"ansible/ansible.cfg": "~/.ansible.cfg" "ansible/ansible.cfg": "~/.ansible.cfg"
"gitignore": "~/.config/git/ignore" "gitignore": "~/.config/git/ignore"
- name: check undodir_migration - name: Exec vim undodir migration (if required)
stat: path=${HOME}/.vim_runtime/temp_dirs/undodir command: |
register: undodir mv ${HOME}/.vim_runtime/temp_dirs/undodir ${HOME}/.vim/undo
args:
removes: .vim_runtime/temp_dirs/undodir
- name: vim undodir migration - name: Install vim plugins
command: mv ${HOME}/.vim_runtime/temp_dirs/undodir ${HOME}/.vim/undo command: |
when: undodir.stat.exists env DOTFILES={{ dotfiles_path }} vim -c 'PlugInstall|qa!'
args:
creates: .vim/vim-plug
- name: vim plugins install - name: Get git config facts
# Open vim once so that the plugins are installed
command: echo | env DOTFILES={{ DOTFILES }} vim
- name: git config facts
community.general.git_config: community.general.git_config:
name: "include.path" name: "include.path"
scope: global scope: global
@ -121,10 +123,10 @@
- debug: - debug:
msg: "Git config include.path={{ config_value }}" msg: "Git config include.path={{ config_value }}"
- name: git config - name: Set up git config include if required
community.general.git_config: community.general.git_config:
name: "include.path" name: "include.path"
value: "{{ DOTFILES }}/gitconfig" value: "{{ dotfiles_path }}/gitconfig"
scope: global scope: global
when: config_value is not defined when: config_value is not defined
@ -133,17 +135,3 @@
src: ../../gitignore src: ../../gitignore
dest: ~/.gitignore dest: ~/.gitignore
mode: "0600" mode: "0600"
backup: yes
- name: annoyances
shell: |
## Fix scrolling in byobu
if [[ $(uname) == "Darwin" ]]; then
sed -i '' 's/set -g terminal-overrides/#set -g terminal-overrides/' /usr/local/share/byobu/profiles/tmux
else
sed -i 's/set -g terminal-overrides/#set -g terminal-overrides/' /usr/share/byobu/profiles/tmux
fi
sed 's|ls \\|#ls \\|' /etc/grc.zsh
args:
executable: /bin/bash
when: fix_annoyances is true