diff --git a/playbook/arch.yml b/playbook/arch.yml new file mode 100644 index 0000000..8327198 --- /dev/null +++ b/playbook/arch.yml @@ -0,0 +1,6 @@ +--- +- hosts: local + roles: + - role: arch + - role: common + diff --git a/playbook/bootstrap b/playbook/bootstrap new file mode 100755 index 0000000..67373e5 --- /dev/null +++ b/playbook/bootstrap @@ -0,0 +1,11 @@ +#!/bin/bash + +set -xe +if [[ -f /etc/lsb-release ]]; then + sudo apt update + sudo apt -y install zsh git python-pip aptitude curl cmake libreadline-dev +else + sudo dnf install -y zsh git cmake openssl-devel tmux gpg +fi + +pip3 install --user ansible diff --git a/playbook/bootstrap-macos b/playbook/bootstrap-macos new file mode 100755 index 0000000..c3d1bf4 --- /dev/null +++ b/playbook/bootstrap-macos @@ -0,0 +1,12 @@ +#!/bin/bash + +set -xe + +# no no no no I don't like it but… +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + +brew install git cmake openssl tmux gpg + +sudo echo '/usr/local/bin/zsh' >> /etc/shells + +chsh -s /usr/local/bin/zsh diff --git a/playbook/defaults/main.yml b/playbook/defaults/main.yml new file mode 100644 index 0000000..2cf1b34 --- /dev/null +++ b/playbook/defaults/main.yml @@ -0,0 +1,2 @@ +--- +dev_machine: True diff --git a/playbook/fedora.yml b/playbook/fedora.yml new file mode 100644 index 0000000..fc7bd01 --- /dev/null +++ b/playbook/fedora.yml @@ -0,0 +1,6 @@ +--- +- hosts: local + roles: + - role: fedora + - role: common + diff --git a/playbook/input.yml b/playbook/input.yml new file mode 100644 index 0000000..b68b046 --- /dev/null +++ b/playbook/input.yml @@ -0,0 +1,17 @@ +--- +- name: Ask user for the input + hosts: localhost + tags: always + tasks: + - block: + - debug: + var: dev_machine + - name: Dev Machine prompt + pause: + prompt: "Is this a developer's machine? yes|no" + register: _dev_machine + when: + - dev_machine == 'yes' + - name: Set dev machine fact based on input + set_fact: + dev_machine: "{{ _dev_machine }}" diff --git a/playbook/inventory b/playbook/inventory new file mode 100644 index 0000000..13cfabe --- /dev/null +++ b/playbook/inventory @@ -0,0 +1,2 @@ +[local] +localhost ansible_connection=local diff --git a/playbook/launch b/playbook/launch new file mode 100755 index 0000000..d750f0a --- /dev/null +++ b/playbook/launch @@ -0,0 +1,19 @@ +#!/usr/bin/env sh +set -ex + +PATH="$PATH:$HOME/.local/bin" + +if [[ `uname` == "Linux" ]]; then + if [[ -f /etc/pacman.conf ]]; then + ansible-playbook -i inventory arch.yml + elif [[ -f /etc/lsb-release ]]; then + ansible-playbook -i inventory ubuntu.yml + elif [[ -f /etc/fedora-release ]]; then + ansible-playbook -i inventory fedora.yml + else + echo "can't autodetermine distro, just running default inventory" + ansible-playbook -i inventory common.yml + fi +else + ansible-playbook -i inventory osx.yml +fi diff --git a/playbook/macos.yml b/playbook/macos.yml new file mode 100644 index 0000000..d77889a --- /dev/null +++ b/playbook/macos.yml @@ -0,0 +1,5 @@ +--- +- hosts: local + roles: + - role: common + - role: osx diff --git a/playbook/main.yml b/playbook/main.yml new file mode 100644 index 0000000..d8a740a --- /dev/null +++ b/playbook/main.yml @@ -0,0 +1,22 @@ +--- +# - name: Include prompts playbook +# import_playbook: input.yml + +- name: Find out what kind of host we are + hosts: all + tasks: + - name: Classify host + group_by: + key: os_{{ ansible_facts['distribution'] }} + +- hosts: os_MacOSX + gather_facts: True + roles: + - common + - macos + +- hosts: os_Fedora + gather_facts: True + roles: + - common + - fedora diff --git a/playbook/roles/arch/tasks/main.yml b/playbook/roles/arch/tasks/main.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/playbook/roles/arch/tasks/main.yml @@ -0,0 +1 @@ + diff --git a/playbook/roles/common/defaults/main.yml b/playbook/roles/common/defaults/main.yml new file mode 100644 index 0000000..ff17851 --- /dev/null +++ b/playbook/roles/common/defaults/main.yml @@ -0,0 +1,4 @@ +--- +user_name: "Anthony Cicchetti" +user_email: "anthony@anthonycicchetti.com" +dev_machine: yes diff --git a/playbook/roles/common/tasks/alacritty.yml b/playbook/roles/common/tasks/alacritty.yml new file mode 100644 index 0000000..481aab4 --- /dev/null +++ b/playbook/roles/common/tasks/alacritty.yml @@ -0,0 +1,12 @@ +--- +- name: alacritty dir setup + file: + path: "$HOME/.config/alacritty/" + state: directory + +- name: alacritty.conf setup + file: + src: "$HOME/.dotfiles/alacritty/alacritty.yml" + dest: "$HOME/.config/alacritty/alacritty.yml" + state: link + diff --git a/playbook/roles/common/tasks/anyenv.yml b/playbook/roles/common/tasks/anyenv.yml new file mode 100644 index 0000000..549f592 --- /dev/null +++ b/playbook/roles/common/tasks/anyenv.yml @@ -0,0 +1,45 @@ +--- +- name: Install anyenv + git: + repo: https://github.com/anyenv/anyenv + dest: ~/.anyenv + +- name: Ensure anyenv got installed + file: + path: ~/.anyenv + state: directory + +- name: Ensure anyenv is initialized + shell: ~/.anyenv/bin/anyenv install --force-init + args: + creates: ~/.config/anyenv/anyenv-install + +- name: anyenv - pyenv + shell: ~/.anyenv/bin/anyenv install pyenv + args: + creates: ~/.anyenv/envs/pyenv + +- name: anyenv - rbenv + shell: ~/.anyenv/bin/anyenv install rbenv + args: + creates: ~/.anyenv/envs/rbenv + +- name: anyenv - rbenv-gemset + git: + repo: https://github.com/jf/rbenv-gemset + dest: ~/.anyenv/envs/rbenv/plugins/rbenv-gemset + +- name: anyenv - nodejs + shell: ~/.anyenv/bin/anyenv install nodenv + args: + creates: ~/.anyenv/envs/nodenv + +- name: anyenv - erlang + shell: ~/.anyenv/bin/anyenv install erlenv + args: + creates: ~/.anyenv/envs/erlenv + +- name: anyenv - elixir + shell: ~/.anyenv/bin/anyenv install exenv + args: + creates: ~/.anyenv/envs/exenv diff --git a/playbook/roles/common/tasks/git.yml b/playbook/roles/common/tasks/git.yml new file mode 100644 index 0000000..363273b --- /dev/null +++ b/playbook/roles/common/tasks/git.yml @@ -0,0 +1,9 @@ +--- +- name: Set up gitconfig + shell: git config --global user.name "{{user_name}}" && git config --global user.email {{user_email}} + args: + creates: ~/.gitconfig + +- name: Add git pushall alias + shell: git config --global alias.pushall '!git remote | xargs -L1 git push --all' + diff --git a/playbook/roles/common/tasks/hyper.yml b/playbook/roles/common/tasks/hyper.yml new file mode 100644 index 0000000..9da19ca --- /dev/null +++ b/playbook/roles/common/tasks/hyper.yml @@ -0,0 +1,7 @@ +--- +- name: hyper.js setup + file: + src: "$HOME/.dotfiles/hyperterm/hyper.js" + dest: "$HOME/.hyper.js" + state: link + diff --git a/playbook/roles/common/tasks/kerl.yml b/playbook/roles/common/tasks/kerl.yml new file mode 100644 index 0000000..0c98502 --- /dev/null +++ b/playbook/roles/common/tasks/kerl.yml @@ -0,0 +1,11 @@ +--- +- name: Create ~/bin directory + file: + path: ~/bin + state: directory + +- name: Download kerl + get_url: + url: https://raw.githubusercontent.com/kerl/kerl/master/kerl + dest: ~/bin/kerl + mode: 0755 diff --git a/playbook/roles/common/tasks/main.yml b/playbook/roles/common/tasks/main.yml new file mode 100644 index 0000000..a1b202d --- /dev/null +++ b/playbook/roles/common/tasks/main.yml @@ -0,0 +1,21 @@ +--- +- debug: + var: dev_machine +- import_tasks: anyenv.yml + when: + - dev_machine == 'yes' +# - import_tasks: neovim.yml +# - import_tasks: rust.yml +# - import_tasks: tmux.yml +# - import_tasks: alacritty.yml +# - import_tasks: hyper.yml +# - import_tasks: kerl.yml +- import_tasks: git.yml +# - import_tasks: zsh.yml +# - import_tasks: sdkman.yml + + +- name: Create ~/bin directory + file: + path: ~/bin + state: directory diff --git a/playbook/roles/common/tasks/neovim.yml b/playbook/roles/common/tasks/neovim.yml new file mode 100644 index 0000000..f215660 --- /dev/null +++ b/playbook/roles/common/tasks/neovim.yml @@ -0,0 +1,13 @@ +--- +- name: Ensure neovim config directory exists + file: + path: ~/.config/nvim/ + state: directory + +- name: Symlink init.vim + file: + src: ~/.dotfiles/vim/vimrc + dest: ~/.config/nvim/init.vim + state: link + force: yes + diff --git a/playbook/roles/common/tasks/rust.yml b/playbook/roles/common/tasks/rust.yml new file mode 100644 index 0000000..f0eefbe --- /dev/null +++ b/playbook/roles/common/tasks/rust.yml @@ -0,0 +1,41 @@ +--- +- name: Download Rust + get_url: + url: https://sh.rustup.rs + dest: /tmp/install_rust.sh + mode: 0755 + +- name: Install Rust + shell: /tmp/install_rust.sh -y + args: + creates: ~/.cargo + +- name: Install ripgrep + shell: ~/.cargo/bin/cargo install ripgrep + args: + creates: ~/.cargo/bin/rg + +- name: Install exa + shell: ~/.cargo/bin/cargo install exa + args: + creates: ~/.cargo/bin/exa + +- name: Install just + shell: ~/.cargo/bin/cargo install just + args: + creates: ~/.cargo/bin/just + +- name: Install cargo-update + shell: ~/.cargo/bin/cargo install cargo-update + args: + creates: ~/.cargo/bin/cargo-install-update + +- name: Install bat + shell: ~/.cargo/bin/cargo install bat + args: + creates: ~/.cargo/bin/bat + +- name: Install rls + shell: ~/.cargo/bin/rustup component add rls-preview rust-analysis rust-src + args: + creates: ~/.cargo/bin/rls diff --git a/playbook/roles/common/tasks/sdkman.yml b/playbook/roles/common/tasks/sdkman.yml new file mode 100644 index 0000000..4a3b98a --- /dev/null +++ b/playbook/roles/common/tasks/sdkman.yml @@ -0,0 +1,5 @@ +--- +- name: Install SDKMan + shell: curl -s https://get.sdkman.io | zsh + args: + creates: ~/.sdkman/bin/sdkman-init.sh diff --git a/playbook/roles/common/tasks/tmux.yml b/playbook/roles/common/tasks/tmux.yml new file mode 100644 index 0000000..9313e73 --- /dev/null +++ b/playbook/roles/common/tasks/tmux.yml @@ -0,0 +1,7 @@ +--- +- name: Symlink tmux.conf + file: + src: ~/.dotfiles/tmux/tmux.conf + dest: ~/.tmux.conf + state: link + force: yes diff --git a/playbook/roles/common/tasks/zsh.yml b/playbook/roles/common/tasks/zsh.yml new file mode 100644 index 0000000..6ca21b3 --- /dev/null +++ b/playbook/roles/common/tasks/zsh.yml @@ -0,0 +1,12 @@ +--- +- name: Install antigen + git: + repo: https://github.com/zsh-users/antigen.git + dest: ~/.antigen + +- name: Symlink zshrc + file: + src: ~/.dotfiles/zsh/zshrc + dest: ~/.zshrc + state: link + force: yes diff --git a/playbook/roles/fedora/tasks/main.yml b/playbook/roles/fedora/tasks/main.yml new file mode 100644 index 0000000..de0961b --- /dev/null +++ b/playbook/roles/fedora/tasks/main.yml @@ -0,0 +1,28 @@ +--- +# - name: Update Packages +# become: yes +# become_method: sudo +# dnf: +# name: "*" +# state: latest + +# - name: Install neovim +# become: yes +# become_method: sudo +# dnf: +# name: "neovim" +# state: latest + +# - name: Install @development-tools +# become: yes +# become_method: sudo +# dnf: +# name: "@development-tools" +# state: latest + +# - name: Install openssl-dev +# become: yes +# become_method: sudo +# dnf: +# name: "openssl-devel" +# state: latest diff --git a/playbook/roles/macos/tasks/main.yml b/playbook/roles/macos/tasks/main.yml new file mode 100644 index 0000000..cb5db4f --- /dev/null +++ b/playbook/roles/macos/tasks/main.yml @@ -0,0 +1,26 @@ +--- +- name: Homebrew Update + homebrew: + update_homebrew: yes + upgrade_all: yes + +- name: Homebrew - install neovim + homebrew: + update_homebrew: yes + name: neovim + +- name: Homebrew - Install git + homebrew: + update_homebrew: yes + name: git + +- name: Homebrew - Install zsh + homebrew: + update_homebrew: yes + name: zsh + install_options: with-gdbm with-pcre with-unicode9 + +- name: Homebrew - Install gnu-tar and zstd + homebrew: + update_homebrew: yes + name: gnu-tar,zstd diff --git a/playbook/roles/ubuntu/tasks/main.yml b/playbook/roles/ubuntu/tasks/main.yml new file mode 100644 index 0000000..fa49617 --- /dev/null +++ b/playbook/roles/ubuntu/tasks/main.yml @@ -0,0 +1,21 @@ +- name: Update Packages + become: yes + become_method: sudo + apt: + name: "*" + state: latest + +- name: Install neovim + become: yes + become_method: sudo + apt: + name: "neovim" + state: latest + +- name: Install build-essential + become: yes + become_method: sudo + apt: + name: "build-essential" + state: latest + diff --git a/playbook/ubuntu.yml b/playbook/ubuntu.yml new file mode 100644 index 0000000..92b2638 --- /dev/null +++ b/playbook/ubuntu.yml @@ -0,0 +1,6 @@ +--- +- hosts: local + roles: + - role: ubuntu + - role: common +