Ansible god!

Big rework!
Control stuffs with variables!
We still should do some movei'n around of roles before extending
features.
This commit is contained in:
2022-03-23 02:03:04 +01:00
parent 2c29be1b7b
commit a70d58f3f7
33 changed files with 447 additions and 104 deletions

View File

@@ -1 +1,2 @@
permit nopass siv as root
permit persist :adm
permit persist siv

View File

@@ -0,0 +1,104 @@
print_info() {
info title
info underline
info "OS" distro
info "Host" model
info "Kernel" kernel
info "Uptime" uptime
info "Packages" packages
info "Shell" shell
; info "Resolution" resolution
; info "DE" de
; info "WM" wm
; info "WM Theme" wm_theme
; info "Theme" theme
info "Icons" icons
info "Terminal" term
info "Terminal Font" term_font
info "CPU" cpu
info "GPU" gpu
info "Memory" memory
; info "GPU Driver" gpu_driver # Linux/macOS only
; info "CPU Usage" cpu_usage
info "Disk" disk
; info "Battery" battery
info "Font" font
; info "Song" song
; [[ "$player" ]] && prin "Music Player" "$player"
info "Local IP" local_ip
; info "Public IP" public_ip
; info "Users" users
; info "Locale" locale # This only works on glibc systems.
info cols
}
title_fqdn="off"
kernel_shorthand="off"
distro_shorthand="off"
os_arch="off"
uptime_shorthand="on"
memory_percent="on"
memory_unit="gib"
package_managers="on"
shell_path="on"
shell_version="on"
speed_type="bios_limit"
speed_shorthand="on"
cpu_brand="on"
cpu_speed="on"
cpu_cores="logical"
cpu_temp="C"
gpu_brand="on"
gpu_type="all"
refresh_rate="on"
gtk_shorthand="off"
gtk2="on"
gtk3="on"
public_ip_host="https://myip.wtf/text"
public_ip_timeout=2
de_version="on"
disk_show=('/')
disk_subtitle="mount"
disk_percent="on"
music_player="auto"
song_format="%artist% - %album% - %title%"
song_shorthand="off"
mpc_args=()
colors=(distro)
bold="on"
underline_enabled="on"
underline_char="-"
separator=":"
block_range=(0 15)
color_blocks="on"
block_width=2
block_height=1
col_offset="auto"
bar_char_elapsed="="
bar_char_total="-"
bar_border="on"
bar_length=15
bar_color_elapsed="distro"
bar_color_total="distro"
cpu_display="infobar"
memory_display="infobar"
battery_display="infobar"
disk_display="infobar"
image_backend="ascii"
image_source="ascii"
ascii_distro="auto"
ascii_colors=(distro)
ascii_bold="on"
image_loop="off"
thumbnail_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/thumbnails/neofetch"
crop_mode="normal"
crop_offset="center"
image_size="auto"
gap=3
yoffset=1
xoffset=1
background_color=
stdout="off"

View File

@@ -1,36 +1,67 @@
- name: Install and configure packages
- name: Install packages
when: update
block:
- name: Install the good stuff (pacman)
pacman: name={{ packages }} state=latest
- name: Install packages (pacman)
when: "'pacman' in group_names"
tags: pacman
- name: Install the good stuff (apk)
apk: name={{ packages }} state=latest
block:
- name: Install the good stuff (pacman)
pacman: name={{ item }} state=latest
ignore_errors: yes
with_items:
- "{{ extra_packages }}"
- "{{ packages }}"
rescue:
- name: Uninstall the good stuff (pacman)
pacman: name={{ item }} state=absent
with_items:
- "{{ extra_packages }}"
- "{{ packages }}"
- name: Install packages (apk)
when: "'apk' in group_names or 'alpine' in group_names"
tags: apk
- name: Install the good stuff (apt)
apt: package={{ packages }} state=latest
block:
- name: Install the good stuff (apk)
apk: name={{ item }} state=latest
ignore_errors: yes
with_items:
- "{{ extra_packages }}"
- "{{ packages }}"
rescue:
- name: Uninstall the good stuff (apk)
apk: name={{ item }} state=absent
with_items:
- "{{ extra_packages }}"
- "{{ packages }}"
- name: Install packages (apt)
when: "'apt' in group_names"
tags: apt
block:
- name: Install the good stuff (apt)
apt: package={{ item }} state=latest
ignore_errors: yes
with_items:
- "{{ extra_packages }}"
- "{{ packages }}"
rescue:
- name: Uninstall the good stuff (apt)
apt: package={{ item }} state=absent
with_items:
- "{{ extra_packages }}"
- "{{ packages }}"
- name: Configure system packages
when: "'system' in setup"
block:
- 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
- name: Configure user configs
when: "'user' in setup"
block:
- name: Add ~/.config/neofetch/
copy: src=neofetch dest=/home/{{ name }}/.config/neofetch owner={{ name }} group={{ name }} mode=0755
tags: config

