2020-12-07 19:45:06 +01:00
|
|
|
---
|
2024-01-03 15:21:17 +01:00
|
|
|
- name: Setup dotfiles
|
|
|
|
hosts: all
|
2020-12-07 19:45:06 +01:00
|
|
|
vars_files:
|
|
|
|
- ../ansible-packages.yml
|
|
|
|
vars:
|
2024-01-03 15:21:17 +01:00
|
|
|
dotfiles_path: "$HOME/.dotfiles"
|
2020-12-07 19:45:06 +01:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Install required system packages (debian)
|
|
|
|
apt:
|
|
|
|
install_recommends: no
|
|
|
|
update_cache: yes
|
2022-12-18 13:19:53 +01:00
|
|
|
pkg: "{{ packages + packages_debian }}"
|
2020-12-07 19:45:06 +01:00
|
|
|
when: ansible_facts['os_family'] == "Debian"
|
2024-01-03 15:21:17 +01:00
|
|
|
become: true
|
2020-12-07 19:45:06 +01:00
|
|
|
|
2022-12-18 13:19:53 +01:00
|
|
|
- name: Install required system packages (arch)
|
2020-12-07 19:45:06 +01:00
|
|
|
pacman:
|
|
|
|
update_cache: yes
|
2022-12-18 13:19:53 +01:00
|
|
|
name: "{{ packages + packages_archlinux }}"
|
2020-12-07 19:45:06 +01:00
|
|
|
when: ansible_facts['os_family'] == "Archlinux"
|
2024-01-03 15:21:17 +01:00
|
|
|
become: true
|
2020-12-07 19:45:06 +01:00
|
|
|
|
2024-01-03 15:21:17 +01:00
|
|
|
- name: Clone dotfiles repo
|
2020-12-07 19:45:06 +01:00
|
|
|
git:
|
|
|
|
repo: https://git.decapod.one/brethil/dotfiles
|
2024-01-03 15:21:17 +01:00
|
|
|
dest: "{{ dotfiles_path }}"
|
2020-12-08 17:15:31 +01:00
|
|
|
when: local_development is not defined
|
2020-12-07 19:45:06 +01:00
|
|
|
|
2022-02-05 13:44:05 +01:00
|
|
|
- name: directories
|
|
|
|
file:
|
2022-12-18 13:19:53 +01:00
|
|
|
dest: "{{ item }}"
|
2022-02-05 13:44:05 +01:00
|
|
|
state: directory
|
|
|
|
mode: 0700
|
2022-12-18 13:19:53 +01:00
|
|
|
loop: "{{ directories }}"
|
2022-02-05 13:44:05 +01:00
|
|
|
vars:
|
|
|
|
directories:
|
2022-12-18 13:19:53 +01:00
|
|
|
- "$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
|
2020-12-07 19:45:06 +01:00
|
|
|
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"
|
2020-12-07 19:45:06 +01:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2024-01-03 15:21:17 +01:00
|
|
|
creates: bin/antibody
|
2020-12-07 19:45:06 +01:00
|
|
|
|
2024-01-03 15:21:17 +01:00
|
|
|
- name: Set zsh as default shell
|
2020-12-07 19:45:06 +01:00
|
|
|
user:
|
2022-12-18 13:19:53 +01:00
|
|
|
name: "{{ ansible_user }}"
|
2020-12-07 19:45:06 +01:00
|
|
|
shell: /usr/bin/zsh
|
2024-01-03 15:21:17 +01:00
|
|
|
become: true
|
2020-12-07 19:45:06 +01:00
|
|
|
|
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
|
2022-12-18 13:19:53 +01:00
|
|
|
create: true
|
2024-01-03 15:21:17 +01:00
|
|
|
mode: 600
|
2020-12-07 19:45:06 +01:00
|
|
|
|
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
|
2020-12-07 19:45:06 +01:00
|
|
|
file:
|
2024-01-03 15:21:17 +01:00
|
|
|
src: "{{ dotfiles_path }}/{{ item.key }}"
|
2022-12-18 13:19:53 +01:00
|
|
|
dest: "{{ item.value }}"
|
2020-12-07 19:45:06 +01:00
|
|
|
state: link
|
|
|
|
force: yes
|
2022-12-18 13:19:53 +01:00
|
|
|
loop: "{{ files | dict2items }}"
|
2020-12-07 19:45:06 +01:00
|
|
|
vars:
|
|
|
|
files:
|
2022-12-18 13:19:53 +01:00
|
|
|
"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
|
2022-12-18 13:19:53 +01:00
|
|
|
"ansible/ansible.cfg": "~/.ansible.cfg"
|
|
|
|
"gitignore": "~/.config/git/ignore"
|
2020-12-07 19:45:06 +01:00
|
|
|
|
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
|
2021-04-11 20:16:31 +02:00
|
|
|
|
2024-01-03 15:21:17 +01:00
|
|
|
- name: Get git config facts
|
2020-12-08 02:05:07 +01:00
|
|
|
community.general.git_config:
|
2022-12-18 13:19:53 +01:00
|
|
|
name: "include.path"
|
2020-12-08 02:05:07 +01:00
|
|
|
scope: global
|
|
|
|
register: config_value
|
|
|
|
- debug:
|
2022-12-18 13:19:53 +01:00
|
|
|
msg: "Git config include.path={{ config_value }}"
|
2020-12-08 02:05:07 +01:00
|
|
|
|
2024-01-03 15:21:17 +01:00
|
|
|
- name: Set up git config include if required
|
2020-12-07 19:45:06 +01:00
|
|
|
community.general.git_config:
|
2022-12-18 13:19:53 +01:00
|
|
|
name: "include.path"
|
2024-01-03 15:21:17 +01:00
|
|
|
value: "{{ dotfiles_path }}/gitconfig"
|
2020-12-08 02:05:07 +01:00
|
|
|
scope: global
|
|
|
|
when: config_value is not defined
|
2020-12-07 19:45:06 +01:00
|
|
|
|
2021-01-09 21:28:21 +01:00
|
|
|
- name: git global .gitignore
|
|
|
|
copy:
|
|
|
|
src: ../../gitignore
|
|
|
|
dest: ~/.gitignore
|
2022-12-18 13:19:53 +01:00
|
|
|
mode: "0600"
|