diff --git a/playbook/launch b/playbook/launch index d750f0a..c7cdd0c 100755 --- a/playbook/launch +++ b/playbook/launch @@ -1,19 +1,23 @@ -#!/usr/bin/env sh +#!/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 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 + /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 diff --git a/playbook/main.yml b/playbook/main.yml index d39064c..f6ff437 100644 --- a/playbook/main.yml +++ b/playbook/main.yml @@ -30,3 +30,25 @@ 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 }}" diff --git a/playbook/roles/arch/tasks/main.yml b/playbook/roles/arch/tasks/main.yml index 8b13789..39d9fb0 100644 --- a/playbook/roles/arch/tasks/main.yml +++ b/playbook/roles/arch/tasks/main.yml @@ -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 diff --git a/playbook/roles/fedora/tasks/main.yml b/playbook/roles/fedora/tasks/main.yml index 19119b7..d426938 100644 --- a/playbook/roles/fedora/tasks/main.yml +++ b/playbook/roles/fedora/tasks/main.yml @@ -17,6 +17,7 @@ - tmux - gpg - neovim + - hstr state: latest - name: Install @development-tools diff --git a/playbook/roles/ubuntu/tasks/main.yml b/playbook/roles/ubuntu/tasks/main.yml index fa49617..ed03b97 100644 --- a/playbook/roles/ubuntu/tasks/main.yml +++ b/playbook/roles/ubuntu/tasks/main.yml @@ -2,20 +2,44 @@ 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 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