Inital commit

Good start
Added roles for setting up a user with zsh config and ssh keys
Also installation and configuriation of some packages
This commit is contained in:
2022-03-14 01:16:44 +01:00
parent 27a60cb898
commit b3d85445c5
18 changed files with 209 additions and 2 deletions

View File

View File

@@ -0,0 +1 @@
permit nopass siv as root

View File

@@ -0,0 +1,44 @@
- name: Install and configure packages
block:
- name: Install the good stuff (pacman)
pacman: name={{ packages }} state=latest
when: "'pacman' in group_names"
tags: pacman
- name: Add some repos (alpine)
become: yes
shell: cmd="cat > /etc/apk/repositories << EOF; $(echo)
https://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main/
https://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community/
https://dl-cdn.alpinelinux.org/alpine/edge/testing/
EOF"
when: "'alpine' in group_names"
- name: Install the good stuff (apk)
apk: name={{ packages }} state=latest
when: "'apk' in group_names or 'alpine' in group_names"
tags: apk
- name: Install the good stuff (apt)
apt: package={{ packages }} state=latest
when: "'apt' in group_names"
tags: apt
- name: Add /etc/doas.conf
copy: src=doas.conf dest=/etc/doas.conf owner=root group=root mode=0644
tags: system
rescue:
- name: Uninstall the good stuff (pacman)
pacman: name={{ packages }} state=absent
when: "'pacman' in group_names"
tags: pacman
- name: Uninstall the good stuff (apk)
apk: name={{ packages }} state=absent
when: "'apk' in group_names or 'alpine' in group_names"
tags: apk
- name: Uninstall the good stuff (apt)
apt: package={{ packages }} state=absent
when: "'apt' in group_names"
tags: apt
- name: Remove /etc/doas.conf
file: state=absent path=/etc/doas.conf
tags: system

17
roles/update/main.yml Normal file
View File

@@ -0,0 +1,17 @@
- name: Update and upgrade pacman packages
pacman:
update_cache: yes
upgrade: yes
tags: pacman
- name: Update and upgrade apk packages
become: true
apk:
update_cache: yes
upgrade: yes
tags: apk
- name: Update and upgrade apt packages
become: true
apt:
update_cache: yes
upgrade: yes
tags: apt

15
roles/user/tasks/main.yml Normal file
View File

@@ -0,0 +1,15 @@
- name: Create user
user:
name="{{ name }}"
groups="{{ item }}"
shell="{{ shell }}"
append=yes
ignore_errors: yes
with_items:
- "{{ user_groups }}"
- name: Add SSH pubkeys
authorized_key:
user="{{ name }}"
key="{{ item }}"
with_items:
- "{{ pubkeys }}"

View File

@@ -0,0 +1,7 @@
#!/bin/sh
alias\
ls="lsd -h --color=auto --group-dirs first"\
ll="ls -l"\
la="ls -a"\
diff="diff --color=auto"\
grep="grep --color=auto -n"

6
roles/zsh/files/bat.conf Normal file
View File

@@ -0,0 +1,6 @@
--theme "Solarized (dark)"
--style "numbers,changes,header"
--map-syntax "*.ino:C++"
--decorations auto
--color auto
--tabs 2

16
roles/zsh/files/env.sh Normal file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
export LS_COLORS='di=1;35:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90:*.png=35:*.gif=36:*.jpg=35:*.c=92:*.jar=33:*.py=93:*.h=90:*.txt=94:*.doc=104:*.docx=104:*.odt=104:*.csv=102:*.xlsx=102:*.xlsm=102:*.rb=31:*.cpp=92:*.sh=92:*.html=96:*.zip=4;33:*.tar.gz=4;33:*.mp4=105:*.mp3=106'
[ -d ~/.npm/node_modules/.bin ] && PATH=~/.npm/node_modules/.bin:$PATH
[ -d ~/.go/bin ] && PATH=~/.go/bin:$PATH
[ -d ~/.cargo/bin ] && PATH=~/.cargo/bin:$PATH
[ -d ~/.local/bin ] && PATH=~/.local/bin:$PATH
[ -d ~/.emacs.d/bin ] && PATH=~/.emacs.d/bin:$PATH
[ -e ~/.aliases ] && source ~/.aliases
export EDITOR=/usr/bin/vim
export HISTFILE=~/.histfile
export HISTSIZE=42069
export SAVEHIST=42069
export PAGER="less"
export BAT_CONFIG_PATH=~/.bat.conf
export GOPATH=~/.go
export PATH

15
roles/zsh/files/zshrc.zsh Normal file
View File

@@ -0,0 +1,15 @@
[[ $- != *i* ]] && return
PROMPT="%F{yellow}% %n%F{green}% @%F{blue}% %m %F{#bb33bb}% %1~%f > "
setopt autocd extendedglob nomatch notify prompt_subst
autoload -Uz compinit && compinit
unsetopt beep
bindkey -v
[ -e ~/.zstyles ] && source ~/.zstyles
[ -e ~/.env ] && source ~/.env
for src in `/bin/ls ~/.zshrc.d`; do
[ -e $src ] && source $src
done
source ~/.zshrc.d/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

View File

@@ -0,0 +1,13 @@
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' max-errors 1
zstyle ':completion::complete:*' use-cache 1
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git*+set-message:*' hooks untracked-git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr '!'
zstyle ':vcs_info:*' stagedstr '+'
zstyle ':vcs_info:*' formats "%f%s(%F{red}%r/%b%f)%c "$'\n'" %F{#bb33bb}% %S%f"

33
roles/zsh/tasks/main.yml Normal file
View File

@@ -0,0 +1,33 @@
- name: Setup user zsh config
block:
- name: Add .zshrc
copy: src=zshrc.zsh dest=/home/{{ name }}/.zshrc owner={{ name }} group={{ name }} mode=0755
- name: Add zsh zstyles config
copy: src=zstyles.zsh dest=/home/{{ name }}/.zstyles owner={{ name }} group={{ name }} mode=0755
- name: Add .env file
copy: src=env.sh dest=/home/{{ name }}/.env owner={{ name }} group={{ name }} mode=0755
- name: Add .aliases
copy: src=aliases.sh dest=/home/{{ name }}/.aliases owner={{ name }} group={{ name }} mode=0755
- name: Add .bat.conf
copy: src=bat.conf dest=/home/{{ name }}/.bat.conf owner={{ name }} group={{ name }} mode=0755
- name: Install zsh syntax highlighting
git:
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
dest: /home/{{ name }}/.zshrc.d/zsh-syntax-highlighting
update: yes
clone: yes
rescue:
- name: Remove .zshrc
file: state=absent path=/home/{{ name }}/.zshrc
- name: Remove zsh zstyles config
file: state=absent path=/home/{{ name }}/.zstyles
- name: Remove .env file
file: state=absent path=/home/{{ name }}/.env
- name: Remove .aliases
file: state=absent path=/home/{{ name }}/.aliases
- name: Remove .bat.conf
file: state=absent path=/home/{{ name }}/.bat.conf
# - name: Remove zsh syntax highlighting
# file: state=absent path=/home/{{ name }}/.zshrc.d/zsh-syntax-highlighting