diff --git a/.gitattributes b/.gitattributes index 98a8062..f369391 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -roles/ssh/files/config filter=git-crypt diff=git-crypt +roles/common/files/ssh_config filter=git-crypt diff=git-crypt diff --git a/README.md b/README.md index 310aa20..9e1dc26 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ sudo apt-get install ansible echo -e "Host git.schauenburg.me\nUser git\nPort 587" >>~/.ssh/config git clone git@git.schauenburg.me:fernando/dotfiles.git $HOME/.dotfiles cd $HOME/.dotfiles -ansible-playbook -i hosts.ini dotfiles.yml +ansible-playbook -i inventory dotfiles.yml gpg -d --output - <(base64 -d .key) | git crypt unlock - ``` diff --git a/dotfiles.yml b/dotfiles.yml index adfd6fc..4784771 100644 --- a/dotfiles.yml +++ b/dotfiles.yml @@ -1,23 +1,12 @@ - name: Make myself at home :) hosts: dotfiles - vars_prompt: - - name: git_user - private: no - default: Fernando Schauenburg - - name: git_email - private: no - default: fernando@schauenburg.me + # 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 + - common diff --git a/hosts.ini b/inventory similarity index 100% rename from hosts.ini rename to inventory diff --git a/roles/bash/tasks/main.yml b/roles/bash/tasks/main.yml deleted file mode 100644 index d75ad32..0000000 --- a/roles/bash/tasks/main.yml +++ /dev/null @@ -1,57 +0,0 @@ -- name: Install latest bash with apt - when: ansible_os_family == "Debian" - become: yes - apt: - update_cache: yes - state: latest - name: - - bash - - bash-completion - - -- name: Install latest bash with homebrew - when: ansible_os_family == "Darwin" - homebrew: - state: latest - name: - - bash - - bash-completion - - -- name: Remove pre-installed bash configurations which could cause conflicts - file: - path: ~/{{ item }} - state: absent - loop: - - .bash_logout - - .profile - - -- name: Ensure existence of directories used in bashrc - file: - path: ~/{{ item }} - state: directory - loop: - - .config/bash - - .local/share/bash - - .local/share/bash-completion/completions - - .local/share/less - - -- 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/roles/bash/files/profile b/roles/common/files/bashrc similarity index 100% rename from roles/bash/files/profile rename to roles/common/files/bashrc diff --git a/roles/git/files/bin/git-churn b/roles/common/files/bin/git-churn similarity index 100% rename from roles/git/files/bin/git-churn rename to roles/common/files/bin/git-churn diff --git a/roles/git/files/bin/git-what-the-hell-just-happened b/roles/common/files/bin/git-what-the-hell-just-happened similarity index 100% rename from roles/git/files/bin/git-what-the-hell-just-happened rename to roles/common/files/bin/git-what-the-hell-just-happened diff --git a/roles/git/files/bin/git-wtf b/roles/common/files/bin/git-wtf similarity index 100% rename from roles/git/files/bin/git-wtf rename to roles/common/files/bin/git-wtf diff --git a/roles/bin/files/vboxmount b/roles/common/files/bin/vboxmount similarity index 100% rename from roles/bin/files/vboxmount rename to roles/common/files/bin/vboxmount diff --git a/roles/dircolors/files/solarized-dark b/roles/common/files/dircolors/solarized-dark similarity index 100% rename from roles/dircolors/files/solarized-dark rename to roles/common/files/dircolors/solarized-dark diff --git a/roles/dircolors/files/solarized-light b/roles/common/files/dircolors/solarized-light similarity index 100% rename from roles/dircolors/files/solarized-light rename to roles/common/files/dircolors/solarized-light diff --git a/roles/git/files/config b/roles/common/files/gitconfig similarity index 100% rename from roles/git/files/config rename to roles/common/files/gitconfig diff --git a/roles/git/files/ignore b/roles/common/files/gitignore similarity index 100% rename from roles/git/files/ignore rename to roles/common/files/gitignore diff --git a/roles/readline/files/inputrc b/roles/common/files/inputrc similarity index 100% rename from roles/readline/files/inputrc rename to roles/common/files/inputrc diff --git a/roles/mintty/files/config b/roles/common/files/minttyrc similarity index 100% rename from roles/mintty/files/config rename to roles/common/files/minttyrc diff --git a/roles/vim/files/plug.vim b/roles/common/files/plug.vim similarity index 100% rename from roles/vim/files/plug.vim rename to roles/common/files/plug.vim diff --git a/roles/python/files/startup.py b/roles/common/files/python-startup.py similarity index 100% rename from roles/python/files/startup.py rename to roles/common/files/python-startup.py diff --git a/roles/ssh/files/config b/roles/common/files/ssh_config similarity index 100% rename from roles/ssh/files/config rename to roles/common/files/ssh_config diff --git a/roles/tmux/files/tmux-colors.conf b/roles/common/files/tmux-colors.conf similarity index 100% rename from roles/tmux/files/tmux-colors.conf rename to roles/common/files/tmux-colors.conf diff --git a/roles/tmux/files/tmux.conf b/roles/common/files/tmux.conf similarity index 100% rename from roles/tmux/files/tmux.conf rename to roles/common/files/tmux.conf diff --git a/roles/vim/files/vimrc b/roles/common/files/vimrc similarity index 99% rename from roles/vim/files/vimrc rename to roles/common/files/vimrc index 578046a..9e93600 100644 --- a/roles/vim/files/vimrc +++ b/roles/common/files/vimrc @@ -89,7 +89,7 @@ endif " }}} " Plugins {{{ -call plug#begin('$XDG_CONFIG_HOME/vim/bundle') +call plug#begin('$XDG_DATA_HOME/vim/plugged') Plug 'altercation/vim-colors-solarized' Plug 'bronson/vim-trailing-whitespace' Plug 'elzr/vim-json' diff --git a/roles/common/tasks/bash.yml b/roles/common/tasks/bash.yml new file mode 100644 index 0000000..9b7ff05 --- /dev/null +++ b/roles/common/tasks/bash.yml @@ -0,0 +1,30 @@ +--- +- name: bash | remove pre-installed profile + file: + path: "{{ item }}" + state: absent + loop: + - ~/.bash_logout + - ~/.profile + + +- name: bash | ensure existence of directories used in bashrc + file: + path: "{{ item }}" + state: directory + loop: + - ~/.local/share/bash # for bash history + - ~/.local/share/bash-completion/completions # for custom completions + - ~/.local/share/less # for less history + + +- name: bash | deploy bash profile + file: + src: "{{ role_path }}/files/bashrc" + dest: "{{ item }}" + state: link + force: yes + loop: + - ~/.bash_profile # executed for login shells + - ~/.bashrc # executed for interactve shells + diff --git a/roles/bin/tasks/main.yml b/roles/common/tasks/bin.yml similarity index 62% rename from roles/bin/tasks/main.yml rename to roles/common/tasks/bin.yml index 7887ea0..2bb5ca3 100644 --- a/roles/bin/tasks/main.yml +++ b/roles/common/tasks/bin.yml @@ -1,15 +1,16 @@ -- name: Create local bin directory +--- +- name: bin | create ~/.local/bin file: path: ~/.local/bin state: directory -- name: Deploy local commands +- name: bin | deploy local commands file: src: "{{ item }}" dest: ~/.local/bin/{{ item | basename }} state: link force: yes with_fileglob: - - "{{ role_path }}/files/*" + - "{{ role_path }}/files/bin/*" diff --git a/roles/dircolors/tasks/main.yml b/roles/common/tasks/dircolors.yml similarity index 71% rename from roles/dircolors/tasks/main.yml rename to roles/common/tasks/dircolors.yml index e448300..efe148c 100644 --- a/roles/dircolors/tasks/main.yml +++ b/roles/common/tasks/dircolors.yml @@ -1,4 +1,5 @@ -- name: Create the dircolors config directory +--- +- name: dircolors | create config directory file: path: ~/.config/dircolors state: directory @@ -11,5 +12,5 @@ state: link force: yes with_fileglob: - - "{{ role_path }}/files/*" + - "{{ role_path }}/files/dircolors/*" diff --git a/roles/common/tasks/git.yml b/roles/common/tasks/git.yml new file mode 100644 index 0000000..6901837 --- /dev/null +++ b/roles/common/tasks/git.yml @@ -0,0 +1,26 @@ +--- +- name: git | create config directories + file: + path: "{{ item }}" + state: directory + loop: + - ~/.config/git + - ~/.local/etc/git + + +- name: git | deploy config + file: + src: "{{ role_path }}/files/{{ item.src }}" + dest: ~/.config/git/{{ item.dest }} + state: link + force: yes + loop: + - { src: gitconfig, dest: config } + - { src: gitignore, dest: ignore } + + +- name: git | deploy host-specific config + template: + src: gitconfig.host.j2 + dest: ~/.local/etc/git/config.host + diff --git a/roles/common/tasks/hushlogin.yml b/roles/common/tasks/hushlogin.yml new file mode 100644 index 0000000..a9eb644 --- /dev/null +++ b/roles/common/tasks/hushlogin.yml @@ -0,0 +1,13 @@ +--- +- name: hushlogin | exists? + stat: + path: ~/.hushlogin + register: hush + + +- name: hushlogin | create + when: hush.stat.exists == false + file: + path: ~/.hushlogin + state: touch + diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml new file mode 100644 index 0000000..7dc4c1f --- /dev/null +++ b/roles/common/tasks/main.yml @@ -0,0 +1,15 @@ +--- +- block: + # - import_tasks: bash.yml + # - import_tasks: bin.yml + # - import_tasks: dircolors.yml + # - import_tasks: git.yml + # - import_tasks: hushlogin.yml + # - import_tasks: mintty.yml + - import_tasks: packages.yml # TODO + # - import_tasks: python.yml + # - import_tasks: readline.yml + # - import_tasks: ssh.yml + # - import_tasks: tmux.yml + # - import_tasks: vim.yml + diff --git a/roles/mintty/tasks/main.yml b/roles/common/tasks/mintty.yml similarity index 52% rename from roles/mintty/tasks/main.yml rename to roles/common/tasks/mintty.yml index 15b9e32..3a69580 100644 --- a/roles/mintty/tasks/main.yml +++ b/roles/common/tasks/mintty.yml @@ -1,12 +1,13 @@ -- name: Create the mintty config directory +--- +- name: mintty | create config directory file: path: ~/.config/mintty state: directory -- name: Deploy mintty config +- name: mintty | deploy config file: - src: "{{ role_path }}/files/config" + src: "{{ role_path }}/files/minttyrc" dest: ~/.config/mintty/config state: link force: yes diff --git a/roles/common/tasks/packages.yml b/roles/common/tasks/packages.yml new file mode 100644 index 0000000..2129d53 --- /dev/null +++ b/roles/common/tasks/packages.yml @@ -0,0 +1,73 @@ +--- +- name: debian | install apt packages + when: ansible_facts['os_family']|lower == "debian" + become: yes + apt: + state: latest + update_cache: yes + name: + - bash + - bash-completion + - curl + - exa + - exuberant-ctags + - ffmpeg + - git + - git-crypt + - git-lfs + - gpg + - htop + - nmap + - psmisc + - python3 + - python3-pip + - shellcheck + - sqlite + - stow + - tmux + - tree + - vifm + - vim + - wget + - youtube-dl + + +- name: macOS | install homebrew packages + when: ansible_facts['os_family']|lower == "darwin" + homebrew: + state: latest + name: + - bash + - bash-completion + - coreutils + - ctags + - curl + - exa + - exiftool + - ffmpeg + - findutils + - git + - git-crypt + - git-lfs + - gnu-sed + - gpg + - grep + - gzip + - htop + - imagemagick + - jupyter + - make + - nmap + - pstree + - python3 + - reattach-to-user-namespace + - shellcheck + - sqlite + - stow + - tmux + - tree + - vifm + - vim + - wget + - youtube-dl + diff --git a/roles/common/tasks/python.yml b/roles/common/tasks/python.yml new file mode 100644 index 0000000..204b27c --- /dev/null +++ b/roles/common/tasks/python.yml @@ -0,0 +1,17 @@ +--- +- name: python | create config and data directories + file: + path: "{{ item }}" + state: directory + loop: + - ~/.config/python + - ~/.local/share/python # for this history file + + +- name: python | deploy startup file + file: + src: "{{ role_path }}/files/python-startup.py" + dest: ~/.config/python/startup.py + state: link + force: yes + diff --git a/roles/readline/tasks/main.yml b/roles/common/tasks/readline.yml similarity index 68% rename from roles/readline/tasks/main.yml rename to roles/common/tasks/readline.yml index 7b16b6b..0b6eb3d 100644 --- a/roles/readline/tasks/main.yml +++ b/roles/common/tasks/readline.yml @@ -1,10 +1,11 @@ -- name: Create the readline config directory +--- +- name: readline | create config directory file: path: ~/.config/readline state: directory -- name: Deploy inputrc +- name: readline | deploy inputrc file: src: "{{ role_path }}/files/inputrc" dest: ~/.config/readline/inputrc diff --git a/roles/common/tasks/ssh.yml b/roles/common/tasks/ssh.yml new file mode 100644 index 0000000..32677b7 --- /dev/null +++ b/roles/common/tasks/ssh.yml @@ -0,0 +1,14 @@ +--- +- name: ssh | create config diretory + file: + path: ~/.ssh + state: directory + + +- name: ssh | deploy config + file: + src: "{{ role_path }}/files/ssh_config" + dest: ~/.ssh/config + state: link + force: yes + diff --git a/roles/common/tasks/tmux.yml b/roles/common/tasks/tmux.yml new file mode 100644 index 0000000..2b2b99b --- /dev/null +++ b/roles/common/tasks/tmux.yml @@ -0,0 +1,17 @@ +--- +- name: tmux | create config directory + file: + path: ~/.config/tmux + state: directory + + +- name: tmux | deploy config + file: + src: "{{ role_path }}/files/{{ item }}" + dest: ~/.config/tmux/{{ item }} + state: link + force: yes + loop: + - tmux.conf + - tmux-colors.conf + diff --git a/roles/common/tasks/vim.yml b/roles/common/tasks/vim.yml new file mode 100644 index 0000000..a2520ca --- /dev/null +++ b/roles/common/tasks/vim.yml @@ -0,0 +1,26 @@ +--- +- name: vim | create directories + file: + path: "{{ item }}" + state: directory + loop: + - ~/.config/vim # for vimrc + - ~/.config/vim/autoload # for plugin manager + - ~/.local/share/vim # for viminfo + - ~/.local/share/vim/plugged # for installing uplugins + + +- name: vim | deploy configuration + file: + src: "{{ role_path }}/files/{{ item.src }}" + dest: "{{ item.dest }}" + state: link + force: yes + loop: + - { src: vimrc, dest: ~/.config/vim/vimrc } + - { src: plug.vim, dest: ~/.config/vim/autoload/plug.vim } + + +- name: vim | install plugins + shell: vim -es -u ~/.config/vim/vimrc +PlugInstall +qall + diff --git a/roles/git/templates/config.host.j2 b/roles/common/templates/gitconfig.host.j2 similarity index 100% rename from roles/git/templates/config.host.j2 rename to roles/common/templates/gitconfig.host.j2 diff --git a/roles/git/tasks/main.yml b/roles/git/tasks/main.yml deleted file mode 100644 index 5948ac9..0000000 --- a/roles/git/tasks/main.yml +++ /dev/null @@ -1,58 +0,0 @@ -- name: Install git with apt - when: ansible_os_family == "Debian" - become: yes - apt: - update_cache: yes - state: latest - name: - - git - - git-crypt - - git-lfs - - -- name: Install git with homebrew - when: ansible_os_family == "Darwin" - homebrew: - state: latest - name: - - git - - git-crypt - - git-lfs - - -- name: Create the git config directories - file: - path: "{{ item }}" - state: directory - loop: - - ~/.config/git - - ~/.local/bin - - ~/.local/etc/git - - -- 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: ~/.local/etc/git/config.host - - -- name: Deploy additional git commands - file: - src: "{{ item }}" - dest: "~/.local/bin/{{ item | basename }}" - state: link - force: yes - with_fileglob: - - "{{ role_path }}/files/bin/*" - diff --git a/roles/hushlogin/tasks/main.yml b/roles/hushlogin/tasks/main.yml deleted file mode 100644 index 74e4cb0..0000000 --- a/roles/hushlogin/tasks/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: Make sure hushlogin exists - file: - path: ~/.hushlogin - state: touch - diff --git a/roles/packages/tasks/main.yml b/roles/packages/tasks/main.yml deleted file mode 100644 index 3891b2e..0000000 --- a/roles/packages/tasks/main.yml +++ /dev/null @@ -1,59 +0,0 @@ -- name: Set up Debian machine - when: ansible_os_family == "Debian" - become: yes - block: - - name: Install apt packages - apt: - update_cache: yes - state: latest - name: - - curl - - exa - - exuberant-ctags - - ffmpeg - - gpg - - htop - - nmap - - psmisc - - shellcheck - - sqlite - - stow - - tree - - vifm - - wget - - youtube-dl - - -- name: Set up macOS machine - when: ansible_os_family == "Darwin" - block: - - name: Install homebrew packages - homebrew: - state: latest - name: - - coreutils - - ctags - - curl - - exa - - exiftool - - ffmpeg - - findutils - - gnu-sed - - gpg - - grep - - gzip - - htop - - imagemagick - - jupyter - - make - - nmap - - pstree - - reattach-to-user-namespace - - shellcheck - - sqlite - - stow - - tree - - vifm - - wget - - youtube-dl - diff --git a/roles/python/tasks/main.yml b/roles/python/tasks/main.yml deleted file mode 100644 index b5b67e0..0000000 --- a/roles/python/tasks/main.yml +++ /dev/null @@ -1,34 +0,0 @@ -- name: Install python3 with apt - when: ansible_os_family == "Debian" - become: yes - apt: - update_cache: yes - state: latest - name: - - python3 - - python3-pip - - -- name: Install python3 with homebrew - when: ansible_os_family == "Darwin" - homebrew: - name: python3 - state: latest - - -- name: Create the python config and data directories - file: - path: "{{ item }}" - state: directory - loop: - - ~/.config/python - - ~/.local/share/python # for this history file - - -- name: Deploy python startup file - file: - src: "{{ role_path }}/files/startup.py" - dest: ~/.config/python/startup.py - state: link - force: yes - diff --git a/roles/ssh/tasks/main.yml b/roles/ssh/tasks/main.yml deleted file mode 100644 index 7b88b07..0000000 --- a/roles/ssh/tasks/main.yml +++ /dev/null @@ -1,13 +0,0 @@ -- 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/roles/tmux/tasks/main.yml b/roles/tmux/tasks/main.yml deleted file mode 100644 index 08820fe..0000000 --- a/roles/tmux/tasks/main.yml +++ /dev/null @@ -1,32 +0,0 @@ -- name: Install tmux with apt - when: ansible_os_family == "Debian" - become: yes - apt: - name: tmux - state: latest - update_cache: yes - - -- name: Install tmux with homebrew - 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/{{ item }}" - dest: ~/.config/tmux/{{ item }} - state: link - force: yes - loop: - - tmux.conf - - tmux-colors.conf - diff --git a/roles/vim/tasks/main.yml b/roles/vim/tasks/main.yml deleted file mode 100644 index 21d876a..0000000 --- a/roles/vim/tasks/main.yml +++ /dev/null @@ -1,42 +0,0 @@ -- name: Install vim with apt - when: ansible_os_family == "Debian" - become: yes - apt: - name: vim - state: latest - update_cache: yes - - -- name: Install vim with homebrew - 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.src }}" - dest: ~/.config/vim/{{ item.dest }} - state: link - force: yes - loop: - - src: plug.vim - dest: autoload/plug.vim - - src: vimrc - dest: vimrc - - -- name: Install configured vim plugins - shell: vim -u "~/.config/vim/vimrc" +PlugInstall +qall -