ansible_roles_rework #2
36 changed files with 304 additions and 65 deletions
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
- hosts: local
|
||||
roles:
|
||||
- role: common
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
- hosts: local
|
||||
roles:
|
||||
- role: fedora
|
||||
- role: common
|
||||
|
21
playbooks/input.yml
Normal file
21
playbooks/input.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
- name: Ask user for the input
|
||||
hosts: localhost
|
||||
tags: always
|
||||
vars_prompt:
|
||||
- name: _dev_machine
|
||||
prompt: "Is this a developer's machine?"
|
||||
private: no
|
||||
default: "yes"
|
||||
- name: _rust_extras
|
||||
prompt: "Do you want to install rust extras?"
|
||||
private: no
|
||||
default: "no"
|
||||
tasks:
|
||||
- block:
|
||||
- name: Set dev machine fact
|
||||
set_fact:
|
||||
_dev_machine: "{{ _dev_machine }}"
|
||||
- name: Set rust extras fact
|
||||
set_fact:
|
||||
_rust_extras: "{{ _rust_extras }}"
|
|
@ -1,19 +1,24 @@
|
|||
#!/usr/bin/env zsh
|
||||
#!/usr/bin/env bash
|
||||
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
|
||||
if [[ $(command -v ansible) ]]; then
|
||||
printf "ansible already installed"
|
||||
elif [[ $(uname) == "Linux" ]]; then
|
||||
if [[ $(command -v pacman) ]]; then
|
||||
sudo pacman -Sy --noconfirm ansible
|
||||
elif [[ $(command -v apt) ]]; then
|
||||
sudo apt install -y ansible python3-apt
|
||||
# ubuntu doesn't create a /usr/bin/python, so we have to make one ourselves
|
||||
ln -s /usr/bin/python3 /usr/bin/python
|
||||
elif [[ $(command -v dnf) ]]; then
|
||||
sudo dnf install ansible -y
|
||||
fi
|
||||
elif [[ $(uname) == "Darwin" ]]; then
|
||||
# Yeah, raw brew install
|
||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
/usr/local/bin/brew install ansible
|
||||
fi
|
||||
|
||||
ansible-playbook -i inventory main.yml
|
||||
|
|
54
playbooks/main.yml
Normal file
54
playbooks/main.yml
Normal file
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
- 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:
|
||||
- role: macos
|
||||
vars:
|
||||
- dev_machine: "{{ _dev_machine }}"
|
||||
- role: common
|
||||
vars:
|
||||
- dev_machine: "{{ _dev_machine }}"
|
||||
- rust_extras: "{{ _rust_extras }}"
|
||||
|
||||
- hosts: os_Fedora
|
||||
gather_facts: True
|
||||
roles:
|
||||
- role: fedora
|
||||
vars:
|
||||
dev_machine: "{{ _dev_machine }}"
|
||||
- role: common
|
||||
vars:
|
||||
- dev_machine: "{{ _dev_machine }}"
|
||||
- rust_extras: "{{ _rust_extras }}"
|
||||
|
||||
- hosts: os_Archlinux
|
||||
gather_facts: True
|
||||
roles:
|
||||
- role: arch
|
||||
vars:
|
||||
dev_machine: "{{ _dev_machine }}"
|
||||
- role: common
|
||||
vars:
|
||||
- dev_machine: "{{ _dev_machine }}"
|
||||
- rust_extras: "{{ _rust_extras }}"
|
||||
|
||||
- hosts: os_Ubuntu
|
||||
gather_facts: False
|
||||
roles:
|
||||
- role: ubuntu
|
||||
vars:
|
||||
dev_machine: "{{ _dev_machine }}"
|
||||
- role: common
|
||||
vars:
|
||||
- dev_machine: "{{ _dev_machine }}"
|
||||
- rust_extras: "{{ _rust_extras }}"
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
- hosts: local
|
||||
roles:
|
||||
- role: common
|
||||
- role: osx
|
2
playbooks/roles/alacritty/defaults/main.yml
Normal file
2
playbooks/roles/alacritty/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
2
playbooks/roles/anyenv/defaults/main.yml
Normal file
2
playbooks/roles/anyenv/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
2
playbooks/roles/arch/defaults/main.yml
Normal file
2
playbooks/roles/arch/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
|
@ -1 +1,58 @@
|
|||
---
|
||||
- name: Update Packages
|
||||
become: yes
|
||||
become_method: sudo
|
||||
pacman:
|
||||
update_cache: yes
|
||||
upgrade: yes
|
||||
|
||||
- name: Install basics
|
||||
become: yes
|
||||
become_method: sudo
|
||||
pacman:
|
||||
name:
|
||||
- zsh
|
||||
- git
|
||||
- cmake
|
||||
- tmux
|
||||
- gnupg
|
||||
- neovim
|
||||
state: latest
|
||||
|
||||
- name: Install Development Tools
|
||||
when:
|
||||
- dev_machine == true
|
||||
become: yes
|
||||
become_method: sudo
|
||||
pacman:
|
||||
name:
|
||||
- base-devel
|
||||
- openssl
|
||||
state: latest
|
||||
|
||||
- name: clone yay from github
|
||||
when:
|
||||
- dev_machine == true
|
||||
become: false
|
||||
git:
|
||||
repo: https://aur.archlinux.org/yay.git
|
||||
dest: /tmp/yay
|
||||
version: master
|
||||
update: yes
|
||||
# notify: makepkg -si
|
||||
|
||||
- name: makepkg --noconfirm -si
|
||||
when:
|
||||
- dev_machine == true
|
||||
become: false
|
||||
command: makepkg --noconfirm -si
|
||||
args:
|
||||
chdir: /tmp/yay
|
||||
creates: /usr/bin/yay
|
||||
|
||||
- name: Install hstr
|
||||
when:
|
||||
- dev_machine == true
|
||||
command: yay -Sy --noconfirm --needed --cleanafter hstr
|
||||
args:
|
||||
creates: /usr/local/bin/hstr
|
||||
|
|
4
playbooks/roles/common/defaults/main.yml
Normal file
4
playbooks/roles/common/defaults/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
user_name: "Anthony Cicchetti"
|
||||
user_email: "anthony@anthonycicchetti.com"
|
||||
dev_machine: yes
|
|
@ -1,28 +1,43 @@
|
|||
---
|
||||
- import_tasks: anyenv.yml
|
||||
- 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_role:
|
||||
name: anyenv
|
||||
when:
|
||||
- dev_machine == true
|
||||
- import_role:
|
||||
name: neovim
|
||||
- import_role:
|
||||
name: rust
|
||||
vars:
|
||||
- rust_extras: "{{ _rust_extras }}"
|
||||
when:
|
||||
- dev_machine == true
|
||||
- import_role:
|
||||
name: tmux
|
||||
when:
|
||||
- dev_machine == true
|
||||
- import_role:
|
||||
name: alacritty
|
||||
when:
|
||||
- dev_machine == true
|
||||
- import_role:
|
||||
name: hyper
|
||||
when:
|
||||
- dev_machine == true
|
||||
- import_role:
|
||||
name: kerl
|
||||
when:
|
||||
- dev_machine == true
|
||||
- import_role:
|
||||
name: git
|
||||
when:
|
||||
- dev_machine == true
|
||||
- import_role:
|
||||
name: zsh
|
||||
- import_role:
|
||||
name: sdkman
|
||||
when:
|
||||
- dev_machine == true
|
||||
|
||||
- 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
|
||||
|
||||
- name: Install SDKMan
|
||||
shell: curl -s https://get.sdkman.io | zsh
|
||||
args:
|
||||
creates: ~/.sdkman/bin/sdkman-init.sh
|
||||
|
||||
- name: Create ~/bin directory
|
||||
file:
|
||||
|
|
2
playbooks/roles/fedora/defaults/main.yml
Normal file
2
playbooks/roles/fedora/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
|
@ -6,23 +6,28 @@
|
|||
name: "*"
|
||||
state: latest
|
||||
|
||||
- name: Install neovim
|
||||
- name: Install basics
|
||||
become: yes
|
||||
become_method: sudo
|
||||
dnf:
|
||||
name: "neovim"
|
||||
name:
|
||||
- zsh
|
||||
- git
|
||||
- cmake
|
||||
- tmux
|
||||
- gpg
|
||||
- neovim
|
||||
- hstr
|
||||
state: latest
|
||||
|
||||
- name: Install @development-tools
|
||||
when:
|
||||
- dev_machine == true
|
||||
become: yes
|
||||
become_method: sudo
|
||||
dnf:
|
||||
name: "@development-tools"
|
||||
name:
|
||||
- "@development-tools"
|
||||
- openssl-devel
|
||||
state: latest
|
||||
|
||||
- name: Install openssl-dev
|
||||
become: yes
|
||||
become_method: sudo
|
||||
dnf:
|
||||
name: "openssl-devel"
|
||||
state: latest
|
||||
|
|
2
playbooks/roles/git/defaults/main.yml
Normal file
2
playbooks/roles/git/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
9
playbooks/roles/git/tasks/main.yml
Normal file
9
playbooks/roles/git/tasks/main.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'
|
||||
|
2
playbooks/roles/hyper/defaults/main.yml
Normal file
2
playbooks/roles/hyper/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
2
playbooks/roles/kerl/defaults/main.yml
Normal file
2
playbooks/roles/kerl/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
2
playbooks/roles/macos/defaults/main.yml
Normal file
2
playbooks/roles/macos/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
2
playbooks/roles/neovim/defaults/main.yml
Normal file
2
playbooks/roles/neovim/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
3
playbooks/roles/rust/defaults/main.yml
Normal file
3
playbooks/roles/rust/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dev_machine: yes
|
||||
rust_extras: no
|
|
@ -14,28 +14,40 @@
|
|||
shell: ~/.cargo/bin/cargo install ripgrep
|
||||
args:
|
||||
creates: ~/.cargo/bin/rg
|
||||
when:
|
||||
- rust_extras == true
|
||||
|
||||
- name: Install exa
|
||||
shell: ~/.cargo/bin/cargo install exa
|
||||
args:
|
||||
creates: ~/.cargo/bin/exa
|
||||
when:
|
||||
- rust_extras == true
|
||||
|
||||
- name: Install just
|
||||
shell: ~/.cargo/bin/cargo install just
|
||||
args:
|
||||
creates: ~/.cargo/bin/just
|
||||
when:
|
||||
- rust_extras == true
|
||||
|
||||
- name: Install cargo-update
|
||||
shell: ~/.cargo/bin/cargo install cargo-update
|
||||
args:
|
||||
creates: ~/.cargo/bin/cargo-install-update
|
||||
when:
|
||||
- rust_extras == true
|
||||
|
||||
- name: Install bat
|
||||
shell: ~/.cargo/bin/cargo install bat
|
||||
args:
|
||||
creates: ~/.cargo/bin/bat
|
||||
when:
|
||||
- rust_extras == true
|
||||
|
||||
- name: Install rls
|
||||
shell: ~/.cargo/bin/rustup component add rls-preview rust-analysis rust-src
|
||||
args:
|
||||
creates: ~/.cargo/bin/rls
|
||||
when:
|
||||
- rust_extras == true
|
2
playbooks/roles/sdkman/defaults/main.yml
Normal file
2
playbooks/roles/sdkman/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
5
playbooks/roles/sdkman/tasks/main.yml
Normal file
5
playbooks/roles/sdkman/tasks/main.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
|
2
playbooks/roles/tmux/defaults/main.yml
Normal file
2
playbooks/roles/tmux/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
2
playbooks/roles/ubuntu/defaults/main.yml
Normal file
2
playbooks/roles/ubuntu/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
|
@ -2,20 +2,46 @@
|
|||
become: yes
|
||||
become_method: sudo
|
||||
apt:
|
||||
force_apt_get: yes
|
||||
name: "*"
|
||||
state: latest
|
||||
|
||||
- name: Install neovim
|
||||
- name: Install essentials
|
||||
become: yes
|
||||
become_method: sudo
|
||||
apt:
|
||||
name: "neovim"
|
||||
force_apt_get: yes
|
||||
name:
|
||||
- neovim
|
||||
- git
|
||||
- zsh
|
||||
- tmux
|
||||
- gpg
|
||||
- software-properties-common
|
||||
state: latest
|
||||
|
||||
- name: Install build-essential
|
||||
- name: Install Development Tools
|
||||
become: yes
|
||||
become_method: sudo
|
||||
apt:
|
||||
name: "build-essential"
|
||||
force_apt_get: yes
|
||||
name:
|
||||
- build-essential
|
||||
- cmake
|
||||
- libssl-dev
|
||||
- pkg-config
|
||||
state: latest
|
||||
|
||||
# - name: Add hstr repo
|
||||
# become: yes
|
||||
# become_method: sudo
|
||||
# command: "add-apt-repository ppa:acicchetti/utils"
|
||||
|
||||
# - name: Install hstr
|
||||
# become: yes
|
||||
# become_method: sudo
|
||||
# apt:
|
||||
# force_apt_get: yes
|
||||
# name: hstr
|
||||
# state: latest
|
||||
# update_cache: yes
|
||||
|
|
2
playbooks/roles/zsh/defaults/main.yml
Normal file
2
playbooks/roles/zsh/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
dev_machine: yes
|
12
playbooks/roles/zsh/tasks/main.yml
Normal file
12
playbooks/roles/zsh/tasks/main.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
|
Loading…
Add table
Reference in a new issue