1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-22 11:31:30 +01:00
dotfiles/ansible/playbooks/setup.yml

Failed to ignore revisions in .git-blame-ignore-revs.

138 lines
3.7 KiB
YAML
Raw Normal View History

---
2024-01-03 15:21:17 +01:00
- name: Setup dotfiles
hosts: all
vars_files:
- ../ansible-packages.yml
vars:
2024-01-03 15:21:17 +01:00
dotfiles_path: "$HOME/.dotfiles"
tasks:
- name: Install required system packages (debian)
apt:
install_recommends: no
update_cache: yes
pkg: "{{ packages + packages_debian }}"
when: ansible_facts['os_family'] == "Debian"
2024-01-03 15:21:17 +01:00
become: true
- name: Install required system packages (arch)
pacman:
update_cache: yes
name: "{{ packages + packages_archlinux }}"
when: ansible_facts['os_family'] == "Archlinux"
2024-01-03 15:21:17 +01:00
become: true
2024-01-03 15:21:17 +01:00
- name: Clone dotfiles repo
git:
repo: https://git.decapod.one/brethil/dotfiles
2024-01-03 15:21:17 +01:00
dest: "{{ dotfiles_path }}"
when: local_development is not defined
2022-02-05 13:44:05 +01:00
- name: directories
file:
dest: "{{ item }}"
2022-02-05 13:44:05 +01:00
state: directory
mode: 0700
loop: "{{ directories }}"
2022-02-05 13:44:05 +01:00
vars:
directories:
- "$HOME/bin"
- "$HOME/projects"
- "$HOME/git"
- "$HOME/.config/git"
2024-01-02 15:51:01 +01:00
- "$HOME/.ssh/"
- "$HOME/.ssh/sockets"
2022-02-05 13:44:05 +01:00
2024-01-03 15:21:17 +01:00
- name: Install antibody
shell: |
2022-02-05 13:44:05 +01:00
set -euo pipefail
curl -sfL https://git.io/antibody | sh -s - -b $HOME/bin/
2024-01-03 15:21:17 +01:00
$HOME/bin/antibody bundle "{{ dotfiles_path }}/antibody_plugins.txt"
args:
executable: /bin/bash
2024-01-03 15:21:17 +01:00
creates: bin/antibody
2024-01-03 15:21:17 +01:00
- name: Set zsh as default shell
user:
name: "{{ ansible_user }}"
shell: /usr/bin/zsh
2024-01-03 15:21:17 +01:00
become: true
2024-01-03 15:21:17 +01:00
- name: Update zshrc
2022-02-05 13:44:05 +01:00
blockinfile:
path: $HOME/.zshrc
2023-09-14 22:58:43 +02:00
marker: "# {mark} brethil dotfiles"
2022-02-05 13:44:05 +01:00
block: |
2024-01-03 15:21:17 +01:00
export DOTFILES={{ dotfiles_path }}
2022-02-05 13:44:05 +01:00
source $DOTFILES/brethil_dotfile.sh
create: true
2024-01-03 15:21:17 +01:00
mode: 600
2024-01-03 15:21:17 +01:00
- name: Update .ssh/config
2024-01-02 15:51:01 +01:00
blockinfile:
path: $HOME/.ssh/config
marker: "# {mark} brethil dotfiles"
insertbefore: "BOF"
block: |
TCPKeepAlive=yes
ServerAliveCountMax=6
## Uncomment to enable compression for all ssh sessions
#Compression=yes
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%n:%p
ControlPersist yes
Host *
ServerAliveInterval 300
create: true
2024-01-03 15:21:17 +01:00
- name: dotfiles symlinks
file:
2024-01-03 15:21:17 +01:00
src: "{{ dotfiles_path }}/{{ item.key }}"
dest: "{{ item.value }}"
state: link
force: yes
loop: "{{ files | dict2items }}"
vars:
files:
"tmux.conf": "~/.tmux.conf"
"vim/vimrc": "~/.vimrc"
"pdbrc.py": "~/.pdbrc.py"
2020-12-09 01:54:42 +01:00
# "ipython": "~/.ipython" # FIXME: ipython config is more complex
"ansible/ansible.cfg": "~/.ansible.cfg"
"gitignore": "~/.config/git/ignore"
2024-01-03 15:21:17 +01:00
- name: Exec vim undodir migration (if required)
command: |
mv ${HOME}/.vim_runtime/temp_dirs/undodir ${HOME}/.vim/undo
args:
removes: .vim_runtime/temp_dirs/undodir
2020-12-09 01:54:42 +01:00
2024-01-03 15:21:17 +01:00
- name: Install vim plugins
command: |
env DOTFILES={{ dotfiles_path }} vim -c 'PlugInstall|qa!'
args:
creates: .vim/vim-plug
2024-01-03 15:21:17 +01:00
- name: Get git config facts
community.general.git_config:
name: "include.path"
scope: global
register: config_value
- debug:
msg: "Git config include.path={{ config_value }}"
2024-01-03 15:21:17 +01:00
- name: Set up git config include if required
community.general.git_config:
name: "include.path"
2024-01-03 15:21:17 +01:00
value: "{{ dotfiles_path }}/gitconfig"
scope: global
when: config_value is not defined
2021-01-09 21:28:21 +01:00
- name: git global .gitignore
copy:
src: ../../gitignore
dest: ~/.gitignore
mode: "0600"