Merge remote-tracking branch 'origin/ansible'

This commit is contained in:
Fernando Schauenburg 2020-03-04 19:27:30 +01:00 committed by U-BOURNS\fernandos
commit facf7f2926
35 changed files with 330 additions and 2 deletions

2
.gitattributes vendored
View file

@ -1 +1 @@
dotfiles/.ssh/config filter=git-crypt diff=git-crypt roles/ssh/files/config filter=git-crypt diff=git-crypt

0
.gitmodules vendored
View file

22
dotfiles.yml Normal file
View file

@ -0,0 +1,22 @@
- name: Set up development machine
hosts: localhost
vars_prompt:
- name: git_user
private: no
default: Fernando Schauenburg
- name: git_email
private: no
default: fernando@schauenburg.me
roles:
- packages
- bin
- bash
- dircolors
- git
- hushlogin
- mintty
- python
- readline
- ssh
- tmux
- vim

View file

5
hosts Normal file
View file

@ -0,0 +1,5 @@
[local]
localhost
[local:vars]
ansible_connection=local

Binary file not shown.

33
roles/bash/tasks/main.yml Normal file
View file

@ -0,0 +1,33 @@
- name: Remove pre-installed bash configurations which could cause conflicts
file:
state: absent
path: "~/.{{ item }}"
loop:
- bash_logout
- profile
- name: Create the bash cache and config directories
file:
path: "{{ item }}"
state: directory
loop:
- "~/.cache/bash"
- "~/.config/bash"
- "~/.config/bash/completion.d"
- name: Deploy bash profile
file:
src: "{{ role_path }}/files/profile"
dest: ~/.config/bash/profile
state: link
force: yes
- name: Make sure bash will find our profile
file:
src: ~/.config/bash/profile
dest: "~/.{{ item }}"
state: link
force: yes
loop:
- bashrc
- bash_profile

14
roles/bin/tasks/main.yml Normal file
View file

