ansible_roles_rework #2
27 changed files with 371 additions and 0 deletions
6
playbook/arch.yml
Normal file
6
playbook/arch.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- hosts: local
|
||||||
|
roles:
|
||||||
|
- role: arch
|
||||||
|
- role: common
|
||||||
|
|
11
playbook/bootstrap
Executable file
11
playbook/bootstrap
Executable file
|
@ -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
|
12
playbook/bootstrap-macos
Executable file
12
playbook/bootstrap-macos
Executable file
|
@ -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
|
2
playbook/defaults/main.yml
Normal file
2
playbook/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
dev_machine: True
|
6
playbook/fedora.yml
Normal file
6
playbook/fedora.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- hosts: local
|
||||||
|
roles:
|
||||||
|
- role: fedora
|
||||||
|
- role: common
|
||||||
|
|
17
playbook/input.yml
Normal file
17
playbook/input.yml
Normal file
|
@ -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 }}"
|
2
playbook/inventory
Normal file
2
playbook/inventory
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[local]
|
||||||
|
localhost ansible_connection=local
|
19
playbook/launch
Executable file
19
playbook/launch
Executable file
|
@ -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
|
5
playbook/macos.yml
Normal file
5
playbook/macos.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- hosts: local
|
||||||
|
roles:
|
||||||
|
- role: common
|
||||||
|
- role: osx
|
22
playbook/main.yml
Normal file
22
playbook/main.yml
Normal file
|
@ -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
|
1
playbook/roles/arch/tasks/main.yml
Normal file
1
playbook/roles/arch/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
4
playbook/roles/common/defaults/main.yml
Normal file
4
playbook/roles/common/defaults/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
user_name: "Anthony Cicchetti"
|
||||||
|
user_email: "anthony@anthonycicchetti.com"
|
||||||
|
dev_machine: yes
|
12
playbook/roles/common/tasks/alacritty.yml
Normal file
12
playbook/roles/common/tasks/alacritty.yml
Normal file
|
@ -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
|
||||||
|
|
45
playbook/roles/common/tasks/anyenv.yml
Normal file
45
playbook/roles/common/tasks/anyenv.yml
Normal file
|
@ -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
|
9
playbook/roles/common/tasks/git.yml
Normal file
9
playbook/roles/common/tasks/git.yml
Normal file
|
@ -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'
|
||||||
|
|
7
playbook/roles/common/tasks/hyper.yml
Normal file
7
playbook/roles/common/tasks/hyper.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
- name: hyper.js setup
|
||||||
|
file:
|
||||||
|
src: "$HOME/.dotfiles/hyperterm/hyper.js"
|
||||||
|
dest: "$HOME/.hyper.js"
|
||||||
|
state: link
|
||||||
|
|
11
playbook/roles/common/tasks/kerl.yml
Normal file
11
playbook/roles/common/tasks/kerl.yml
Normal file
|
@ -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
|
21
playbook/roles/common/tasks/main.yml
Normal file
21
playbook/roles/common/tasks/main.yml
Normal file
|
@ -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
|
13
playbook/roles/common/tasks/neovim.yml
Normal file
13
playbook/roles/common/tasks/neovim.yml
Normal file
|
@ -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
|
||||||
|
|
41
playbook/roles/common/tasks/rust.yml
Normal file
41
playbook/roles/common/tasks/rust.yml
Normal file
|
@ -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
|
5
playbook/roles/common/tasks/sdkman.yml
Normal file
5
playbook/roles/common/tasks/sdkman.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: Install SDKMan
|
||||||
|
shell: curl -s https://get.sdkman.io | zsh
|
||||||
|
args:
|
||||||
|
creates: ~/.sdkman/bin/sdkman-init.sh
|
7
playbook/roles/common/tasks/tmux.yml
Normal file
7
playbook/roles/common/tasks/tmux.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
- name: Symlink tmux.conf
|
||||||
|
file:
|
||||||
|
src: ~/.dotfiles/tmux/tmux.conf
|
||||||
|
dest: ~/.tmux.conf
|
||||||
|
state: link
|
||||||
|
force: yes
|
12
playbook/roles/common/tasks/zsh.yml
Normal file
12
playbook/roles/common/tasks/zsh.yml
Normal file
|
@ -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
|
28
playbook/roles/fedora/tasks/main.yml
Normal file
28
playbook/roles/fedora/tasks/main.yml
Normal file
|
@ -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
|
26
playbook/roles/macos/tasks/main.yml
Normal file
26
playbook/roles/macos/tasks/main.yml
Normal file
|
@ -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
|
21
playbook/roles/ubuntu/tasks/main.yml
Normal file
21
playbook/roles/ubuntu/tasks/main.yml
Normal file
|
@ -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
|
||||||
|
|
6
playbook/ubuntu.yml
Normal file
6
playbook/ubuntu.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- hosts: local
|
||||||
|
roles:
|
||||||
|
- role: ubuntu
|
||||||
|
- role: common
|
||||||
|
|
Loading…
Add table
Reference in a new issue