Move from dotfiles to roles-based playbooks

This commit is contained in:
Anthony Rose 2019-10-03 11:50:19 +01:00
commit 57fa030b8f
22 changed files with 648 additions and 0 deletions

8
main.yml Normal file
View file

@ -0,0 +1,8 @@
---
- name: Setup
hosts: localhost
tasks:
- include_role:
name: distro
- include_role:
name: home

View file

@ -0,0 +1,42 @@
---
- name: Install packages
become: true
apt:
name: '{{ packages }}'
state: present
force_apt_get: yes
vars:
packages:
- apt-file
- asciidoctor
- caja-open-terminal
- dc
- desktop-base
- dnsutils
- emacs
- evolution
- galculator
- git
- git-gui
- mc
- mpv
- nextcloud-desktop
- nmap
- packagekit
- python3
- realmd
- redshift-gtk
- remmina
- rxvt-unicode
- seahorse
- sqlite3
- sssd
- sudo
- task-british-desktop
- task-mate-desktop
- tlp
- tmux
- vim-gtk
- xinput
- xterm
- zsh

View file

@ -0,0 +1,4 @@
---
- include: debian.yml
when: ansible_distribution == 'Debian'
- include: modules.yml

View file

@ -0,0 +1,13 @@
---
- name: Blacklist pcspkr module
become: true
lineinfile:
path: /etc/modprobe.d/blacklist.conf
line: blacklist pcspkr
create: yes
- name: Blacklist dvb_usb_rtl28xxu module
become: true
lineinfile:
path: /etc/modprobe.d/blacklist.conf
line: blacklist dvb_usb_rtl28xxu
create: yes

View file

@ -0,0 +1,67 @@
*color: true
URxvt*background: #111111
URxvt*color0: #1e1e1e
URxvt*color1: #cc0000
URxvt*color2: #4e9a06
URxvt*color3: #c4a000
URxvt*color4: #3465a4
URxvt*color5: #75507b
URxvt*color6: #0b939b
URxvt*color7: #d3d7cf
URxvt*color8: #555753
URxvt*color9: #ef2929
URxvt*color10: #8ae234
URxvt*color11: #fce94f
URxvt*color12: #729fcf
URxvt*color13: #ad7fa8
URxvt*color14: #00f5e9
URxvt*color15: #eeeeec
URxvt*font: xft:Monospace:Regular:size=10
URxvt*foreground: #c0c0c0
URxvt*letterSpace: -1
URxvt*locale: true
URxvt*metaSendsEscape: true
URxvt*perl-ext: -searchable-scrollback
URxvt*scrollBar_right: true
URxvt*termName: rxvt-unicode
XClock*hourColor: black
XClock*majorColor: red
XClock*minorColor: black
XClock*minuteColor: black
XClock*render: true
XClock*secondColor: red
XClock*update: 1
Xft.hintstyle: hintfull
Xft.rgba: none
xterm*background: #111111
xterm*color0: #1e1e1e
xterm*color1: #cc0000
xterm*color2: #4e9a06
xterm*color3: #c4a000
xterm*color4: #3465a4
xterm*color5: #75507b
xterm*color6: #0b939b
xterm*color7: #d3d7cf
xterm*color8: #555753
xterm*color9: #ef2929
xterm*color10: #8ae234
xterm*color11: #fce94f
xterm*color12: #729fcf
xterm*color13: #ad7fa8
xterm*color14: #00f5e9
xterm*color15: #eeeeec
xterm*faceName: xft:Monospace:Regular:size=10
xterm*faceSize1: 4
xterm*faceSize2: 6
xterm*faceSize3: 8
xterm*faceSize4: 12
xterm*faceSize5: 14
xterm*faceSize6: 16
xterm*faceSize: 9
xterm*foreground: #c0c0c0
xterm*locale: true
xterm*metaSendsEscape: true
xterm*scrollBar: true
xterm*utf8: always
xterm*utf8Fonts: always
xterm*utf8Title: true

View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
if [ -r $HOME/.profile ]; then
. $HOME/.profile
fi

4
roles/home/files/bashrc Normal file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
if [ -r $HOME/.shrc ]; then
. $HOME/.shrc
fi

View file

@ -0,0 +1,50 @@
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<!-- Smooth fonts. -->
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
<edit mode="assign" name="hinting">
<bool>true</bool>
</edit>
<edit mode="assign" name="hintstyle">
<const>hintslight</const>
</edit>
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
<edit mode="assign" name="lcdfilter">
<const>lcddefault</const>
</edit>
</match>
<!-- Substitute basic PostScript fonts with better looking ones. -->
<match target="pattern">
<test qual="any" name="family">
<string>Times</string>
</test>
<edit name="family" mode="assign">
<string>Liberation Serif</string>
</edit>
</match>
<match target="pattern">
<test qual="any" name="family">
<string>Helvetica</string>
</test>
<edit name="family" mode="assign">
<string>Liberation Sans</string>
</edit>
</match>
<match target="pattern">
<test qual="any" name="family">
<string>Courier</string>
</test>
<edit name="family" mode="assign">
<string>Liberation Mono</string>
</edit>
</match>
</fontconfig>