15
roles/shell/files/aliases.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
which lsd>/dev/null
if [ "$?" = "0" ]; then
alias ls="lsd -h --color=auto --group-dirs first"
else
alias ls="ls -h --color=auto --group-directories-first"
fi
# ([ "$?" = "0" ] && \
# alias ls="lsd -h --color=auto --group-dirs first") || \
# alias ls="ls -h --color=auto --group-directories-first"
alias\
ll="ls -l"\
la="ls -a"\
diff="diff --color=auto"\
grep="grep --color=auto -n"

View File

@@ -0,0 +1,26 @@
- name: Add .aliases
copy: src=aliases.sh dest=/home/{{ name }}/.aliases owner={{ name }} group={{ group }} mode=0644
- name: Add .bat.conf
copy: src=bat.conf dest=/home/{{ name }}/.bat.conf owner={{ name }} group={{ group }} mode=0644
when: "'bat' in packages or 'bat' in extra_packages"
- name: Install zsh syntax highlighting (~/.zshrc.d folder)
when: not zsh_opt_config
git:
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
dest: /home/{{ name }}/.zshrc.d/zsh-syntax-highlighting
single_branch: yes
version: master
- name: Install zsh syntax highlighting (/opt/zsh folder)
when: zsh_opt_config
git:
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
dest: /opt/zsh/zsh-syntax-highlighting
single_branch: yes
version: master
become: true
- name: Add ~/.zshrc.d -> /opt/zsh symbolic link
when: zsh_opt_config
file: state=link dest=/home/{{ name }}/.zshrc.d src=/opt/zsh owner={{ name }} group={{ group }} mode=0755
- name: Set owner ship of zsh syntax highlighting files
file: state=directory recurse=yes dest=/home/{{ name }}/.zshrc.d owner={{ name }} group={{ group }}

View File

@@ -0,0 +1,30 @@
- name: Setup user zsh config
when: "'zsh' in setup"
tags: [user,zsh]
block:
- name: Add .zshrc
template: src=zshrc.zsh.j2 dest=/home/{{ name }}/.zshrc owner={{ name }} group={{ group }} mode=0644
- name: Add zsh zstyles config
copy: src=zstyles.zsh dest=/home/{{ name }}/.zstyles owner={{ name }} group={{ group }} mode=0644
- name: Setup user bash config
when: "'bash' in setup"
tags: [user,bash]
block:
- name: Add .bashrc
template: src=bashrc.sh.j2 dest=/home/{{ name }}/.bashrc owner={{ name }} group={{ group }} mode=0644
- name: Setup user extra config
when: "'extra' in setup"
tags: [user,extra]
block:
- import_tasks: extra.yml
- name: Add .env file
when: not revert
copy: src=env.sh dest=/home/{{ name }}/.env owner={{ name }} group={{ group }} mode=0644
- name: Revert ansible shell setup
when: revert
block:
- import_tasks: revert.yml

View File

