This commit is contained in:
sfigato 2020-08-07 19:59:07 +02:00
commit 27dbb4e032
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
17 changed files with 369 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.vagrant

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM debian:buster
ARG UID 1000
ARG GID 1000
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y \
openssh-server \
supervisord \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* \
&& groupadd -g ${GID} chic \
&& useradd -u ${UID} -g ${GID} plinio
COPY docker/supervisord.conf /etc/supervisord.conf
EXPOSE 2222
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]

5
Makefile Normal file
View File

@ -0,0 +1,5 @@
build:
docker build -t zsh_chic_ansible:latest .
run:
ansible

29
README.md Normal file
View File

@ -0,0 +1,29 @@
# Zsh chic
An ansible role to ensure your zsh is très chic
### How
Feed something like this to your role
```yml
zsh_chic:
users:
- username: root
home: /root
group: root
antibody: true
- username: qui
home: /home/qui
group: qui
starship: true
- username: quo
home: /home/quo
group: quo
antibody: true
- username: qua
home: /home/qua
group: qua
```
**WARNING**: this role is suited only for debian (buster and maybe bullseye).

31
Vagrantfile vendored Normal file
View File

@ -0,0 +1,31 @@
# This guide is optimized for Vagrant 1.7 and above.
# Although versions 1.6.x should behave very similarly, it is recommended
# to upgrade instead of disabling the requirement below.
Vagrant.require_version ">= 1.7.0"
Vagrant.configure(2) do |config|
config.vm.box = "debian/buster64"
config.vm.define "debiantest" do |m|
m.vm.hostname = "debiantest"
m.vm.network :private_network, ip: "192.168.123.2", libvirt__dhcp_enabled: false
m.vm.synced_folder ".", "/vagrant", disabled: true
end
# Disable the new default behavior introduced in Vagrant 1.7, to
# ensure that all Vagrant machines will use the same SSH key pair.
# See https://github.com/mitchellh/vagrant/issues/5005
config.ssh.insert_key = false
config.vm.provider :libvirt do |lv|
lv.cpus = 2
lv.memory = 1024
end
config.vm.provision "ansible" do |ansible|
ansible.become = true
ansible.verbose = "v"
ansible.playbook = "playbook.yml"
ansible.inventory_path = "inventory"
end
end

2
ansible.cfg Normal file
View File

@ -0,0 +1,2 @@
[defaults]
roles_path = ../

4
defaults/main.yml Normal file
View File

@ -0,0 +1,4 @@
---
zsh_chic:
antibody: false
starship: false

5
files/starship.toml Normal file
View File

@ -0,0 +1,5 @@
[hostname]
ssh_only = false
prefix = "⟪"
suffix = "⟫"
disabled = false

1
inventory Normal file
View File

@ -0,0 +1 @@
debiantest

15
playbook.yml Normal file
View File

@ -0,0 +1,15 @@
---
- hosts: debiantest
gather_facts: yes
vars_files:
- ./test_vars.yml
pre_tasks:
- name: Add dummy users
user:
name: "{{ item.username }}"
state: present
password: $6$LqIjU1/Cd$Uou/9gTKyP/qPHnI0EWcuUYg.7DsI9zNOTeDUWk8pH7/.ncgZGwIGXupGRxPNtqw/w6p/6Ls84Bddvfu3D9p9/
with_items: "{{ zsh_chic.users }}"
roles:
- zsh_chic

21
tasks/antibody.yml Normal file
View File

@ -0,0 +1,21 @@
---
- name: Download antibody installer
get_url:
url: https://git.io/antibody
dest: /tmp/antibody-installer.sh
owner: root
group: root
mode: 0755
- name: Run antibody installer
shell:
cmd: /tmp/antibody-installer.sh
chdir: /usr
- name: Copy antibody plugin list
template:
src: templates/antibody.plugins.zsh.j2
dest: /usr/share/zsh/antibody.plugins.zsh
owner: root
group: root
mode: 0755

67
tasks/main.yml Normal file
View File

@ -0,0 +1,67 @@
---
- name: Ensure zsh is present
apt:
name:
- zsh
- tmux
- fzf
- curl
- git
- fasd
- ripgrep
state: present
- name: Obtain bat .deb package
get_url:
url: https://github.com/sharkdp/bat/releases/download/v0.13.0/bat_0.13.0_amd64.deb
dest: /tmp/bat_0.13.0_amd64.deb
owner: root
group: root
mode: 0755
register: new_bat_deb
- name: Install bat
shell: dpkg -i /tmp/bat_0.13.0_amd64.deb
when: new_bat_deb is defined and new_bat_deb.changed
- include_tasks: antibody.yml
- include_tasks: starship.yml
- include_tasks: powerline.yml
- name: Clone fzf repo to get completion and keybindings
git:
repo: 'https://github.com/junegunn/fzf'
dest: /opt/fzf
- name: Install zshrc template for each provided user
template:
src: templates/zshrc.j2
dest: "{{ item.home }}/.zshrc"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0644
vars:
antibody: "{{ item.antibody|default(false) }}"
starship: "{{ item.starship|default(false) }}"
powerline: "{{ item.powerline|default(false) }}"
locale: "{{ item.locale|default('en_US.UTF-8') }}"
term: "{{ item.term|default(None) }}"
with_items: "{{ zsh_chic.users }}"
- name: Set zsh as default shell for each provided user
user:
name: "{{ item.username }}"
shell: /bin/zsh
with_items: "{{ zsh_chic.users }}"
- name: Copy starship config for use who use it
copy:
src: files/starship.toml
dest: "{{ item.home }}/.starship.toml"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0644
when: item.starship is defined and item.starship
with_items: "{{ zsh_chic.users }}"

