initial commit

This commit is contained in:
Patrick Neff 2022-01-23 02:20:50 +01:00
commit 32b9d7373f
34 changed files with 789 additions and 0 deletions

1
defaults/main.yml Normal file
View File

@ -0,0 +1 @@
users: []

View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# File listing
alias ls='ls -F'
alias ll='ls -l'
alias la='ls -al'
# Colors
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias diff='colordiff'
# Convinience
alias mkdir='mkdir -p'
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
alias ln='ln -i'
# Editor
alias vi='vim'
# Python
alias venv="source .venv/bin/activate"
alias serve='python -m http.server'
# Network
alias ports='ss -tulpn'
# Shortcuts
alias mpy='python manage.py'

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
[[ -f ${HOME}/.bashrc ]] && . ${HOME}/.bashrc

70
files/odie/bash/bashrc Normal file
View File

@ -0,0 +1,70 @@
#!/usr/bin/env bash
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Normal Colors
#Black="\[$(tput setaf 0)\]" # Black
Red="\[$(tput setaf 1)\]" # Red
Green="\[$(tput setaf 2)\]" # Green
Yellow="\[$(tput setaf 3)\]" # Yellow
#Blue="\[$(tput setaf 4)\]" # Blue
#Purple="\[$(tput setaf 5)\]" # Purple
Cyan="\[$(tput setaf 6)\]" # Cyan
#White="\[$(tput setaf 7)\]" # White
# Bold
#Bold="\[$(tput bold)\]" # Black
#Bold="\[$(tput dim)\]" # Dim
#Bold="\[$(tput smso)\]" # Standout
#Bold="\[$(tput invis)\]" # Invisible
Reset="\[$(tput sgr0)\]" # Invisible
# Background
#On_Black="\[$(tput setab 0)\]" # Black
#On_Red="\[$(tput setab 1)\]" # Red
#On_Green="\[$(tput setab 2)\]" # Green
#On_Yellow="\[$(tput setab 3)\]" # Yellow
#On_Blue="\[$(tput setab 4)\]" # Blue
#On_Purple="\[$(tput setab 5)\]" # Purple
#On_Cyan="\[$(tput setab 6)\]" # Cyan
#On_White="\[$(tput setab 7)\]" # White
NC=$Reset # Color Reset
function prompt_username {
# Test user type:
if [[ "${USER}" == "root" ]]; then
SU=${Red} # User is root.
elif [[ "$((UID))" == "0" ]]; then
SU=${Red} # User is root.
elif [[ "${USER}" != "$(whoami)" ]]; then
SU=${Red} # User is not login user.
else
SU=${Green} # User is normal (well ... most of us are).
fi
echo -n "${SU}\u${NC}"
}
function prompt_hostname {
echo -n "${Cyan}\h${NC}"
}
function prompt_directory {
echo -n "${Yellow}\W${NC}"
}
function prompt_end {
retval=$Green
[[ $? -eq 0 ]] || retval=$Red
symbol="▸"
end="${retval}${symbol}${NC}"
echo -n "${end}"
}
# PS1='[\u@\h \W]\$ '
PS1="$(prompt_username)@$(prompt_hostname) $(prompt_directory) $(prompt_end) "
[ -f /usr/share/fzf/key-bindings.bash ] && source /usr/share/fzf/key-bindings.bash
[ -f /usr/share/fzf/completion.bash ] && source /usr/share/fzf/completion.bash

1
files/odie/nano/nanorc Normal file
View File

@ -0,0 +1 @@
include "/usr/share/nano/*.nanorc"

95
files/odie/tmux/tmux.conf Normal file
View File

