From 46aa5ef390ad04f9279291ba30b3fb12023485e2 Mon Sep 17 00:00:00 2001 From: Andrew Coleman Date: Fri, 16 Apr 2021 12:59:28 -0400 Subject: [PATCH] playbooks for my setup --- README.md | 22 ++++++ apt.yml | 5 ++ base16-outrun-dark-256.sh | 91 +++++++++++++++++++++++ dnf.yml | 8 ++ freebsd-inventory.yml | 6 ++ gnome-terminal.yml | 12 +++ linux-inventory.yml | 6 ++ localdev.yml | 26 +++++++ neovim.yml | 5 ++ pkg.yml | 60 +++++++++++++++ playbook.sh | 7 ++ rust.yml | 151 ++++++++++++++++++++++++++++++++++++++ 12 files changed, 399 insertions(+) create mode 100644 README.md create mode 100644 apt.yml create mode 100755 base16-outrun-dark-256.sh create mode 100644 dnf.yml create mode 100644 freebsd-inventory.yml create mode 100644 gnome-terminal.yml create mode 100644 linux-inventory.yml create mode 100644 localdev.yml create mode 100644 neovim.yml create mode 100644 pkg.yml create mode 100755 playbook.sh create mode 100644 rust.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..e072d55 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# FreeBSD + + # as root + pkg install py37-ansible python3 sudo bash + visudo # allow user to sudo without password + # as your user + ansible-galaxy collection install community.general + ./playbook.sh + +# Fedora + + sudo visudo # allow user to sudo without password + sudo dnf install -y ansible ansible-collection-general + ./playbook.sh + +# All operating systems + + bw server https://bitwarden.penguincoder.org + bw login + # configure `BW_SESSION` + chezmoi init ssh://git@git.penguincoder.org:2222/penguincoder/dotfiles.git + chezmoi apply diff --git a/apt.yml b/apt.yml new file mode 100644 index 0000000..4d2ff45 --- /dev/null +++ b/apt.yml @@ -0,0 +1,5 @@ +--- +- name: install apt applications + apt: + name: jq,vim,emacs,curl,htop,tmux,git,build-essential,libssl-dev,libncurses5-dev,cmake,fzf,awscli,most + state: present diff --git a/base16-outrun-dark-256.sh b/base16-outrun-dark-256.sh new file mode 100755 index 0000000..230166f --- /dev/null +++ b/base16-outrun-dark-256.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# Base16 Outrun Dark - Gnome Terminal color scheme install script +# Hugo Delahousse (http://github.com/hugodelahousse/) +set -x +[[ -f "$HOME/.config/.gnome-terminal-profile-created" ]] && exit 0 +[[ -z "$PROFILE_NAME" ]] && PROFILE_NAME="Base 16 Outrun Dark 256" +[[ -z "$PROFILE_SLUG" ]] && PROFILE_SLUG="base-16-outrun-dark-256" +[[ -z "$DCONF" ]] && DCONF=dconf +[[ -z "$UUIDGEN" ]] && UUIDGEN=uuidgen + +dset() { + local key="$1"; shift + local val="$1"; shift + + if [[ "$type" == "string" ]]; then + val="'$val'" + fi + + "$DCONF" write "$PROFILE_KEY/$key" "$val" +} + +# Because dconf still doesn't have "append" +dlist_append() { + local key="$1"; shift + local val="$1"; shift + + local entries="$( + { + "$DCONF" read "$key" | tr -d '[]' | tr , "\n" | fgrep -v "$val" + echo "'$val'" + } | perl -pe 'chomp if eof' | tr "\n" , + )" + + "$DCONF" write "$key" "[$entries]" +} + +# Newest versions of gnome-terminal use dconf +if which "$DCONF" > /dev/null 2>&1; then + # Check that uuidgen is available + type $UUIDGEN >/dev/null 2>&1 || { echo >&2 "Requires uuidgen but it's not installed. Aborting!"; exit 1; } + + [[ -z "$BASE_KEY_NEW" ]] && BASE_KEY_NEW=/org/gnome/terminal/legacy/profiles: + + if [[ -n "`$DCONF list $BASE_KEY_NEW/`" ]]; then + if which "$UUIDGEN" > /dev/null 2>&1; then + PROFILE_SLUG=`uuidgen` + fi + + if [[ -n "`$DCONF read $BASE_KEY_NEW/default`" ]]; then + DEFAULT_SLUG=`$DCONF read $BASE_KEY_NEW/default | tr -d \'` + else + DEFAULT_SLUG=`$DCONF list $BASE_KEY_NEW/ | grep '^:' | head -n1 | tr -d :/` + fi + + DEFAULT_KEY="$BASE_KEY_NEW/:$DEFAULT_SLUG" + PROFILE_KEY="$BASE_KEY_NEW/:$PROFILE_SLUG" + + # Copy existing settings from default profile + $DCONF dump "$DEFAULT_KEY/" | $DCONF load "$PROFILE_KEY/" + + # Add new copy to list of profiles + dlist_append $BASE_KEY_NEW/list "$PROFILE_SLUG" + + # Update profile values with theme options + dset visible-name "'$PROFILE_NAME'" + dset palette "['#00002a', '#ff4242', '#59f176', '#f3e877', '#66b0ff', '#f10596', '#0ef0f0', '#d0d0fa', '#50507a', '#ff4242', '#59f176', '#f3e877', '#66b0ff', '#f10596', '#0ef0f0', '#f5f5ff']" + dset background-color "'#00002a'" + dset foreground-color "'#d0d0fa'" + dset bold-color "'#d0d0fa'" + dset bold-color-same-as-fg "true" + dset cursor-colors-set "true" + dset cursor-background-color "'#d0d0fa'" + dset cursor-foreground-color "'#00002a'" + dset use-theme-colors "false" + dset use-theme-background "false" + + unset PROFILE_NAME + unset PROFILE_SLUG + unset PROFILE_KEY + unset DCONF + unset UUIDGEN + unset DEFAULT_KEY + unset DEFAULT_SLUG + unset BASE_NEW_KEY + touch "$HOME/.config/.gnome-terminal-profile-created" + exit 0 + fi +fi + +echo "dconf not found" +exit 1 diff --git a/dnf.yml b/dnf.yml new file mode 100644 index 0000000..2673a72 --- /dev/null +++ b/dnf.yml @@ -0,0 +1,8 @@ +--- +- name: install dnf applications + become: yes + become_user: root + become_method: sudo + dnf: + name: jq,vim,emacs,curl,htop,tmux,git,sqlite,sqlite-devel,make,automake,gcc,gcc-c++,kernel-devel,llvm,cmake,awscli,skopeo,ShellCheck,libtool,alien,fakeroot,openssl-devel,zlib-devel,flex,bison,uuid-devel,libtirpc-devel,libaio-devel,elfutils-libelf-devel,libffi-devel,libudev-devel,libblkid-devel,libuuid-devel,podman,libvirt-daemon-kvm,qemu-kvm,most,fzf,nodejs,npm,golang,llvm10,clang + state: present diff --git a/freebsd-inventory.yml b/freebsd-inventory.yml new file mode 100644 index 0000000..7272842 --- /dev/null +++ b/freebsd-inventory.yml @@ -0,0 +1,6 @@ +all: + hosts: + localhost + vars: + ansible_connection: local + ansible_python_interpreter: /usr/local/bin/python3 diff --git a/gnome-terminal.yml b/gnome-terminal.yml new file mode 100644 index 0000000..a0d9248 --- /dev/null +++ b/gnome-terminal.yml @@ -0,0 +1,12 @@ +--- +- name: create linux gnome-terminal profile + when: ansible_facts['system']|lower == 'linux' + script: base16-outrun-dark-256.sh + args: + creates: "{{ ansible_env.HOME }}/.config/.gnome-terminal-profile-created" + +- name: create freebsd gnome-terminal profile + when: ansible_facts['system']|lower == 'freebsd' + script: base16-outrun-dark-256.sh + args: + creates: "{{ ansible_env.HOME }}/.config/.gnome-terminal-profile-created" diff --git a/linux-inventory.yml b/linux-inventory.yml new file mode 100644 index 0000000..aec4a8a --- /dev/null +++ b/linux-inventory.yml @@ -0,0 +1,6 @@ +all: + hosts: + localhost + vars: + ansible_connection: local + ansible_python_interpreter: /usr/bin/python3 diff --git a/localdev.yml b/localdev.yml new file mode 100644 index 0000000..add1074 --- /dev/null +++ b/localdev.yml @@ -0,0 +1,26 @@ +--- +- name: localdev configuration + hosts: all + tasks: + + - name: Install the packages for Fedora + import_tasks: dnf.yml + when: ansible_facts['os_family']|lower == 'redhat' + + - name: Install the packages for Debian + import_tasks: apt.yml + when: ansible_facts['os_family']|lower == 'debian' + + - name: Install the packages for Ubuntu + import_tasks: apt.yml + when: ansible_facts['os_family']|lower == 'ubuntu' + + - name: Install the packages for FreeBSD + import_tasks: pkg.yml + when: ansible_facts['os_family']|lower == 'freebsd' + + - name: Install rust via rustup + import_tasks: rust.yml + + - name: Configure gnome-terminal profile + import_tasks: gnome-terminal.yml diff --git a/neovim.yml b/neovim.yml new file mode 100644 index 0000000..efdc8ac --- /dev/null +++ b/neovim.yml @@ -0,0 +1,5 @@ +--- +- name: clone neovim github repo + ansible.builtin.shell: "cd ~/dev && git clone https://github.com/neovim/neovim.git && cd neovim && gmake && sudo gmake install" + args: + creates: /usr/local/bin/nvim diff --git a/pkg.yml b/pkg.yml new file mode 100644 index 0000000..472c398 --- /dev/null +++ b/pkg.yml @@ -0,0 +1,60 @@ +--- +- name: install pkg applications + become: yes + become_user: root + become_method: sudo + community.general.pkgng: + name: libtool,autogen,libuv,gettext,autoconf,automake,gmake,coreutils,bash,tmux,git,most,node,npm,go,cmake,llvm10 + state: present + +- name: install desktop pkg applications + become: yes + become_user: root + become_method: sudo + community.general.pkgng: + name: gnome3,gdm,firefox,nerd-fonts,cantarell-fonts,evolution,evolution-ews,drm-kmod + state: present + +- name: enable dbus + become: yes + become_user: root + become_method: sudo + community.general.sysrc: + name: dbus_enable + state: value_present + value: "YES" + +- name: enable hald + become: yes + become_user: root + become_method: sudo + community.general.sysrc: + name: hald_enable + state: value_present + value: "YES" + +- name: enable gdm + become: yes + become_user: root + become_method: sudo + community.general.sysrc: + name: gdm_enable + state: value_present + value: "YES" + +- name: fetch ports snapshot + become: yes + become_user: root + become_method: sudo + command: portsnap fetch extract + args: + creates: /usr/ports/.portsnap.INDEX + +- name: install htop + become: yes + become_user: root + become_method: sudo + command: make install-missing-packages install clean + args: + chdir: /usr/ports/sysutils/htop + creates: /usr/local/bin/htop diff --git a/playbook.sh b/playbook.sh new file mode 100755 index 0000000..178b47a --- /dev/null +++ b/playbook.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ "$(uname -s)" = "Linux" ] ; then + ansible-playbook -i linux-inventory.yml localdev.yml +elif [ "$(uname -s)" = "FreeBSD" ] ; then + ansible-playbook -i freebsd-inventory.yml localdev.yml +fi diff --git a/rust.yml b/rust.yml new file mode 100644 index 0000000..7fadd5c --- /dev/null +++ b/rust.yml @@ -0,0 +1,151 @@ +--- +- name: install rustup + command: curl -o t.sh https://sh.rustup.rs -sSf && chmod 700 t.sh && ./t.sh --no-modify-path --verbose -y --default-toolchain stable && rm -f t.sh && ~/.cargo/bin/rustup install toolchain nightly + args: + warn: False + creates: "{{ ansible_env.HOME }}/.cargo/bin/rustup" + +- name: install amber + command: cargo install amber + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/ambr" + +- name: install basic-http-server + command: cargo install basic-http-server + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/basic-http-server" + +- name: install bat + command: cargo install bat + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/bat" + +- name: install btm + command: cargo install btm + when: ansible_facts['system']|lower == 'linux' + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/btm" + +- name: install choose + command: cargo install choose + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/choose" + +- name: install delta + command: cargo install git-delta + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/delta" + +- name: install dust + command: cargo install du-dust + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/dust" + +- name: install endbasic + command: cargo install endbasic + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/endbasic" + +- name: install exa + command: cargo install exa + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/exa" + +- name: install fd + command: cargo install fd-find + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/fd" + +- name: install frawk freebsd + shell: LLVM_SYS_100_PREFIX=/usr/local/llvm10 cargo +nightly install frawk + when: ansible_facts['system']|lower == 'freebsd' + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/frawk" + +- name: install frawk linux + command: cargo +nightly install frawk + when: ansible_facts['system']|lower == 'linux' + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/frawk" + +- name: install git-gone + command: cargo install git-gone + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/git-gone" + +- name: install gitui + command: cargo install gitui + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/gitui" + +- name: install gget + command: cargo install gget + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/gget" + +- name: install grex + command: cargo install grex + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/grex" + +- name: install hexyl + command: cargo install hexyl + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/hexyl" + +- name: install hyperfine + command: cargo install hyperfine + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/hyperfine" + +- name: install kondo + command: cargo install kondo + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/kondo" + +- name: install kubie + command: cargo install kubie + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/kubie" + +- name: install lsd + command: cargo install lsd + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/lsd" + +- name: install mdbook + command: cargo install mdbook + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/mdbook" + +- name: install ncgopher + command: cargo install ncgopher + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/ncgopher" + +- name: install rg + command: cargo install ripgrep + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/rg" + +- name: install stargazer + command: cargo install stargazer + when: ansible_facts['system']|lower == 'linux' + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/stargazer" + +- name: install wasm-pack + command: cargo install wasm-pack + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/wasm-pack" + +- name: install xcp + command: cargo install xcp + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/xcp" + +- name: install ytop + command: cargo install ytop + when: ansible_facts['system']|lower == 'linux' + args: + creates: "{{ ansible_env.HOME }}/.cargo/bin/ytop"