5
tasks/powerline.yml Normal file
View File

@ -0,0 +1,5 @@
---
- name: Install powerline
apt:
name: powerline
state: present

19
tasks/starship.yml Normal file
View File

@ -0,0 +1,19 @@
---
- name: Download starship binary
get_url:
url: https://github.com/starship/starship/releases/download/{{ version }}/starship-x86_64-unknown-linux-gnu.tar.gz
dest: /root/starship.tar.gz
owner: root
group: root
mode: 0755
vars:
version: "v0.39.0"
- name: Extract and install starship binary
unarchive:
src: /root/starship.tar.gz
dest: /usr/local/bin
remote_src: yes
owner: root
group: root
mode: 0755

View File

@ -0,0 +1,13 @@
leophys/ohmyzsh path:lib
leophys/ohmyzsh path:themes/agnoster-server.zsh-theme
leophys/ohmyzsh path:plugins/colored-man-pages
leophys/ohmyzsh path:plugins/docker
leophys/ohmyzsh path:plugins/gitfast
ael-code/zsh-gpg-agent
ael-code/zsh-plugin-fasd-fzf
ael-code/zsh-colored-man-pages
leophys/zsh-plugin-fzf-finder
zsh-users/zsh-autosuggestions
junegunn/fzf
wfxr/forgit

98
templates/zshrc.j2 Normal file
View File

@ -0,0 +1,98 @@
# Local pre scripts
if [[ -d $HOME/.config/zsh/pre ]] && [[ "$(ls $HOME/.config/zsh/pre)" ]] ; then
for script in $HOME/.config/zsh/pre/*; do
. $script
done
fi
# Locales
export LANG={{ locale }}
export LANGUAGE={{ locale.split(".")[0] }}
export LC_CTYPE="{{ locale }}"
export LC_NUMERIC="{{ locale }}"
export LC_TIME="{{ locale }}"
export LC_COLLATE="{{ locale }}"
export LC_MONETARY="{{ locale }}"
export LC_MESSAGES="{{ locale }}"
export LC_PAPER="{{ locale }}"
export LC_NAME="{{ locale }}"
export LC_ADDRESS="{{ locale }}"
export LC_TELEPHONE="{{ locale }}"
export LC_MEASUREMENT="{{ locale }}"
export LC_IDENTIFICATION="{{ locale }}"
export LC_ALL=
{% if term is defined and term != "" %}
export TERM={{ term }}
{% endif -%}
{% if antibody %}
autoload -Uz compinit
compinit
source <(antibody init)
source /usr/share/doc/fzf/examples/key-bindings.zsh
antibody bundle < /usr/share/zsh/antibody.plugins.zsh
{% endif -%}
{% if starship %}
autoload -U select-word-style
select-word-style bash
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory
export STARSHIP_CONFIG=${HOME}/.starship.toml
eval "$(starship init zsh)"
{% endif -%}
source /opt/fzf/shell/completion.zsh
source /opt/fzf/shell/key-bindings.zsh
eval "$(fasd --init auto)"
alias t="tmux -2"
alias sy="systemctl"
alias ssy="sudo systemctl"
alias syu="systemctl --user"
alias ls="ls --color=tty"
alias l="ls -1"
alias lt="ls -lt"
alias lh="ls -lh"
alias la="ls -la"
alias ll="ls -l"
alias lrt="ls -lrt"
alias vf="cd \$(git rev-parse --show-toplevel)"
alias vvf="cd \$(${HOME}/.bin/vvf.sh)"
{% if localbin is defined %}
if [ -d ${HOME}/{{ localbin }} ]; then
export PATH=${HOME}/{{ localbin }}:$PATH
fi
{% endif %}
{% if powerline %}
if which powerline-daemon > /dev/null; then
powerline-daemon -q
POWERLINE_ZSH=/usr/share/powerline/bindings/zsh/powerline.zsh
if [ -f ${POWERLINE_ZSH} ]; then
. ${POWERLINE_ZSH}
fi
fi
{% endif %}
# Local post scripts
if [[ -d $HOME/.config/zsh/post ]] && [[ "$(ls $HOME/.config/zsh/post)" ]] ; then
for script in $HOME/.config/zsh/post/*; do
. $script
done
fi
if [ -f ${HOME}/.zshrc.local ]; then
source ${HOME}/.zshrc.local
fi
# vim: et sw=2 ts=2

33
test_vars.yml Normal file
View File

@ -0,0 +1,33 @@
---
zsh_chic:
users:
- username: root
home: /root
group: root
antibody: true
- username: qui
home: /home/qui
group: qui
starship: true
- username: quo
home: /home/quo
group: quo
antibody: true
- username: qua
home: /home/qua
group: qua
- username: pk
home: /home/pk
group: pk
antibody: false
starship: false
- username: uno
home: /home/uno
group: uno
antibody: true
- username: due
home: /home/due
group: due
starship: true
antibody: false
starship: true