@ -0,0 +1,95 @@
# Unicode
#setw -g utf8 on
#set -g status-utf8 on
# prefix like screen
unbind C-b
set -g prefix ^A
bind a send-prefix
# Quick pane cycling
unbind ^A
bind ^A last-window
unbind 'Space'
bind 'Space' next-window
# Start counting at 1
set -g base-index 1
set-window-option -g pane-base-index 1
# Act like Vim
set-window-option -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
bind-key -r '+' resize-pane -U 5
bind-key -r '-' resize-pane -D 5
bind-key -r '<' resize-pane -L 10
bind-key -r '>' resize-pane -R 10
# Look good
#set -g default-terminal "screen-256color"
set-option -g mouse on
# Increase History limit
set -g history-limit 10000
# Allows faster key repetition
set -s escape-time 0
bind-key b set-option status
##CLIPBOARD selection integration
##Requires prefix key before the command key
#Copy tmux paste buffer to CLIPBOARD
bind C-c run "tmux show-buffer | xsel -i -b"
#Copy CLIPBOARD to tmux paste buffer and paste tmux paste buffer
bind C-v run "tmux set-buffer -- \"$(xsel -o -b)\"; tmux paste-buffer"
# Status line
set -g status-justify "left"
set -g status "on"
set -g status-left-length "100"
set -g status-bg "#465457"
set -g status-right-length "100"
setw -g window-status-separator ""
set -g status-left "#[fg=#080808,bg=#e6db74] #S #[fg=#e6db74,bg=#465457,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=#232526,bg=#465457,nobold,nounderscore,noitalics]#[fg=#f8f8f0,bg=#232526] %d.%m.%Y  %H:%M #[fg=#e6db74,bg=#232526,nobold,nounderscore,noitalics]#[fg=#080808,bg=#e6db74] #h "
setw -g window-status-format "#[fg=#f8f8f0,bg=#465457] #I #[fg=#f8f8f0,bg=#465457] #W "
setw -g window-status-current-format "#[fg=#465457,bg=#232526,nobold,nounderscore,noitalics]#[fg=#f8f8f0,bg=#232526] #I #[fg=#f8f8f0,bg=#232526] #W #[fg=#232526,bg=#465457,nobold,nounderscore,noitalics]"
set -g set-titles on
set -g set-titles-string "tmux - #S"
set-option -sa terminal-overrides ',xterm-256color:RGB'
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }
bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'
# List of plugins
# Supports `github_username/repo` or full git repo URLs
set -g @tpm_plugins ' \
tmux-plugins/tpm \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-yank \
nhdaly/tmux-better-mouse-mode \
'
# Other examples:
# github_username/plugin_name \
# git@github.com/user/plugin \
# git@bitbucket.com/user/plugin \
# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'

View File

@ -0,0 +1 @@
setlocal shiftwidth=2

View File

@ -0,0 +1,10 @@
"""
" Easyer Help mode navigation
"""
nnoremap <buffer> <CR> <C-]>
nnoremap <buffer> <BS> <C-T>
nnoremap <buffer> o /'\l\{2,\}'<CR>
nnoremap <buffer> O ?'\l\{2,\}'<CR>
nnoremap <buffer> s /\|\zs\S\+\ze\|<CR>
nnoremap <buffer> S ?\|\zs\S\+\ze\|<CR>

View File

@ -0,0 +1,7 @@
setlocal shiftwidth=2
let b:delimitMate_matchpairs = '(:),[:],{:}'
unlet! b:did_ftplugin
source $HOME/.vim/bundle/xmledit/ftplugin/html.vim
source $HOME/.vim/bundle/xmledit/ftplugin/xml.vim

View File

@ -0,0 +1 @@
setlocal shiftwidth=2

View File

@ -0,0 +1,4 @@
setlocal shiftwidth=2
let b:surround_45 = "{{ \r }}"
let b:surround_95 = "{% \r %}"

View File

@ -0,0 +1 @@
setlocal textwidth=79

View File

@ -0,0 +1,16 @@
" Necessary for multiple encodings
setlocal encoding=utf-8
" Common code for encodings
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction
" .NFO specific
autocmd vimrc BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single
autocmd vimrc BufReadPost *.nfo call RestoreFileEncodings()

View File

@ -0,0 +1 @@
setlocal shiftwidth=2

View File

@ -0,0 +1,11 @@
setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal textwidth=79
setlocal expandtab
setlocal nosmarttab
let b:surround_45 = "_(\r)"
let b:delimitMate_nesting_quotes = ['"', "'"]
let b:delimitMate_expand_cr = 1
let b:delimitMate_expand_inside_quotes = 1

View File

@ -0,0 +1 @@
setlocal textwidth=79

View File

@ -0,0 +1,2 @@
setlocal textwidth=79
setlocal shiftwidth=2

View File

@ -0,0 +1 @@
setlocal shiftwidth=2

View File

@ -0,0 +1,5 @@
setlocal shiftwidth=2
unlet! b:did_ftplugin
source $HOME/.vim/bundle/xmledit/ftplugin/html.vim
source $HOME/.vim/bundle/xmledit/ftplugin/xml.vim