@@ -0,0 +1,27 @@
- name: Remove user zsh config
tags: [zsh]
block:
- name: Remove .zshrc
file: state=absent path=/home/{{ name }}/.zshrc
- name: Remove zsh zstyles config
file: state=absent path=/home/{{ name }}/.zstyles
- name: Remove .zshrc.d folder/link
file: state=absent path=/home/{{ name }}/.zshrc.d
- name: Remove zsh syntax highlighting
file: state=absent path=/home/{{ name }}/.zshrc.d/zsh-syntax-highlighting
when: not zsh_opt_config
- name: Remove zsh syntax highlighting (/opt/zsh)
file: state=absent path=/opt/zsh/zsh-syntax-highlighting
when: zsh_opt_config
- name: Remove extra user config
when: "'extra' in setup"
tags: [extra]
block:
- name: Remove .aliases
file: state=absent path=/home/{{ name }}/.aliases
- name: Remove .bat.conf
file: state=absent path=/home/{{ name }}/.bat.conf
- name: Remove .env file
file: state=absent path=/home/{{ name }}/.env

View File

@@ -0,0 +1,25 @@
case $- in
*i*) ;;
*) return;;
esac
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
shopt -s histappend checkwinsize globstar
HISTFILESIZE=42069
HISTSIZE=42069
#PS1='${debian_chroot:+($debian_chroot)}{{ bash_prompt }} '
PS1='{{ bash_prompt }} '
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
[ -f ~/.aliases ] && . ~/.aliases
[ -f ~/.env ] && . ~/.env
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi

View File

@@ -1,6 +1,6 @@
[[ $- != *i* ]] && return
PROMPT="%F{yellow}% %n%F{green}% @%F{blue}% %m %F{#bb33bb}% %1~%f > "
PROMPT="{{ zsh_prompt }} "
setopt autocd extendedglob nomatch notify prompt_subst
autoload -Uz compinit && compinit
unsetopt beep

View File

@@ -1,30 +1,42 @@
# - name: Install yay (AUR helper)
# - name: Update and upgrade pacman packages
# become: yes
# pacman:
# executable: yay
# update_cache: yes
# upgrade: yes
# when: 'pacman'
# tags: pacman
- name: Update and upgrade pacman packages
pacman:
update_cache: yes
upgrade: yes
when: "'pacman' in group_names"
tags: pacman
become: yes
shell: pacman -Syu --noconfirm
when: package_manager == 'pacman' or 'pacman' in group_names
tags: update
- name: Add some repos (alpine)
become: yes
shell: |
grep -R 'testing' /etc/apk/repositories
[ $? == 1 ] && echo 'https://dl-cdn.alpinelinux.org/alpine/edge/testing'>>/etc/apk/repositories
if [ $? == 1 ]; then
echo 'https://dl-cdn.alpinelinux.org/alpine/edge/testing'>>/etc/apk/repositories
fi
when: "'alpine' in group_names"
tags: alpine
tags: update alpine
- name: Update and upgrade apk packages
become: true
become: yes
apk:
update_cache: yes
upgrade: yes
when: "'apk' in group_names or 'alpine' in group_names"
tags: apk
when: package_manager == 'apk' or 'apk' in group_names
tags: update
- name: Update and upgrade apt packages
become: true
become: yes
apt:
update_cache: yes
upgrade: yes
when: "'apt' in group_names"
tags: apt
when: package_manager == 'apt' or 'apt' in group_names
tags: update

View File

@@ -0,0 +1,21 @@
- name: Setup doom emacs
when: "'emacs' in setup"
tags: [doom,emacs]
block:
- name: Remove old emacs config
file: state=absent path=/home/{{ name }}/.emacs.d
- name: Git clone doom emacs
git:
repo: https://github.com/hlissner/doom-emacs
dest: /home/{{ name }}/.emacs.d
accept_newhostkey: yes
single_branch: yes
version: master
depth: 1
- name: Install doom emacs
shell: |
chown -R {{ name }} /home/{{ name }}/.emacs.d
echo "y\ny"|su {{ name }} /home/{{ name }}/.emacs.d/bin/doom install
#* ^ Above we answer terminal prompts
# - name: Add doom emacs config
# - name: Run doom sync

View File

@@ -1,4 +1,5 @@
- name: Create user
when: "'system' in setup"
user:
name="{{ name }}"
groups="{{ item }}"
@@ -12,4 +13,5 @@
user="{{ name }}"
key="{{ item }}"
with_items:
- "{{ pubkeys }}"
- "{{ pubkeys }}"
- import_tasks: doom-emacs.yml

View File

@@ -1,7 +0,0 @@
#!/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"

View File

@@ -1,33 +0,0 @@
- 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