View file

@ -0,0 +1,26 @@
[pull]
rebase = true
[push]
default = simple
[color]
ui = auto
[credential]
helper = store
[alias]
ci = commit
co = checkout
ff = merge --ff-only
graph = log --graph --oneline --all
l1 = log --pretty=oneline
last = log -1 HEAD --pretty=fuller
unstage = reset HEAD --
up = pull --rebase
[gui]
encoding = utf-8
recentrepo = /home/acp/data/he
[guitool "Rebase"]
cmd = rebase
[user]
name = Anthony Perkins
email = anthony@acperkins.com

View file

1
roles/home/files/inputrc Normal file
View file

@ -0,0 +1 @@
set bell-style none

View file

@ -0,0 +1,69 @@
[Toplevel top]
expand=true
orientation=top
size=32
[Object menu]
object-type=menu
toplevel-id=top
position=0
locked=true
[Object terminal]
object-type=launcher
launcher-location=/usr/share/applications/mate-terminal.desktop
toplevel-id=top
position=10
locked=true
[Object file-browser]
object-type=launcher
launcher-location=/usr/share/applications/caja-browser.desktop
toplevel-id=top
position=20
locked=true
[Object text-editor]
object-type=launcher
launcher-location=/usr/share/applications/gvim.desktop
toplevel-id=top
position=30
locked=true
[Object web-browser]
object-type=launcher
launcher-location=/usr/share/applications/firefox-esr.desktop
toplevel-id=top
position=40
locked=true
[Object window-list]
object-type=applet
applet-iid=WnckletFactory::WindowListApplet
toplevel-id=top
position=50
locked=true
[Object workspace-switcher]
object-type=applet
applet-iid=WnckletFactory::WorkspaceSwitcherApplet
toplevel-id=top
position=20
panel-right-stick=true
locked=true
[Object notification-area]
object-type=applet
applet-iid=NotificationAreaAppletFactory::NotificationArea
toplevel-id=top
position=10
panel-right-stick=true
locked=true
[Object clock]
object-type=applet
applet-iid=ClockAppletFactory::ClockApplet
toplevel-id=top
position=0
panel-right-stick=true
locked=true

16
roles/home/files/profile Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
if [ -r /etc/profile ]; then
. /etc/profile
fi
export BASH_ENV="$HOME/.bashrc"
export BLOCKSIZE="K"
export EDITOR="vi"
export ENV="$HOME/.shrc"
export LANG="en_GB.UTF-8"
export PAGER="less"
if [ -r $HOME/.profile.$(hostname -s) ]; then
. $HOME/.profile.$(hostname -s)
fi

228
roles/home/files/shrc Normal file
View file