View File

@ -0,0 +1 @@
setlocal shiftwidth=2

View File

@ -0,0 +1,44 @@
" Delete Trailing Whitespace
function! myfuncs#DeleteTrailingWhitespace() abort
if ! &bin
silent! %s/\s\+$//ge
endif
endfunction
" Recursively search up from dirname, sourcing all .vimrc.local files along the way
function! myfuncs#ApplyLocalSettings(dirname) abort
" convert windows paths to unix style
let l:curDir = substitute(a:dirname, '\\', '/', 'g')
" walk to the top of the dir tree
let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, '/'))
if isdirectory(l:parentDir)
call ApplyLocalSettings(l:parentDir)
endif
" now walk back down the path and source .vimsettings as you find them.
" child directories can inherit from their parents
let l:settingsFile = a:dirname . '/.vimrc.local'
if filereadable(l:settingsFile)
exec ':runtime' . l:settingsFile
endif
endfunction
" Toggle relative number
function! myfuncs#NumberToggle()
if(&relativenumber == 1)
set norelativenumber
else
set relativenumber
endif
endfunction
"Restore Last Cursor Position
function! myfuncs#RestoreCursor()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction

306
files/odie/vim/vimrc Normal file
View File

@ -0,0 +1,306 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" VIM Config - by odie
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
""""""""""""
"" FUNCTIONS
""""""""""""
function! Cond(cond, ...)
let opts = get(a:000, 0, {})
return a:cond ? opts : extend(opts, { 'on': [], 'for': [] })
endfunction
let g:my_vimdir = expand('$HOME/.vim')
let g:my_vimrc = expand('$HOME/.vim/init.vim')
let g:my_plugdir = g:my_vimdir . '/bundle'
let g:my_plug = g:my_vimdir . '/autoload/plug.vim'
""""""""""
"" PLUGINS
""""""""""
" Install Vim Plug if not installed
if empty(glob(g:my_plug))
execute 'silent !curl -fLo ' . g:my_plug . ' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall
endif
call plug#begin(g:my_plugdir)
" Colorschemes
Plug 'patstockwell/vim-monokai-tasty'
" Plugins
Plug 'Raimondi/delimitMate', { 'for': ['vue','python','javascript','typescript','html']}
Plug 'tpope/vim-surround', { 'for': ['vue','python','javascript','typescript','html']}
Plug 'tpope/vim-repeat', { 'for': ['vue','python','javascript','typescript','html']}
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'Bookmark']} | Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'scrooloose/nerdcommenter', { 'for': ['vue','python','javascript','typescript','html']}
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!', 'WhichKeyVisual', 'WhichKeyVisual!'] }
Plug 'editorconfig/editorconfig-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end() " required
"""""""""""""""
"" VIM SETTINGS
"""""""""""""""
syntax on
filetype plugin indent on
scriptencoding utf-8
"Move over end of line
set whichwrap=b,s,<,>,[,],h,l
" Backspace over autoindent, line breaks, start of insert (see :help 'backspace')
set backspace=indent,eol,start
"Auto indentation
set autoindent
"Tabs
set tabstop=8
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
" Paste mode toggle key
set pastetoggle=<F11>
" Set Leader Key
let g:mapleader = "\<space>"
let g:maplocalleader = ","
"" Mouse Settings
if has('mouse')
set mouse=a
set selectmode=mouse
endif
"" Search Settings
"Better Tab Completion
set wildmenu
set wildmode=list:longest
set hlsearch
set ignorecase
set smartcase
set incsearch
"" Misc Settings
" Status Line
set laststatus=2
"Bigger History
set history=1000
" keep at least 5 lines above/below
set scrolloff=5
set sidescrolloff=5
"1000 Undos
set undolevels=1000
"Dont move to startofline
set nostartofline
"Activate hidden buffers
set hidden
"Automatically read buffer when changed outside of vim
set autoread
"Place backup and temp directory somewhere else
set backup
"Use "./" in the 'tags' options reads tags file relative to current directory
set cpoptions+=d
" Backup, tag and undo locations
execute 'set tags=./.tags,' . g:my_vimdir . '/tags,tags'
execute 'set backupdir=' . g:my_vimdir . '/backup'
execute 'set directory=' . g:my_vimdir . '/tmp'
execute 'set undodir=' . g:my_vimdir . '/undo'
" Line numbers
set number
" Make bell visual and disable error bells
set visualbell
set noerrorbells
" Show (partial) command in status line
set showcmd
" Colorize column 80
set colorcolumn=80
"
" Enable persistent undo
if has("persistent_undo")
set undofile
endif
set ttyfast
" Colorscheme
"set t_Co=256
let g:vim_monokai_tasty_italic = 1
silent! colorscheme vim-monokai-tasty
""""""""""""""""""
"" PLUGIN SETTINGS
""""""""""""""""""
" Disable netrw
let loaded_netrwPlugin = 1
" delimitMate
let delimitMate_balance_matchpairs = 1
" nerdtree
let NERDTreeIgnore = ['\.pyc$', '__pycache__$[[dir]]', '\~$', '\.git$']
" vim-airline
let g:airline_powerline_fonts = 1
let g:airline_theme = "molokai"
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline#extensions#hunks#enabled = 0
let g:airline#extensions#hunks#non_zero_only = 1
let g:airline#extensions#virtualenv#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#lsp#enabled = 0
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#trailing_format = '●[%s]'
let g:airline#extensions#whitespace#mixed_indent_format = '○[%s]'
let g:which_key_use_floating_win = 1
let g:which_key_floating_opts = { 'row': '-10', 'width': '-30', 'height': '+5', 'col': '+15' }
let g:which_key_disable_default_offset = 1
let g:which_key_vertical = 1
let g:which_key_map = {}
""""""""""""""
"" KEYBINDINGS
""""""""""""""
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>WhichKeyVisual '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
vnoremap <silent> <localleader> :<c-u>WhichKeyVisual ','<CR>
nnoremap <leader><leader> :Files<CR>
nnoremap <leader>ff :Files<CR>
nnoremap <leader>fs :write<CR>
let g:which_key_map['<space>'] = 'fzf-files'
let g:which_key_map.f = {
\ 'name' : '+file' ,
\ 'f': ['Files' , 'fzf-files'] ,
\ 's': ['write' , 'save-file'] ,
\ }
" Buffers
nnoremap <leader>, :Buffers<CR>
nnoremap <leader>bb :Buffers<CR>
nnoremap <leader>bd :bd<CR>
nnoremap <leader>bf :bfirst<CR>
nnoremap <leader>bl :blast<CR>
nnoremap <leader>bp :bprevious<CR>
nnoremap <leader>bn :bnext<CR>
let g:which_key_map[','] = 'fzf-buffers'
let g:which_key_map.b = {
\ 'name': '+buffer' ,
\ 'd': ['bd' , 'delete-buffer'] ,
\ 'f': ['bfirst' , 'first-buffer'] ,
\ 'h': ['Startify' , 'home-buffer'] ,
\ 'l': ['blast' , 'last-buffer'] ,
\ 'n': ['bnext' , 'next-buffer'] ,
\ 'p': ['bprevious' , 'previous-buffer'] ,
\ 'b': ['Buffers' , 'fzf-buffer'] ,
\ }
nnoremap <leader>of :NERDTreeToggle<CR>
nnoremap <leader>oh :Startify<CR>
let g:which_key_map.o = {
\ 'name': '+open' ,
\ 'f': ['NERDTreeToggle', 'nerdtree-toggle'] ,
\ 'h': ['Startify' , 'save-file'] ,
\ }
nnoremap <leader>gs :Git<CR>
nnoremap <leader>gc :Git<space>commit<CR>
nnoremap <leader>gl :Git<space>log<CR>
let g:which_key_map.g = {
\ 'name' : '+git' ,
\ 's': ['Git', 'git-status'] ,
\ 'c': ['Git commit', 'git-commit'] ,
\ 'l': ['Git log', 'git-log'] ,
\ }
nnoremap <leader>qq :q<CR>
nnoremap <leader>qQ :q!<CR>
let g:which_key_map.q = {
\ 'name': '+quit' ,
\ 'q': ['quit', 'quit'] ,
\ 'Q': ['quit!', 'force-quit'] ,
\ }
nnoremap <leader>hhp :PlugUpdate<CR>
nnoremap <leader>hhP :PlugUpgrade<CR>
nnoremap <leader>hhc :PlugClean<CR>
nnoremap <leader>hhs :PlugStatus<CR>
let g:which_key_map.h = {
\ 'name': '+help' ,
\ }
let g:which_key_map.h.p = {
\ 'name': '+plugin' ,
\ 'u': ['PlugUpdate', 'plug-update'] ,
\ 'U': ['PlugUpgrade', 'plug-upgrade'] ,
\ 'c': ['PlugClean', 'plug-clean'] ,
\ 's': ['PlugStatus', 'plug-status'] ,
\ }
nnoremap <leader>ww :Windows<CR>
nnoremap <leader>wc <C-W>c
nnoremap <leader>ws <C-W>s
nnoremap <leader>wh <C-W>h
nnoremap <leader>wj <C-W>j
nnoremap <leader>wk <C-W>k
nnoremap <leader>wl <C-W>l
nnoremap <leader>wd <C-W>c
let g:which_key_map.w = {
\ 'name': '+window' ,
\ 'w': ['<C-W>w' , 'fzf-windows'] ,
\ 'd': ['<C-W>c' , 'delete-window'] ,
\ 'h': ['<C-W>h' , 'window-left'] ,
\ 'j': ['<C-W>j' , 'window-below'] ,
\ 'l': ['<C-W>l' , 'window-right'] ,
\ 'k': ['<C-W>k' , 'window-up'] ,
\ 's': ['<C-W>s' , 'split-window-below'] ,
\ 'v': ['<C-W>v' , 'split-window-below'] ,
\ }
nnoremap <leader>pf :NERDTreeToggle<CR>
nnoremap <leader>pB :Bookmark<CR>
let g:which_key_map.p = {
\ 'name': '+project' ,
\ 'f': ['NERDTreeToggle', 'nerdtree-toggle'] ,
\ 'B': ['Bookmark', 'nerdtree-bookmark'] ,
\ }
autocmd! User vim-which-key call which_key#register('<Space>', 'g:which_key_map')
""""""""""""""""""""
"" AUTOCOMMAND GROUP
""""""""""""""""""""
if has('autocmd')
augroup vimrc
autocmd!
"autocmd BufWinEnter * :AirlineRefresh
autocmd BufWinEnter * call myfuncs#RestoreCursor()
autocmd BufWritePost * :call myfuncs#DeleteTrailingWhitespace()
execute 'autocmd BufWritePost .vimrc :source' . g:my_vimrc
execute 'autocmd BufWritePost vimrc :source' . g:my_vimrc
execute 'autocmd BufWritePost init.vim :source' . g:my_vimrc
augroup END
endif
call myfuncs#ApplyLocalSettings('.')