@ -0,0 +1,14 @@
- name: Create local bin directory
file:
path: ~/.local/bin
state: directory
- name: Deploy local commands
file:
src: "{{ item }}"
dest: "~/.local/bin/{{ item | basename }}"
state: link
force: yes
with_fileglob:
- ./*

View file

@ -0,0 +1,15 @@
- name: Create the dircolors config directory
file:
path: ~/.config/dircolors
state: directory
- name: Deploy dircolors
file:
src: "{{ role_path }}/files/solarized-{{ item }}"
dest: "~/.config/dircolors/solarized-{{ item }}"
state: link
force: yes
loop:
- dark
- light

View file

@ -80,4 +80,5 @@
required = true required = true
[include] [include]
path = ~/.config/git/config.local path = ~/.config/git/config.host # host-specific (from template)
path = ~/.config/git/config.local # optional manual configurations

45
roles/git/tasks/main.yml Normal file
View file

@ -0,0 +1,45 @@
- name: Install git (Debian)
when: ansible_os_family == "Debian"
become: yes
apt: name={{ item }} state=latest update_cache=yes
loop: [git, git-crypt]
- name: Install git (macOS)
when: ansible_os_family == "Darwin"
homebrew: name={{ item }} state=latest
loop: [git, git-crypt]
- name: Create the git config directory
file:
path: ~/.config/git
state: directory
- name: Deploy git config
file:
src: "{{ role_path }}/files/{{ item }}"
dest: "~/.config/git/{{ item }}"
state: link
force: yes
loop:
- config
- ignore
- name: Deploy git host-specific config
template:
src: config.host.j2
dest: ~/.config/git/config.host
- name: Create bin directory for additional git commands
file:
path: ~/.local/bin
state: directory
- name: Deploy additional git commands
file:
src: "{{ item }}"
dest: "~/.local/bin/{{ item | basename }}"
state: link
force: yes
with_fileglob:
- ./bin/*

View file

@ -0,0 +1,9 @@
[user]
name = {{ git_user }}
email = {{ git_email }}
{% if ansible_os_family == 'Darwin' %}
[credential]
helper = osxkeychain
{% endif %}

View file

@ -0,0 +1,10 @@
- name: Check if hushlogin exists
register: hushlogin_stat
stat:
path: ~/.hushlogin
- name: Create hushlogin
when: hushlogin_stat.stat.exists == false
file:
state: touch
path: ~/.hushlogin

View file

@ -0,0 +1,12 @@
- name: Create the mintty config directory
file:
path: ~/.config/mintty
state: directory
- name: Deploy mintty config
file:
src: "{{ role_path }}/files/config"
dest: ~/.config/mintty/config
state: link
force: yes

View file

@ -0,0 +1,61 @@
- name: Set up Debian machine
when: ansible_os_family == "Debian"
become: yes
block:
- name: Install apt packages
apt: name={{ item }} state=latest update_cache=yes
loop:
- curl
- exuberant-ctags
- gpg
- htop
- psmisc
- shellcheck
- sqlite
- stow
- tree
- name: Set up macOS machine
when: ansible_os_family == "Darwin"
block:
- name: Install homebrew packages
homebrew: name={{ item }} state=latest
loop:
- coreutils
- ctags
- curl
- exiftool
- findutils
- gnu-sed
- gpg
- htop
- imagemagic
- jupyter
- pstree
- reattach-to-user-namespace
- shellcheck
- sqlite
- stow
- tree
- youtube-dl
- name: Tap into homebrew/cask-fonts
homebrew_tap: tap=homebrew/cask-fonts state=present
- name: Install Mac apps with homebrew cask
homebrew_cask: name={{item}} state=present
loop:
- 1password
- cyberduck
- dropbox
- firefox
- font-source-code-pro
- google-chrome
- iterm2
- transmission
- vagrant
- virtualbox

View file

@ -0,0 +1,25 @@
- name: Install python3 (Debian)
when: ansible_os_family == "Debian"
become: yes
apt: name={{ item }} state=latest update_cache=yes
loop: [python3, python3-pip]
- name: Install python3 (macOS)
when: ansible_os_family == "Darwin"
homebrew: name=python3 state=latest
- name: Create the python config and cache directories
file:
path: "~/.{{ item }}/python"
state: directory
loop:
- cache
- config
- name: Deploy python startup file
file:
src: "{{ role_path }}/files/startup.py"
dest: ~/.config/python/startup.py
state: link
force: yes

View file

@ -0,0 +1,12 @@
- name: Create the readline config directory
file:
path: ~/.config/readline
state: directory
- name: Deploy inputrc
file:
src: "{{ role_path }}/files/inputrc"
dest: ~/.config/readline/inputrc
state: link
force: yes

12
roles/ssh/tasks/main.yml Normal file
View file

@ -0,0 +1,12 @@
- name: Create the SSH directory
file:
path: ~/.ssh
state: directory
- name: Deploy SSH config
file:
src: "{{ role_path }}/files/config"
dest: ~/.ssh/config
state: link
force: yes

21
roles/tmux/tasks/main.yml Normal file
View file

@ -0,0 +1,21 @@
- name: Install tmux (Debian)
when: ansible_os_family == "Debian"
become: yes
apt: name=tmux state=latest update_cache=yes
- name: Install tmux (macOS)
when: ansible_os_family == "Darwin"
homebrew: name=tmux state=latest
- name: Create the tmux config directory
file:
path: ~/.config/tmux
state: directory
- name: Deploy tmux config
file:
src: "{{ role_path }}/files/tmux.conf"
dest: ~/.config/tmux/tmux.conf
state: link
force: yes

31
roles/vim/tasks/main.yml Normal file
View file

@ -0,0 +1,31 @@
- name: Install vim (Debian)
when: ansible_os_family == "Debian"
become: yes
apt: name=vim state=latest update_cache=yes
- name: Install vim (macOS)
when: ansible_os_family == "Darwin"
homebrew: name=vim state=latest
- name: Create the vim cache and config directories
file:
path: "{{ item }}"
state: directory
loop:
- "~/.cache/vim"
- "~/.config/vim"
- "~/.config/vim/autoload"
- name: Deploy vim plug and vimrc
file:
src: "{{ role_path }}/files/{{ item }}"
dest: "~/.config/vim/{{ item }}"
state: link
force: yes
loop:
- autoload/plug.vim
- vimrc
- name: Install configured vim plugins
shell: vim -u "~/.config/vim/vimrc" +PlugInstall +qall