diff --git a/.gitattributes b/.gitattributes index e0de9b0..98a8062 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -dotfiles/.ssh/config filter=git-crypt diff=git-crypt +roles/ssh/files/config filter=git-crypt diff=git-crypt diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29..0000000 diff --git a/dotfiles.yml b/dotfiles.yml new file mode 100644 index 0000000..9d4f343 --- /dev/null +++ b/dotfiles.yml @@ -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 diff --git a/dotfiles/.hushlogin b/dotfiles/.hushlogin deleted file mode 100644 index e69de29..0000000 diff --git a/hosts b/hosts new file mode 100644 index 0000000..f4687cf --- /dev/null +++ b/hosts @@ -0,0 +1,5 @@ +[local] +localhost + +[local:vars] +ansible_connection=local diff --git a/dotfiles/.config/bash/profile b/roles/bash/files/profile similarity index 100% rename from dotfiles/.config/bash/profile rename to roles/bash/files/profile diff --git a/roles/bash/tasks/.main.yml.swp b/roles/bash/tasks/.main.yml.swp new file mode 100644 index 0000000..80343ad Binary files /dev/null and b/roles/bash/tasks/.main.yml.swp differ diff --git a/roles/bash/tasks/main.yml b/roles/bash/tasks/main.yml new file mode 100644 index 0000000..30f5e2b --- /dev/null +++ b/roles/bash/tasks/main.yml @@ -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 diff --git a/dotfiles/.local/bin/vboxmount b/roles/bin/files/vboxmount similarity index 100% rename from dotfiles/.local/bin/vboxmount rename to roles/bin/files/vboxmount diff --git a/roles/bin/tasks/main.yml b/roles/bin/tasks/main.yml new file mode 100644 index 0000000..93f72ba --- /dev/null +++ b/roles/bin/tasks/main.yml @@ -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: + - ./* + diff --git a/dotfiles/.config/dircolors/solarized-dark b/roles/dircolors/files/solarized-dark old mode 100755 new mode 100644 similarity index 100% rename from dotfiles/.config/dircolors/solarized-dark rename to roles/dircolors/files/solarized-dark diff --git a/dotfiles/.config/dircolors/solarized-light b/roles/dircolors/files/solarized-light old mode 100755 new mode 100644 similarity index 100% rename from dotfiles/.config/dircolors/solarized-light rename to roles/dircolors/files/solarized-light diff --git a/roles/dircolors/tasks/main.yml b/roles/dircolors/tasks/main.yml new file mode 100644 index 0000000..adca248 --- /dev/null +++ b/roles/dircolors/tasks/main.yml @@ -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 + diff --git a/dotfiles/.local/bin/git-churn b/roles/git/files/bin/git-churn similarity index 100% rename from dotfiles/.local/bin/git-churn rename to roles/git/files/bin/git-churn diff --git a/dotfiles/.local/bin/git-what-the-hell-just-happened b/roles/git/files/bin/git-what-the-hell-just-happened similarity index 100% rename from dotfiles/.local/bin/git-what-the-hell-just-happened rename to roles/git/files/bin/git-what-the-hell-just-happened diff --git a/dotfiles/.local/bin/git-wtf b/roles/git/files/bin/git-wtf similarity index 100% rename from dotfiles/.local/bin/git-wtf rename to roles/git/files/bin/git-wtf diff --git a/dotfiles/.config/git/config b/roles/git/files/config similarity index 93% rename from dotfiles/.config/git/config rename to roles/git/files/config index 7cfbb6f..7af5964 100644 --- a/dotfiles/.config/git/config +++ b/roles/git/files/config @@ -80,4 +80,5 @@ required = true [include] - path = ~/.config/git/config.local + path = ~/.config/git/config.host # host-specific (from template) + path = ~/.config/git/config.local # optional manual configurations diff --git a/dotfiles/.config/git/ignore b/roles/git/files/ignore similarity index 100% rename from dotfiles/.config/git/ignore rename to roles/git/files/ignore diff --git a/roles/git/tasks/main.yml b/roles/git/tasks/main.yml new file mode 100644 index 0000000..1490090 --- /dev/null +++ b/roles/git/tasks/main.yml @@ -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/* + diff --git a/roles/git/templates/config.host.j2 b/roles/git/templates/config.host.j2 new file mode 100644 index 0000000..33f5074 --- /dev/null +++ b/roles/git/templates/config.host.j2 @@ -0,0 +1,9 @@ +[user] + name = {{ git_user }} + email = {{ git_email }} + +{% if ansible_os_family == 'Darwin' %} +[credential] + helper = osxkeychain +{% endif %} + diff --git a/roles/hushlogin/tasks/main.yml b/roles/hushlogin/tasks/main.yml new file mode 100644 index 0000000..8563cf5 --- /dev/null +++ b/roles/hushlogin/tasks/main.yml @@ -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 diff --git a/dotfiles/.config/mintty/config b/roles/mintty/files/config similarity index 100% rename from dotfiles/.config/mintty/config rename to roles/mintty/files/config diff --git a/roles/mintty/tasks/main.yml b/roles/mintty/tasks/main.yml new file mode 100644 index 0000000..cbc2536 --- /dev/null +++ b/roles/mintty/tasks/main.yml @@ -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 + diff --git a/roles/packages/tasks/main.yml b/roles/packages/tasks/main.yml new file mode 100644 index 0000000..1636a62 --- /dev/null +++ b/roles/packages/tasks/main.yml @@ -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 + diff --git a/dotfiles/.config/python/startup.py b/roles/python/files/startup.py similarity index 100% rename from dotfiles/.config/python/startup.py rename to roles/python/files/startup.py diff --git a/roles/python/tasks/main.yml b/roles/python/tasks/main.yml new file mode 100644 index 0000000..d4ff36f --- /dev/null +++ b/roles/python/tasks/main.yml @@ -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 + diff --git a/dotfiles/.config/readline/inputrc b/roles/readline/files/inputrc similarity index 100% rename from dotfiles/.config/readline/inputrc rename to roles/readline/files/inputrc diff --git a/roles/readline/tasks/main.yml b/roles/readline/tasks/main.yml new file mode 100644 index 0000000..a181681 --- /dev/null +++ b/roles/readline/tasks/main.yml @@ -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 + diff --git a/dotfiles/.ssh/config b/roles/ssh/files/config similarity index 100% rename from dotfiles/.ssh/config rename to roles/ssh/files/config diff --git a/roles/ssh/tasks/main.yml b/roles/ssh/tasks/main.yml new file mode 100644 index 0000000..3977b50 --- /dev/null +++ b/roles/ssh/tasks/main.yml @@ -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 + diff --git a/dotfiles/.config/tmux/tmux.conf b/roles/tmux/files/tmux.conf similarity index 100% rename from dotfiles/.config/tmux/tmux.conf rename to roles/tmux/files/tmux.conf diff --git a/roles/tmux/tasks/main.yml b/roles/tmux/tasks/main.yml new file mode 100644 index 0000000..2e04c96 --- /dev/null +++ b/roles/tmux/tasks/main.yml @@ -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 + diff --git a/dotfiles/.config/vim/autoload/plug.vim b/roles/vim/files/autoload/plug.vim similarity index 100% rename from dotfiles/.config/vim/autoload/plug.vim rename to roles/vim/files/autoload/plug.vim diff --git a/dotfiles/.config/vim/vimrc b/roles/vim/files/vimrc similarity index 100% rename from dotfiles/.config/vim/vimrc rename to roles/vim/files/vimrc diff --git a/roles/vim/tasks/main.yml b/roles/vim/tasks/main.yml new file mode 100644 index 0000000..816c491 --- /dev/null +++ b/roles/vim/tasks/main.yml @@ -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 +