16
files/odie/zsh/zshenv Normal file
View File

@ -0,0 +1,16 @@
export ENV_NAME=".venv"
export EDITOR="vim"
export SUDO_EDITOR=$EDITOR
export GIT_EDITOR=$EDITOR
export VISUAL=$EDITOR
export BROWSER="firefox"
[ -f ~/.bash_aliases ] && source ~/.bash_aliases
[ -f ~/.bash_aliases.local ] && source ~/.bash_aliases.local
export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
# pipenv
export PIPENV_VENV_IN_PROJECT=1
[ -f ~/.zshenv.local ] && source ~/.zshenv.local

27
files/odie/zsh/zshrc Normal file
View File

@ -0,0 +1,27 @@
source ${HOME}/.zsh/antigen.zsh
antigen use oh-my-zsh
fpath=(${HOME}/.completion $fpath)
antigen bundle git
antigen bundle gitignore
antigen bundle vi-mode
antigen bundle tmux
antigen bundle pip
antigen bundle virtualenv
antigen bundle direnv
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-completions
antigen theme masterodie/zsh-theme-odie odie
if [ -f /usr/bin/fzf ]; then
export FZF_BASE=/usr/bin/fzf
antigen bundle fzf
fi
[ -f ~/.zshrc.local ] && source ~/.zshrc.local
antigen apply