@ -0,0 +1,228 @@
#!/bin/sh
umask 0022
set -o emacs
set -o noclobber
# Locale and language.
export LC_ALL=
export LANG="en_GB.UTF-8"
export LANGUAGE="en_GB:en"
export LC_ADDRESS="en_GB.UTF-8"
export LC_COLLATE="en_GB.UTF-8"
export LC_CTYPE="en_GB.UTF-8"
export LC_IDENTIFICATION="en_GB.UTF-8"
export LC_MEASUREMENT="en_GB.UTF-8"
export LC_MESSAGES="en_GB.UTF-8"
export LC_MONETARY="en_GB.UTF-8"
export LC_NAME="en_GB.UTF-8"
export LC_NUMERIC="en_GB.UTF-8"
export LC_PAPER="en_GB.UTF-8"
export LC_TELEPHONE="en_GB.UTF-8"
export LC_TIME="en_GB.UTF-8"
export PAPERSIZE="a4"
export TIME_STYLE="long-iso"
# Other exports.
export EDITOR=vi
export PYTHONWARNINGS="ignore::UserWarning"
if [ "$SHELL" = "/bin/sh" ]; then
export PS1='\$ '
else
export PS1='${SSH_TTY:+[$(id -un)@$(hostname -s)]}\$ '
fi
if [ "$BASH" ]; then
shopt -s histappend
bind '"\e[1;5C": forward-word'
bind '"\e[1;5D": backward-word'
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
fi
if [ "$ZSH_VERSION" ]; then
# Command history.
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[[A" history-beginning-search-backward-end
bindkey "^[[B" history-beginning-search-forward-end
bindkey "^[OA" history-beginning-search-backward-end
bindkey "^[OB" history-beginning-search-forward-end
bindkey "^[[1;5C" forward-word # Ctrl-Right
bindkey "^[[1;5D" backward-word # Ctrl-Left
bindkey "^[[3;5~" delete-char # Ctrl-Del
bindkey "^[[3~" delete-char # Del
export HISTFILE=$HOME/.zsh_history
export HISTSIZE=1000000
export SAVEHIST=1000000
setopt EXTENDED_HISTORY
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt PROMPT_SUBST
setopt SHARE_HISTORY
fi
LSOPTIONS="-F"
if ls --color=auto /dev/null 2>/dev/null 1>/dev/null; then
LSOPTIONS="$LSOPTIONS --color=auto"
fi
if [ "$(uname -s)" = "FreeBSD" ]; then
LSOPTIONS="$LSOPTIONS -G"
fi
alias adoc="asciidoctor -a stylesheet=$HOME/.asciidoctor.css"
alias cal="ncal -w"
alias df="df -x squashfs"
alias ec="emacsclient -c"
alias en="emacsclient -nw"
alias f="fossil"
alias ll="/bin/ls -l"
alias ls="/bin/ls $LSOPTIONS"
alias now="date +%Y%m%dT%H%M%S%z"
alias nowu="date -u +%Y%m%dT%H%M%SZ"
alias ta="$HOME/opt/textadept/textadept"
alias tm="tmux -2 attach-session || tmux -2 new-session"
alias wg="wordgrinder"
alias ytmp3="youtube-dl -q -x --audio-format=mp3"
if [ ! -d "$HOME/.local/bin" ]; then
/bin/mkdir -p "$HOME/.local/bin"
fi
# Alias vi to vim if it is installed
if [ -x /usr/bin/vim ] || [ -x /usr/local/bin/vim ]; then
alias vi="vim"
fi
# Set up GOPATH
export GOPATH="$HOME/data/go"
if [ -x /usr/bin/go ] || [ -x /usr/local/bin/go ]; then
if [ ! -d "$GOPATH" ]; then
/bin/mkdir -p "$GOPATH/bin"
/bin/mkdir -p "$GOPATH/pkg"
/bin/mkdir -p "$GOPATH/src"
fi
fi
# Useful aliases for Podman and Docker
alias prun="podman run --rm -it"
alias prunx="podman run -v /tmp/.X11-unix:/tmp/.X11-unix:ro -e DISPLAY=\"unix\$DISPLAY\""
alias drun="sudo docker run --rm -it"
alias drunx="sudo docker run -v /tmp/.X11-unix:/tmp/.X11-unix:ro -e DISPLAY=\"unix\$DISPLAY\""
PATH="/usr/bin:/bin"
for dir in $HOME/.local/bin \
$HOME/bin \
/app/bin \
/snap/bin \
/sbin \
/usr/sbin \
/usr/X11R6/bin \
/usr/X11R7/bin \
/usr/local/bin \
/usr/local/sbin \
/usr/pkg/bin \
/usr/pkg/sbin \
/usr/games \
/usr/local/heirloom-doctools/bin \
/var/lib/snapd/snap/bin \
$GOPATH/bin \
$HOME/.cargo/bin \
; do
if [ -d "$dir" ]; then
PATH="$PATH:$dir"
fi
done
export PATH
MANPATH="/usr/share/man"
for dir in $HOME/.local/share/man \
/usr/X11R6/man \
/usr/X11R7/man \
/usr/local/man \
/usr/pkg/man \
/usr/local/share/man \
/usr/local/heirloom-doctools/man \
; do
if [ -d "$dir" ]; then
MANPATH="$MANPATH:$dir"
fi
done
export MANPATH
mkcd () {
if [ $# -ne 1 ]; then
echo "mkcd: incorrect arguments (one directory required)." >&2
return 1
else
mkdir -p "$1"
cd "$1"
fi
}
termtitle () {
echo -en "\033]0;$1\007"
}
linapm () {
cat /sys/class/power_supply/BAT0/{status,capacity}
}
cman () {
# md: start bold
# us: start underline
# ue: end underline
# me: end bold, blink, and underline
env MANPAGER=less \
LESS_TERMCAP_md=$'\e[1;36m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_us=$'\e[4;32m' \
LESS_TERMCAP_ue=$'\e[0m' \
/usr/bin/man "$1"
}
xa () {
OUT=$(xrandr --listactivemonitors | awk 'NR!=1{print " "$NF" "}')
for monitor in "${OUT}"; do
m=$(echo $monitor | sed 's/ //g')
xrandr --output $m --auto
done
}
if [ -x /usr/bin/yum ] && [ ! -x /usr/bin/dnf ]; then
alias dnf='yum'
fi
if [ -x /usr/bin/svnlite ] && [ ! -x /usr/local/bin/svn ]; then
alias svn='svnlite'
alias svnadmin='svnliteadmin'
alias svndumpfilter='svnlitedumpfilter'
alias svnlook='svnlitelook'
alias svnmucc='svnlitemucc'
alias svnrdump='svnliterdump'
alias svnserve='svnliteserve'
alias svnsync='svnlitesync'
alias svnversion='svnliteversion'
fi
case $- in
*i*)
# Shell is interactive
printf "\033[7m"
uname -sr
printf "\033[0m"
if [ -r /etc/os-release ]; then
echo " $(. /etc/os-release; echo $PRETTY_NAME)"
fi
;;
*)
;;
esac
if [ -r $HOME/.shrc.$(hostname -s) ]; then
. $HOME/.shrc.$(hostname -s)
fi

View file

@ -0,0 +1,12 @@
bind-key C command-prompt -p "Execute:" "new-window '%1'"
bind-key M-'"' command-prompt -p "Execute:" "split-window '%1'"
bind-key M-% command-prompt -p "Execute:" "split-window -h '%1'"
bind-key R source-file "${HOME}/.tmux.conf"
bind-key S command-prompt -p "Move to:" "swap-pane -s. -t%1 \; select-pane -t%1"
set -g base-index 1
set -g default-command "$SHELL"
set -g default-terminal "screen-256color"
set -g display-panes-time 5000
set -g pane-base-index 1
set -g status-right ''
set-window-option -g xterm-keys on

3
roles/home/files/zshrc Normal file
View file

@ -0,0 +1,3 @@
if [ -r $HOME/.shrc ]; then
. $HOME/.shrc
fi

View file

@ -0,0 +1,38 @@
---
- name: Clone emacs settings
git:
repo: https://git.acperkins.com/acp/emacs.d.git
dest: "{{ ansible_env.HOME }}/.emacs.d"
- name: Find emacs service definition
find:
paths: /usr/share/emacs
patterns: 'emacs.service'
recurse: yes
depth: 3
register: emacs_service_files
- name: Create systemd user directory
file:
path: "{{ ansible_env.HOME }}/.config/systemd/user"
state: directory
- name: Create emacs user service
copy:
src: '{{ item.path }}'
dest: "{{ ansible_env.HOME }}/.config/systemd/user/emacs.service"
remote_src: yes
loop: '{{ emacs_service_files.files }}'
- name: Start emacs user service
systemd:
name: emacs.service
scope: user
daemon_reload: yes
enabled: yes
state: started
- name: Create user applications directory
file:
path: "{{ ansible_env.HOME }}/.local/share/applications"
state: directory
- name: Create emacs client launcher
copy:
src: "{{ ansible_env.HOME }}/.emacs.d/emacs-client.desktop"
dest: "{{ ansible_env.HOME }}/.local/share/applications/emacs-client.desktop"
remote_src: yes

View file

@ -0,0 +1,6 @@
---
- include: repos.yml
- include: vim.yml
- include: shell.yml
- include: emacs.yml
- include: mate.yml

View file

@ -0,0 +1,6 @@
---
- name: Copy MATE panel layout
become: true
copy:
src: mate-acp.layout
dest: /usr/share/mate-panel/layouts/acp.layout

View file

@ -0,0 +1,5 @@
---
- name: Clone vim settings
git:
repo: https://git.acperkins.com/acp/vimfiles.git
dest: "{{ ansible_env.HOME }}/.vim"

View file

@ -0,0 +1,21 @@
---
- name: Copy .bashrc
copy:
src: bashrc
dest: "{{ ansible_env.HOME }}/.bashrc"
- name: Copy .bash_profile
copy:
src: bash_profile
dest: "{{ ansible_env.HOME }}/.bash_profile"
- name: Copy .profile
copy:
src: profile
dest: "{{ ansible_env.HOME }}/.profile"
- name: Copy .shrc
copy:
src: shrc
dest: "{{ ansible_env.HOME }}/.shrc"
- name: Copy .zshrc
copy:
src: zshrc
dest: "{{ ansible_env.HOME }}/.zshrc"

25
roles/home/tasks/vim.yml Normal file
View file

@ -0,0 +1,25 @@
---
- name: Copy .Xresources
copy:
src: Xresources
dest: "{{ ansible_env.HOME }}/.Xresources"
- name: Copy .fonts.conf
copy:
src: fonts.conf
dest: "{{ ansible_env.HOME }}/.fonts.conf"
- name: Copy .gitconfig
copy:
src: gitconfig
dest: "{{ ansible_env.HOME }}/.gitconfig"
- name: Copy .inputrc
copy:
src: inputrc
dest: "{{ ansible_env.HOME }}/.inputrc"
- name: Copy .tmux.conf
copy:
src: tmux.conf
dest: "{{ ansible_env.HOME }}/.tmux.conf"
- name: Copy .hushlogin
copy:
src: hushlogin
dest: "{{ ansible_env.HOME }}/.hushlogin"