View File

@ -0,0 +1,4 @@
[ "${XDG_VTNR}" -eq 8 ]
then
exec /usr/bin/emulationstation; exit
fi

9
tasks/groups.yml Normal file
View File

@ -0,0 +1,9 @@
- block:
- name: "Create group for user '{{ user.username }}'."
tags: users
ansible.builtin.group:
name: "{{ user.group | default(user.username) }}"
gid: "{{ user.gid | default(omit) }}"
state: present
when:
- user.state | default('present') == 'present'

18
tasks/main.yml Normal file
View File

@ -0,0 +1,18 @@
- name: Load OS specific variables.
tags: always,users
ansible.builtin.include_vars:
file: "os_{{ os_distribution }}.yml"
- include_tasks:
file: groups.yml
tags: users
with_items: "{{ users }}"
loop_control:
loop_var: user
- include_tasks:
file: users.yml
tags: users
with_items: "{{ users }}"
loop_control:
loop_var: user

89
tasks/users.yml Normal file
View File

@ -0,0 +1,89 @@
- block:
- name: "Create user '{{ user.username }}'."
tags: users
ansible.builtin.user:
name: "{{ user.username }}"
state: "{{ user.state | default('present') }}"
group: "{{ user.group | default(user.username) }}"
groups: "{{ user.groups | default(omit) | join(',') }}"
comment: "{{ user.comment | default(omit) }}"
shell: "{{ user.shell | default(omit) }}"
password: "{{ user.password | default(omit) }}"
system: "{{ user.system | default(omit) }}"
uid: "{{ user.uid | default(omit) }}"
gid: "{{ user.gid | default(omit) }}"
update_password: on_create
- name: "Create sudoers file for user '{{ user.username }}'."
tags: users,sudo
ansible.builtin.template:
src: "sudoers"
dest: "/etc/sudoers.d/{{ user.username }}"
owner: root
group: root
mode: 0440
when:
- user.sudo | default(false)
- name: "Create config directories for user '{{ user.username }}'."
tags: users
ansible.builtin.file:
path: "{{ user.home_dir | default('/home/' + user.username) }}/{{ item }}"
state: directory
owner: "{{ user.username }}"
group: "{{ user.username }}"
mode: 0700
with_items: "{{ user.config_dirs | default([]) }}"
- name: "Copy config files for user '{{ user.username }}'."
tags: users
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{user.home_dir | default('/home/' + user.username) }}/{{ item.dest }}"
owner: "{{ user.username }}"
group: "{{ user.username }}"
mode: 0600
with_items: "{{ user.config_files | default([]) }}"
register: dotfiles_installed
- name: "Create config files from templates for user '{{ user.username }}'."
tags: users
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{user.home_dir | default('/home/' + user.username) }}/{{ item.dest }}"
owner: "{{ user.username }}"
group: "{{ user.username }}"
mode: 0600
with_items: "{{ user.config_templates | default([]) }}"
register: dotfiles_installed
- name: "Add ssh public keys for user '{{ user.username }}'."
tags: users
ansible.builtin.authorized_key:
user: "{{ user.username }}"
key: "{{ item }}"
with_items: "{{ user.ssh_keys | default([]) }}"
- name: "Install antigen for '{{ user.username }}'."
tags: users
become: true
become_user: "{{ user.username }}"
ansible.builtin.get_url:
url: https://git.io/antigen
dest: "{{ user.home_dir | default('/home/' + user.username) }}/.zsh/antigen.zsh"
mode: 0600
when:
- user.shell is defined
- "'/zsh' in user.shell"
- name: "Install tpm for user '{{ user.username }}'."
tags: users
become: true
become_user: "{{ user.username }}"
ansible.builtin.git:
repo: "https://github.com/tmux-plugins/tpm"
dest: "{{ user.home_dir | default('/home/' + user.username) }}/.tmux/plugins/tpm"
version: v3.0.0
when:
- user.state | default('present') == 'present'

View File

@ -0,0 +1,2 @@
[User]
Icon=/usr/share/pixmaps/faces/{{ user.username }}

3
templates/dmrc Normal file
View File

@ -0,0 +1,3 @@
[Desktop]
Session={{ user.destkop_session | default('gnome') }}
Language={{ common_locale }}

5
templates/sudoers Normal file
View File

@ -0,0 +1,5 @@
{% if user.sudoers is defined %}
{{ user.sudoers }}
{% else %}
{{ user.username }} ALL=(ALL) {% if user.sudo == 'nopasswd' %}NOPASSWD:{% endif %}ALL
{% endif %}

1
vars/os_Arch.yml Normal file
View File

@ -0,0 +1 @@
group_sudo: wheel

1
vars/os_Debian.yml Normal file
View File

@ -0,0 +1 @@
group_sudo: sudo

1
vars/os_Raspbian.yml Normal file
View File

@ -0,0 +1 @@
group_sudo: sudo