diff --git a/CHANGELOG.md b/CHANGELOG.md index 266d27f..de3963b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,54 +1,18 @@ -# Changelog +## 2023-12-10 -## 2023-06-?? +### Version: 1.1.0 -### Version: 2.0 +#### Playbooks -#### DEPRECATED +What added: -- `templates:` and it vars moved from top, level into -`role_component..[config|run_config].template`, -and now look like this: - -```yaml - -role_component: - git: - configs: - templates: - gitconfig: - template: "gitconfig" - dest: "~/.gitconfig" - variables: - foo: bar -``` - -- `zip-configs` deleted - -#### Changed - -- component vars moved from playbook vars, into role defaults. -Now, you can find them in [./defaults/main](./defaults/main) -- refactored ansible messaged. Now they look like: -`[component][][]` -- reduced number of debug messages - -#### Added - -- install via Brew package manager: -`role_component..install.brew=[]` -- for macOS all -`role_component..install.packages=[]` -will be installed viw Brew -- conditional `become` -`role_component..install.become=[True|False]` -- molecule tests +- playbooks with example variables for components. You can find those under `playbooks/vars` and `playbooks/templates` --- -## 2022-03-05 +## 2023-12-10 -### Version: 1.0 +### Version: 1.0.0 #### Basics diff --git a/playbooks/components.yml b/playbooks/components.yml new file mode 100644 index 0000000..fd5e16c --- /dev/null +++ b/playbooks/components.yml @@ -0,0 +1,52 @@ +--- +- hosts: all + gather_facts: true + collections: + - dnullproject.collections + tasks: + - block: + - include_vars: + dir: vars + extensions: + - 'yml' + - 'yaml' + - ansible.builtin.include_role: + name: components + vars: + role_component: + components: + - alacritty + - asdf + - brew + - clipmenu + - direnv + - dmenu + - fonts + - git + - htop + - k9s + - lastpass_cli + - lvim + - minikube + - nvim + - ssh + - stew + - tmux + - versions + - zsh + tags: [files, install, configs, run_configs, run, plugins] + # Additionally post results into ntfy + # - uri: + # url: "https://ntfy.sh/change_me" + # method: POST + # body: "{{ inventory_hostname }} components: finished" + # tags: [files, install, configs, run_configs, run, plugins] + # rescue: + # - uri: + # url: "https://ntfy.sh/change_me" + # method: POST + # body: "{{ inventory_hostname }} components: failed" + # tags: [files, install, configs, run_configs, run, plugins] + # - fail: + # msg: "exit non-zero" + # tags: [files, install, configs, run_configs, run, plugins] diff --git a/playbooks/templates/alacritty.yml b/playbooks/templates/alacritty.yml new file mode 100644 index 0000000..01cc066 --- /dev/null +++ b/playbooks/templates/alacritty.yml @@ -0,0 +1,83 @@ +--- +env: + TERM: {{ var.term }} +window: + padding: + x: 0 + y: 0 + dynamic_padding: false + decorations: none + title: Alacritty + class: + instance: Alacritty + general: Alacritty +scrolling: + history: 5000 +font: + normal: + family: {{ var.font }} + style: Regular + bold: + family: {{ var.font }} + style: Bold + italic: + family: {{ var.font }} + style: Italic + bold_italic: + family: {{ var.font }} + style: Bold Italic + size: {{ var.font_size }} + offset: + x: 0 + y: 0 +draw_bold_text_with_bright_colors: true +# Colors (https://terminal.sexy/#JjI47O_xJjI4_5gAi8NK_8EHA6n06R5jAJaIz9jcN0dP_6dNnMxl_6AAgdT6rRRXJqaa7O_x) +# colors: +# # Default colors +# primary: +# background: '0x263238' +# foreground: '0xeceff1' +# +# # Normal colors +# normal: +# black: '0x263238' +# red: '0xff9800' +# green: '0x8bc34a' +# yellow: '0xffc107' +# blue: '0x03a9f4' +# magenta: '0xe91e63' +# cyan: '0x009688' +# white: '0xcfd8dc' +# +# # Bright colors +# bright: +# black: '0x37474f' +# red: '0xffa74d' +# green: '0x9ccc65' +# yellow: '0xffa000' +# blue: '0x81d4fa' +# magenta: '0xad1457' +# cyan: '0x26a69a' +# white: '0xeceff1' +live_config_reload: true +key_bindings: + # (Windows, Linux, and BSD only) + - {key: V, mods: Control|Shift, action: Paste} + - {key: C, mods: Control|Shift, action: Copy} + - {key: Insert, mods: Shift, action: PasteSelection} + - {key: Key0, mods: Control, action: ResetFontSize} + - {key: Equals, mods: Control, action: IncreaseFontSize} + - {key: Plus, mods: Control, action: IncreaseFontSize} + - {key: Minus, mods: Control, action: DecreaseFontSize} + - {key: Minus, mods: Control, action: DecreaseFontSize} + - {key: F11, mods: None, action: ToggleFullscreen} + - {key: Paste, mods: None, action: Paste} + - {key: Copy, mods: None, action: Copy} + - {key: L, mods: Control, action: ClearLogNotice} + - {key: L, mods: Control, chars: "\f"} + - {key: PageUp, mods: None, action: ScrollPageUp, mode: ~Alt} + - {key: PageDown, mods: None, action: ScrollPageDown, mode: ~Alt} + - {key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt} + - {key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt} +import: + - ~/.config/alacritty/themes/dracula/dracula.yml diff --git a/playbooks/templates/gitconfig b/playbooks/templates/gitconfig new file mode 100644 index 0000000..07319e6 --- /dev/null +++ b/playbooks/templates/gitconfig @@ -0,0 +1,7 @@ +[user] + email = {{ var.email }} + name = {{ var.name }} +[alias] +{% for alias in var.aliases %} + {{ alias }} +{% endfor %} diff --git a/playbooks/templates/htop b/playbooks/templates/htop new file mode 100644 index 0000000..5a123cf --- /dev/null +++ b/playbooks/templates/htop @@ -0,0 +1,26 @@ +# Beware! This file is rewritten by htop when settings are changed in the interface. +# The parser is also very primitive, and not human-friendly. +fields=46 47 1 +sort_key=46 +sort_direction=1 +hide_threads=0 +hide_kernel_threads=0 +hide_userland_threads=0 +shadow_other_users=0 +show_thread_names=0 +show_program_path=1 +highlight_base_name=0 +highlight_megabytes=0 +highlight_threads=1 +tree_view=0 +header_margin=0 +detailed_cpu_time=0 +cpu_count_from_zero=0 +update_process_names=0 +account_guest_in_cpu_meter=0 +# color_scheme=5 +delay=15 +left_meters=LeftCPUs Memory Swap +left_meter_modes=1 1 1 +right_meters=RightCPUs Tasks LoadAverage Uptime +right_meter_modes=1 2 2 2 diff --git a/playbooks/templates/k9s/config.yml b/playbooks/templates/k9s/config.yml new file mode 100644 index 0000000..faf28fe --- /dev/null +++ b/playbooks/templates/k9s/config.yml @@ -0,0 +1,22 @@ +--- +k9s: + refreshRate: 2 + maxConnRetry: 5 + enableMouse: true + headless: false + logoless: false + crumbsless: false + readOnly: false + noExitOnCtrlC: false + noIcons: false + logger: + tail: 200 + buffer: 500 + sinceSeconds: 300 + fullScreenLogs: false + textWrap: false + showTime: false + currentContext: + currentCluster: + clusters: {} + screenDumpDir: /tmp diff --git a/playbooks/templates/k9s/hotkey.yml b/playbooks/templates/k9s/hotkey.yml new file mode 100644 index 0000000..b6eb64c --- /dev/null +++ b/playbooks/templates/k9s/hotkey.yml @@ -0,0 +1,30 @@ +--- +hotKey: + shift-1: + shortCut: Shift-1 + description: View pods + command: pods + shift-2: + shortCut: Shift-2 + description: View Deployments + command: deployments + shift-3: + shortCut: Shift-3 + description: View Statefulset + command: statefulset + shift-4: + shortCut: Shift-4 + description: View Service + command: service + shift-5: + shortCut: Shift-5 + description: View Ingress + command: ingress + shift-9: + shortCut: Shift-9 + description: View Events + command: events + shift-0: + shortCut: Shift-0 + description: Viewing namespaces + command: namespace diff --git a/playbooks/templates/k9s/plugin.yml b/playbooks/templates/k9s/plugin.yml new file mode 100644 index 0000000..27a3b79 --- /dev/null +++ b/playbooks/templates/k9s/plugin.yml @@ -0,0 +1,17 @@ +--- +plugin: + stern: + shortCut: Ctrl-L + confirm: false + description: Logs + scopes: [pods] + command: stern + background: false + args: + - --tail + - 50 + - $FILTER + - -n + - $NAMESPACE + - --context + - $CONTEXT diff --git a/playbooks/templates/k9s/skin.yml b/playbooks/templates/k9s/skin.yml new file mode 100644 index 0000000..96024d3 --- /dev/null +++ b/playbooks/templates/k9s/skin.yml @@ -0,0 +1,116 @@ +--- +# ----------------------------------------------------------------------------- +# Dracula skin +# ----------------------------------------------------------------------------- + +# Styles... +foreground: &foreground "#f8f8f2" +background: &background "#282a36" +current_line: ¤t_line "#44475a" +selection: &selection "#44475a" +comment: &comment "#6272a4" +cyan: &cyan "#8be9fd" +green: &green "#50fa7b" +orange: &orange "#ffb86c" +pink: &pink "#ff79c6" +purple: &purple "#bd93f9" +red: &red "#ff5555" +yellow: &yellow "#f1fa8c" + +# Skin... +k9s: + # General K9s styles + body: + fgColor: *foreground + bgColor: *background + logoColor: *purple + # Command prompt styles + prompt: + fgColor: *foreground + bgColor: *background + suggestColor: *purple + # ClusterInfoView styles. + info: + fgColor: *pink + sectionColor: *foreground + # Dialog styles. + dialog: + fgColor: *foreground + bgColor: *background + buttonFgColor: *foreground + buttonBgColor: *purple + buttonFocusFgColor: *yellow + buttonFocusBgColor: *pink + labelFgColor: *orange + fieldFgColor: *foreground + frame: + # Borders styles. + border: + fgColor: *selection + focusColor: *current_line + menu: + fgColor: *foreground + keyColor: *pink + # Used for favorite namespaces + numKeyColor: *pink + # CrumbView attributes for history navigation. + crumbs: + fgColor: *foreground + bgColor: *current_line + activeColor: *current_line + # Resource status and update styles + status: + newColor: *cyan + modifyColor: *purple + addColor: *green + errorColor: *red + highlightColor: *orange + killColor: *comment + completedColor: *comment + # Border title styles. + title: + fgColor: *foreground + bgColor: *current_line + highlightColor: *orange + counterColor: *purple + filterColor: *pink + views: + # Charts skins... + charts: + bgColor: default + defaultDialColors: + - *purple + - *red + defaultChartColors: + - *purple + - *red + # TableView attributes. + table: + fgColor: *foreground + bgColor: *background + # Header row styles. + header: + fgColor: *foreground + bgColor: *background + sorterColor: *cyan + # Xray view attributes. + xray: + fgColor: *foreground + bgColor: *background + cursorColor: *current_line + graphicColor: *purple + showIcons: false + # YAML info styles. + yaml: + keyColor: *pink + colonColor: *purple + valueColor: *foreground + # Logs styles. + logs: + fgColor: *foreground + bgColor: *background + indicator: + fgColor: *foreground + bgColor: *purple + toggleOnColor: *green + toggleOffColor: *cyan diff --git a/playbooks/templates/lvim/config.lua b/playbooks/templates/lvim/config.lua new file mode 100644 index 0000000..c4e17dc --- /dev/null +++ b/playbooks/templates/lvim/config.lua @@ -0,0 +1,100 @@ +-- Read the docs: https://www.lunarvim.org/docs/configuration +-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6 +-- Forum: https://www.reddit.com/r/lunarvim/ +-- Discord: https://discord.com/invite/Xb9B4Ny +lvim.plugins = { + { + "sindrets/diffview.nvim", + event = "BufRead", + }, + { + "tpope/vim-fugitive", + cmd = { + "G", + "Git", + "Gdiffsplit", + "Gread", + "Gwrite", + "Ggrep", + "GMove", + "GDelete", + "GBrowse", + "GRemove", + "GRename", + "Glgrep", + "Gedit" + }, + ft = { "fugitive" } + }, + { + "tpope/vim-surround", + + -- make sure to change the value of `timeoutlen` if it's not triggering correctly, see https://github.com/tpope/vim-surround/issues/117 + -- setup = function() + -- vim.o.timeoutlen = 500 + -- end + }, + -- { + -- 'f-person/auto-dark-mode.nvim', + -- config = function () + -- require('auto-dark-mode').setup { + -- update_interval = 1000, + -- set_dark_mode = function() + -- lvim.api.nvim_set_option('background', 'dark') + -- lvim.cmd('colorscheme gruvbox') + -- end, + -- set_light_mode = function() + -- lvim.api.nvim_set_option('background', 'light') + -- lvim.cmd('colorscheme gruvbox') + -- end, + -- } + -- require('auto-dark-mode').init{} + -- end + -- } + { "f-person/auto-dark-mode.nvim" }, + { + "someone-stole-my-name/yaml-companion.nvim", + dependencies = { + { "neovim/nvim-lspconfig" }, + { "nvim-lua/plenary.nvim" }, + { "nvim-telescope/telescope.nvim" }, + }, + config = function() + require("telescope").load_extension("yaml_schema") + end + }, + { 'projekt0n/caret.nvim' }, + { 'christoomey/vim-tmux-navigator' }, + { 'Mofiqul/dracula.nvim' }, + { 'mg979/vim-visual-multi' } +} +lvim.colorscheme = "dracula" + +-- Change theme based on Mac settings +-- local auto_dark_mode = require('auto-dark-mode') +-- auto_dark_mode.setup({ +-- update_interval = 1000, +-- set_dark_mode = function() +-- vim.api.nvim_set_option('background', 'dark') +-- vim.cmd('colorscheme caret') +-- end, +-- set_light_mode = function() +-- vim.api.nvim_set_option('background', 'light') +-- vim.cmd('colorscheme caret') +-- end, +-- }) +-- auto_dark_mode.init() + +vim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messages +vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications +vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation +vim.opt.tabstop = 2 -- insert 2 spaces for a tab +vim.opt.relativenumber = true -- relative line numbers +vim.opt.wrap = true -- wrap lines + +-- use treesitter folding +vim.opt.foldmethod = "expr" +vim.opt.foldexpr = "nvim_treesitter#foldexpr()" +lvim.builtin.which_key.mappings["P"] = { + "lua require'telescope'.extensions.projects.projects{}", "Projects" +} diff --git a/playbooks/templates/ssh b/playbooks/templates/ssh new file mode 100644 index 0000000..7140594 --- /dev/null +++ b/playbooks/templates/ssh @@ -0,0 +1,25 @@ +{% if var.include is defined %} +{% for include_path in var.include %} +Include {{ include_path }} +{% endfor %} +{% endif %} + +{% if var.hosts is defined %} +{% for host in var.hosts %} +Host {{ host.name }} +{% if host.host is defined %} + HostName {{ host.host }} +{% endif %} +{% if host.user is defined %} + User {{ host.user }} +{% endif %} +{% if host.key is defined %} + IdentityFile {{ host.key }} +{% endif %} + IdentitiesOnly {{ host.identities_only | default("yes") }} + UpdateHostKeys {{ host.update_key | default("no") }} +{% if host.port is defined %} + Port {{ host.port }} +{% endif %} +{% endfor %} +{% endif %} diff --git a/playbooks/templates/tmux/tmux.conf b/playbooks/templates/tmux/tmux.conf new file mode 100644 index 0000000..9305cf9 --- /dev/null +++ b/playbooks/templates/tmux/tmux.conf @@ -0,0 +1,160 @@ +# TMUX main config file +# +# +unbind r +bind r source-file ~/.tmux.conf \; display "__>r370ad3D 1!!" + +# Continium +set -g @continuum-restore 'on' + +# Vim Autoread file +set -g focus-events on +set -g @resurrect-strategy-vim 'session' + +# map CAPS to CTRL, enable default prefix to CTRL+a +set -g mouse on +set -g prefix C-a + +# vi-like +set-window-option -g mode-keys vi + +# map CTRL+b enable/disable statusbar +unbind C-b +bind b set-option status + +# history limit +set -g history-limit 5000 + +# delay (required) +set -sg escape-time 1 + +# enable indexing from 1 +set -g base-index 1 +setw -g pane-base-index 1 + +# disable autorename +set-option -g allow-rename off +setw -g monitor-activity on +setw -g window-status-activity-fg colour30 + +# reload TMUX conf with CTRL+r + +# split windows by "|" and "-" +bind | split-window -h +bind - split-window -v + +# vi-like moves +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R +bind -r C-h select-window -t :- +bind -r C-l select-window -t :+ + +# vi-like pane resizing +bind -r H resize-pane -L 2 +bind -r J resize-pane -D 2 +bind -r K resize-pane -U 2 +bind -r L resize-pane -R 2 + +# vi-like copy +#bind -t vi-copy 'v' begin-selection +#bind -t vi-copy 'y' copy-selection + +# COLORS +set -g default-terminal "xterm-256color" +set -ga terminal-overrides ",*256col*:Tc" +# statusbar +set -g status-fg colour38 +set -g status-bg colour233 +# windows list +#setw -g window-status-fg colour38 +#setw -g window-status-bg colour233 +#setw -g window-status-attr default +# active window +#setw -g window-status-current-fg colour233 +#setw -g window-status-current-bg colour38 +#setw -g window-status-current-attr bright +# windows selector +#set pane-border-fg colour243 +#set pane-border-bg colour234 +#set pane-active-border-fg colour197 +#set pane-active-border-bg colour234 +# messages +set -g message-fg colour37 +set -g message-bg colour233 +set -g status-interval 1 +set -g status-justify centre +# clock +set-window-option -g clock-mode-colour colour37 + +bind S set-window-option synchronize-panes + +# update time +# set -g status-interval 5 +# left +# right +# set -g status-right "#[fg=colour36]#(cat /proc/loadavg | cut -d' ' -f3)#{?pane_synchronized,#[fg=colour233]#[bg=colour37] SYNC <<,}" + + +# VIM COPY +set -g mouse on +bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'" +bind -n WheelDownPane select-pane -t= \; send-keys -M +bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M +bind -T copy-mode-vi C-WheelUpPane send-keys -X halfpage-up +bind -T copy-mode-vi C-WheelDownPane send-keys -X halfpage-down +bind -T copy-mode-emacs C-WheelUpPane send-keys -X halfpage-up +bind -T copy-mode-emacs C-WheelDownPane send-keys -X halfpage-down + +# To copy, left click and drag to highlight text in yellow, +# once you release left click yellow text will disappear and will automatically be available in clibboard +# # Use vim keybindings in copy mode +setw -g mode-keys vi +# Update default binding of `Enter` to also use copy-pipe +unbind -T copy-mode-vi Enter +bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -selection c" +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard" +# VIM COPY + +# Powerline +# set-option -g status on +# set-option -g status-interval 2 +# set-option -g status-justify "centre" +# set-option -g status-left-length 60 +# set-option -g status-right-length 90 +# set-option -g status-left "#(~/tmux-powerline/powerline.sh left)" +# set-option -g status-right "#(~/tmux-powerline/powerline.sh right)" +#set-window-option -g window-status-current-format "#[fg=colour45, bg=colour232] #I ⮁ #[fg=colour240, bg=colour245]#W" +# run-shell "powerline-daemon -q" +# source "/usr/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf" +# setw -g aggressive-resize off + +set -g @dracula-show-powerline true +set -g @dracula-show-flags true +set -g @dracula-show-left-icon session +set -g @dracula-ping-server "8.8.8.8" +set -g @dracula-ping-rate 5 +set -g @dracula-day-month true +set -g @dracula-military-time true +# set -g @dracula-git-disable-status true +set -g @dracula-show-timezone false +set -g @dracula-show-location false +set -g @dracula-show-fahrenheit false +set -g status-position bottom + +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, tmux-ram-usage, network, network-bandwidth, network-ping, attached-clients, network-vpn, weather, time, spotify-tui, kubernetes-context, synchronize-panes +set -g @dracula-plugins "network-ping battery time" + +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-continuum' +set -g @plugin 'tmux-plugins/tmux-yank' +set -g @plugin 'christoomey/vim-tmux-navigator' +set -g @plugin 'dracula/tmux' +# set -g @plugin 'thewtex/tmux-mem-cpu-load' + + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.tmux/plugins/tpm/tpm' diff --git a/playbooks/templates/zsh/zshrc b/playbooks/templates/zsh/zshrc new file mode 100644 index 0000000..257b764 --- /dev/null +++ b/playbooks/templates/zsh/zshrc @@ -0,0 +1,98 @@ +echo "[\t--\t] Init new console" + +# Oh-My-ZSH +export ZSH=$HOME/.oh-my-zsh +ZSH_THEME="{{ var.zsh_theme }}" +plugins=( +{% for plugin in var.plugins %} + {{ plugin }} +{% endfor %} +) +echo "[\t{{ var.plugins|length }}\t]\tOh-My-ZSH - plugins" +source $ZSH/oh-my-zsh.sh + +# Local Vars +{% for local_var in var.local_vars %} +{{ local_var }} +{% endfor %} +echo "[\t{{ var.local_vars|length }}\t]\tLocal Vars" + +# Exports +{% for export in var.exports %} +export {{ export }} +{% endfor %} +echo -e "[\t{{ var.exports|length }}\t]\tExports" + +# Auto Stuff +{% for script in var.scripts %} +{{ script }} +{% endfor %} +echo -e "[\t{{ var.scripts|length }}\t]\tScripts" +# Prevent gnome keyboard to override system one + +# Imports +echo "- gpg-agent is connected to $GPG_TTY" +if [ ! -S ~/.ssh/ssh_auth_sock ]; then + eval `ssh-agent` + ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock +fi +ssh-add -l > /dev/null || ssh-add +echo -e "[\tok\t]\tImport keys" + +# Bind Keys +{% for bind in var.bind_keys %} +{{ bind }} +{% endfor %} +echo -e "[\t{{ var.bind_keys|length}}\t]\tBind keys" + +# ALIASES +{% for alias in var.aliases %} +alias {{ alias }} +{% endfor %} +echo -e "[\t{{ var.aliases|length }}\t]\tAliases" + +{% for source in var.sources %} +source {{ source }} +{% endfor %} +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +echo -e "[\t{{ var.sources|length }}\t]\tSources" + +{% if var.vault %} +{% for vault in var.vault %} +source {{ vault }} +{% endfor %} +echo -e "[\t{{ var.vault|length }}\t]\tVault" +{% else %} +echo -e "[\t--\t]\tNo Vault used" +{% endif %} + +{% if var.startx %} +if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then + echo "Startin X" + sleep 2 + exec startx +fi +{% endif %} + +{% if var.evals %} +{% for eval in var.evals %} +eval "$({{ eval }})" || echo "cant eval {{ eval }}" +{% endfor %} +echo -e "[\t{{ var.evals|length }}\t]\tEvals" +{% else %} +echo -e "[\t--\t]\tNo Evals used" +{% endif %} + +{% for misc in var.misc %} +{{ misc }} +{% endfor %} +echo -e "[\t{{ var.misc|length }}\t]\tMisc" + +source ~/.config/zsh/funcs +echo -e "[\tok\t]\tCustom funcs" + +echo -e "[\tok\t]\tCustom loads" +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + +echo -e "[\tdone\t]\tInit new console done" diff --git a/playbooks/vars/alacritty.yml b/playbooks/vars/alacritty.yml new file mode 100644 index 0000000..5d5e88f --- /dev/null +++ b/playbooks/vars/alacritty.yml @@ -0,0 +1,40 @@ +--- +role_component: + alacritty: + name: Alacritty - GPU Terminal + install: + pre: + - name: '[alacritty] deps' + package: + name: "{{'{{'}} item {{'}}'}}" + state: present + loop: [cmake, cargo] + become: true + post: + - name: '[alacritty][install] cargo install' + shell: cargo install alacritty + # - name: "[alacritty] cp into /usr/bin/alacritty" + # # TODO: use ansible module instead + # # shell: sudo cp ~/.cargo/bin/alacritty /usr/bin/alacritty + # # become: true + configs: + pre: + - name: '[alacritty][install] themes dir' + file: + path: ~/.config/alacritty/themes + state: directory + - name: '[alacritty][install] themes' + git: + repo: https://github.com/dracula/alacritty + dest: ~/.config/alacritty/themes/dracula + # They changed yaml to toml + version: 18353e319fada1e33c20b3dae840f9ce6eeede5d # pragma: allowlist secret + depth: 1 + templates: + alacritty: + template: alacritty.yml + dest: ~/.config/alacritty/alacritty.yml + variables: + font_size: 10.0 + font: "Iosevka Term" + term: xterm-256color diff --git a/playbooks/vars/asdf.yml b/playbooks/vars/asdf.yml new file mode 100644 index 0000000..67b3ee0 --- /dev/null +++ b/playbooks/vars/asdf.yml @@ -0,0 +1,90 @@ +--- +role_component: + asdf: + name: ASDF - Manage multiple runtime versions with a single CLI tool + install: + pre: + - name: '[asdf] system deps' + # https://github.com/pyenv/pyenv/wiki#suggested-build-environment + package: + name: "{{'{{'}} item {{'}}'}}" + state: present + loop: + - autoconf + - bison + - build-essential + - curl + - gettext + - git + - libbz2-dev + - libcurl4-openssl-dev + - libedit-dev + - libffi-dev + - libgd-dev + - libicu-dev + - libjpeg-dev + - liblzma-dev + - libmysqlclient-dev + - libncursesw5-dev + - libonig-dev + - libpng-dev + - libpq-dev + - libreadline-dev + - libsqlite3-dev + - libssl-dev + - libxml2-dev + - libxmlsec1-dev + - libzip-dev + - llvm + # - locate + - make + - openssl + - pkg-config + - re2c + - tk-dev + - unzip + - wget + - xz-utils + - zlib1g-dev + become: true + - name: '[asdf] install via git' + git: + repo: https://github.com/asdf-vm/asdf.git + dest: ~/.asdf + version: "{{'{{'}} versions.asdf {{'}}'}}" + configs: + pre: + - name: '[asdf] install repos' + shell: | + asdf plugin add {{'{{'}} item {{'}}'}} || echo "Already added?" + environment: + PATH: "{{'{{'}} ansible_env.HOME {{'}}'}}/.asdf/bin:{{'{{'}} ansible_env.PATH\ + \ {{'}}'}}" + loop: + - ruby https://github.com/asdf-vm/asdf-ruby.git + - nodejs https://github.com/asdf-vm/asdf-nodejs.git + - python https://github.com/danhper/asdf-python + - golang https://github.com/kennyp/asdf-golang.git + - gcloud https://github.com/jthegedus/asdf-gcloud + # - "php https://github.com/asdf-community/asdf-php.git" # BROKEN + - rust https://github.com/asdf-community/asdf-rust.git + - packer https://github.com/asdf-community/asdf-hashicorp.git + - terraform https://github.com/asdf-community/asdf-hashicorp.git + - name: '[asdf] install plugins' + # TODO: set version + shell: | + asdf install {{'{{'}} item {{'}}'}} + asdf global {{'{{'}} item {{'}}'}} + environment: + PATH: "{{'{{'}} ansible_env.HOME {{'}}'}}/.asdf/bin:{{ ansible_env.HOME\ + \ }}/.asdf/shims:{{ ansible_env.PATH }}:{{'{{'}} ansible_env.PATH {{'}}'}}" + loop: + - ruby {{'{{'}} versions.ruby {{'}}'}} + - nodejs {{'{{'}} versions.nodejs {{'}}'}} + - python {{'{{'}} versions.python {{'}}'}} + - golang {{'{{'}} versions.golang {{'}}'}} + - gcloud {{'{{'}} versions.gcloud {{'}}'}} + # - "php {{'{{'}} versions.gcloud {{'}}'}}" # BROKEN + - rust {{'{{'}} versions.rust {{'}}'}} + - packer {{'{{'}} versions.packer {{'}}'}} + - terraform {{'{{'}} versions.terraform {{'}}'}} diff --git a/playbooks/vars/brew.yml b/playbooks/vars/brew.yml new file mode 100644 index 0000000..61680ae --- /dev/null +++ b/playbooks/vars/brew.yml @@ -0,0 +1,38 @@ +--- +role_component: + brew: + name: Brew - package manager for macOS or Linux + install: + pre: + - name: '[brew] deps' + package: + name: "{{'{{'}} item {{'}}'}}" + state: present + loop: [git, curl] + become: true + - name: '[brew] get install script' + ansible.builtin.get_url: + url: https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh + dest: /tmp/install.sh + mode: '0770' + - name: '[brew] run install script' + shell: /bin/bash /tmp/install.sh + environment: + NONINTERACTIVE: 1 + become: false + post: + - name: '[brew] version' + shell: /home/linuxbrew/.linuxbrew/bin/brew --version + - name: '[brew] install brew packages' + community.general.homebrew: + state: present + name: [] + # - detect-secrets + # - direnv + # - ipcalc + # - lastpass-cli + # - lazygit + # - pre-commit + # - shellcheck + # - terraform-docs + # - tflint diff --git a/playbooks/vars/clipmenu.yml b/playbooks/vars/clipmenu.yml new file mode 100644 index 0000000..782b5ed --- /dev/null +++ b/playbooks/vars/clipmenu.yml @@ -0,0 +1,45 @@ +--- +role_component: + clipmenu: + name: Clipmenu - Simple Clipboard Manager + install: + pre: + - name: '[clipmenu] deps' + package: + name: + - build-essential + - git + - libxcursor-dev + - libxi-dev + - libxinerama-dev + - libxrandr-dev + - xsel + become: true + post: + - name: '[clipmenu] repo clipnotify' + git: + repo: https://github.com/cdown/clipnotify + dest: /tmp/clipnotify/ + depth: 1 + - name: '[clipmenu] repo clipmenu' + git: + repo: https://github.com/cdown/clipmenu + dest: /tmp/clipmenu/ + depth: 1 + - block: + - name: '[clipmenu] install clipnotify' + shell: make install + args: + chdir: /tmp/clipnotify + - name: '[clipmenu] install clipmenu' + shell: make install + args: + chdir: /tmp/clipmenu + become: true + - name: '[clipmenu] systemd user' + systemd: + name: clipmenud + state: started + enabled: true + scope: user + ignore_errors: yes # for molecule diff --git a/playbooks/vars/direnv.yml b/playbooks/vars/direnv.yml new file mode 100644 index 0000000..0bf5c77 --- /dev/null +++ b/playbooks/vars/direnv.yml @@ -0,0 +1,7 @@ +--- +# direnv +role_component: + direnv: + install: + brew: + - direnv diff --git a/playbooks/vars/dmenu.yml b/playbooks/vars/dmenu.yml new file mode 100644 index 0000000..df156f1 --- /dev/null +++ b/playbooks/vars/dmenu.yml @@ -0,0 +1,6 @@ +--- +role_component: + dmenu: + name: dmenu + install: + packages: [dmenu] diff --git a/playbooks/vars/fonts.yml b/playbooks/vars/fonts.yml new file mode 100644 index 0000000..27a6608 --- /dev/null +++ b/playbooks/vars/fonts.yml @@ -0,0 +1,11 @@ +--- +role_component: + fonts: + install: + pre: + - name: "[Fonts] TODO: replaced with https://www.lunarvim.org/docs/configuration/nerd-fonts" + shell: "echo https://www.lunarvim.org/docs/configuration/nerd-fonts" + - name: "fc-cache" + command: fc-cache -f ~/.local/share/fonts + run: + init: none diff --git a/playbooks/vars/git.yml b/playbooks/vars/git.yml new file mode 100644 index 0000000..7e42684 --- /dev/null +++ b/playbooks/vars/git.yml @@ -0,0 +1,31 @@ +--- +role_component: + git: + name: git + install: + packages: [git] + post: + - name: "[git] brew install lazygit" + community.general.homebrew: + name: lazygit + state: present + ignore_errors: true # now critical if this will not be installed + configs: + templates: + gitconfig: + template: gitconfig + dest: ~/.gitconfig + variables: + email: "" + name: "" + aliases: + - p = push + - st = status -sb + - ll = log --oneline + - last = log -1 HEAD --stat + - cm = commit -m + - rv = remote -v + - d = diff + - dv = difftool -t vimdiff -y + - gl = config --global -l + - se = !git rev-list --all | xargs git grep -F diff --git a/playbooks/vars/htop.yml b/playbooks/vars/htop.yml new file mode 100644 index 0000000..0c7013b --- /dev/null +++ b/playbooks/vars/htop.yml @@ -0,0 +1,12 @@ +--- +# htop +role_component: + htop: + install: + packages: + - htop + configs: + templates: + main: + template: htop + dest: ~/.config/htop/htoprc diff --git a/playbooks/vars/k9s.yml b/playbooks/vars/k9s.yml new file mode 100644 index 0000000..2d147b5 --- /dev/null +++ b/playbooks/vars/k9s.yml @@ -0,0 +1,67 @@ +--- +role_component: + k9s: + # deps: + # - brew # for MacOS + install: + pre: + - name: '[k9s] creating /tmp/k9s' + file: + path: /tmp/k9s + state: directory + + - name: '[k9s] creating ~/.local/bin/' + file: + path: ~/.local/bin + state: directory + + # Linux + - name: '[k9s] Download binary for Linux' + unarchive: + src: https://github.com/derailed/k9s/releases/download/{{'{{'}} versions.k9s + {{'}}'}}/k9s_Linux_amd64.tar.gz + remote_src: true + dest: /tmp/k9s + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' + + # MacOS + - block: + - name: '[k9s] MacOS deps' + community.general.homebrew: + name: gnu-tar + state: present + - name: '[k9s] Download binary for MacOS' + unarchive: + src: https://github.com/derailed/k9s/releases/download/{{'{{'}} versions.k9s + {{'}}'}}/k9s_Darwin_arm64.tar.gz + remote_src: true + dest: /tmp/k9s + environment: + PATH: /opt/homebrew/bin:$PATH + when: ansible_distribution == 'MacOSX' + + - name: "[k9s] move k9s binary into ~/.local/bin" + copy: + src: /tmp/k9s/k9s + dest: ~/.local/bin/ + remote_src: True + + configs: + pre: + - name: '[k9s] config dir' + file: + path: ~/.config/k9s + state: directory + templates: + main: + template: k9s/config.yml + dest: ~/.config/k9s/config.yml + hotkey: + template: k9s/hotkey.yml + dest: ~/.config/k9s/hotkey.yml + plugin: + template: k9s/plugin.yml + dest: ~/.config/k9s/plugin.yml + skin: + template: k9s/skin.yml + dest: ~/.config/k9s/skin.yml diff --git a/playbooks/vars/lastpass_cli.yml b/playbooks/vars/lastpass_cli.yml new file mode 100644 index 0000000..e17842a --- /dev/null +++ b/playbooks/vars/lastpass_cli.yml @@ -0,0 +1,6 @@ +--- +role_component: + lastpass-cli: + name: Lastpass CLI + install: + brew: [lastpass-cli] diff --git a/playbooks/vars/lvim.yml b/playbooks/vars/lvim.yml new file mode 100644 index 0000000..80083b3 --- /dev/null +++ b/playbooks/vars/lvim.yml @@ -0,0 +1,20 @@ +role_component: + lvim: + # https://www.lunarvim.org/docs/installation + name: "LunarVIM" + # deps: + # git, make, pip, python npm, node and cargo + # - asdf + # - nvim + # install: + # pre: + # - name: "[lvim] Install via official install script" + # shell: bash <(curl -s https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh) + # environment: + # LV_BRANCH: "release-1.3/neovim-0.9" + configs: + templates: + config_lua: + template: lvim/config.lua + dest: ~/.config/lvim/config.lua + # variables: diff --git a/playbooks/vars/minikube.yaml b/playbooks/vars/minikube.yaml new file mode 100644 index 0000000..2d61850 --- /dev/null +++ b/playbooks/vars/minikube.yaml @@ -0,0 +1,10 @@ +role_component: + minikube: + install: + pre: + - name: "[minikube] download" + # TODO: aarch + shell: "cd /tmp && curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64" + - name: "[minikube] download" + shell: install -m 755 /tmp/minikube /usr/local/bin/ + become: true diff --git a/playbooks/vars/nvim.yml b/playbooks/vars/nvim.yml new file mode 100644 index 0000000..fc4824a --- /dev/null +++ b/playbooks/vars/nvim.yml @@ -0,0 +1,8 @@ +role_component: + nvim: + name: "NeoVIM" + # deps: + # - brew + install: + brew: + - nvim diff --git a/playbooks/vars/ssh.yml b/playbooks/vars/ssh.yml new file mode 100644 index 0000000..9fe56bf --- /dev/null +++ b/playbooks/vars/ssh.yml @@ -0,0 +1,25 @@ +--- +# ssh +role_component: + ssh: + install: + packages: + - openssh-server + configs: + templates: + ssh_include: + template: ssh + dest: ~/.ssh/config + variables: + include: [] + # - ~/.ssh/example/config + ssh: + template: ssh + dest: ~/.ssh/example/config + variables: + hosts: + - name: example + host: example.com + user: u0_a130 + port: 8022 + key: ~/.ssh/key.ssh diff --git a/playbooks/vars/stew.yml b/playbooks/vars/stew.yml new file mode 100644 index 0000000..7936af4 --- /dev/null +++ b/playbooks/vars/stew.yml @@ -0,0 +1,28 @@ +--- +role_component: + stew: + name: Stew - An independent package manager for compiled binaries + install: + pre: + # - stat: path="~/.stew" + # register: stew_dir + - name: '[stew] dir' + file: + path: ~/.stew/bin + state: directory + - name: '[stew] install binary' + # TODO: install on arm + get_url: + url: https://github.com/marwanhawari/stew/releases/download/{{ versions.stew }}/stew-linux-amd64 + dest: ~/.stew/bin/stew + mode: 0755 + # configs: + # templates: + # stew: + # template: + # variables: + # apps: + # - 'argoproj/argo-rollouts@v1.2.0-rc2' + # - 'junegunn/fzf@0.29.0' + # - 'git-time-metric/gtm@v1.3.5' + # - 'BurntSushi/ripgrep@13.0.0' diff --git a/playbooks/vars/tmux.yml b/playbooks/vars/tmux.yml new file mode 100644 index 0000000..6332cf6 --- /dev/null +++ b/playbooks/vars/tmux.yml @@ -0,0 +1,20 @@ +--- +# tmux +role_component: + tmux: + install: + brew: + - tmux + - tmuxinator + post: + - name: "[tmux][install] Tmux Plugin Manager" + git: + repo: https://github.com/tmux-plugins/tpm + dest: ~/.tmux/plugins/tpm + depth: 1 + configs: + templates: + # main tmux config + tmux_conf: + template: tmux/tmux.conf + dest: ~/.tmux.conf diff --git a/playbooks/vars/versions.yml b/playbooks/vars/versions.yml new file mode 100644 index 0000000..6c01892 --- /dev/null +++ b/playbooks/vars/versions.yml @@ -0,0 +1,16 @@ +--- +versions: + asdf: v0.9.0 + gcloud: 375.0.0 + golang: 1.17.8 + grafana: 9.1.3 + kubectl: v1.26.0 + nodejs: 17.6.0 + python: 3.10.0 + ruby: 3.1.0 + rust: 1.59.0 + stew: v0.3.0 + terraform: 1.1.8 + packer: 1.8.0 + php: 8.0.2 + k9s: v0.27.4 diff --git a/playbooks/vars/zsh.yml b/playbooks/vars/zsh.yml new file mode 100644 index 0000000..969d784 --- /dev/null +++ b/playbooks/vars/zsh.yml @@ -0,0 +1,86 @@ +--- +role_component: + zsh: + # TODO: --ignore-deps for molecule testing + deps: [git] + install: + packages: [git, zsh] + pre: + - name: ZSH Installing oh-my-zsh + git: + repo: https://github.com/robbyrussell/oh-my-zsh + dest: ~/.oh-my-zsh + depth: 1 + force: true + - name: ZSH Change default shell + become: true + user: + name: "{{ '{{' }} ansible_user {{ '}}' }}" + shell: /bin/zsh + ignore_errors: true + - name: ZSH Change plugins + git: + repo: "{{ '{{' }} item.repo {{ '}}' }}" + dest: ~/.oh-my-zsh/custom/plugins/{{ '{{' }} item.plugin {{ '}}' }} + depth: 1 + loop: + - plugin: zsh-autosuggestions + repo: https://github.com/zsh-users/zsh-autosuggestions + - plugin: zsh-syntax-highlighting + repo: https://github.com/zsh-users/zsh-syntax-highlighting + - plugin: zsh-kubectl-prompt + repo: https://github.com/superbrothers/zsh-kubectl-prompt.git + - repo: https://github.com/bilelmoussaoui/flatpak-zsh-completion + plugin: flatpak + configs: + templates: + zsh_theme: + template: zsh/zshrc + dest: ~/.zshrc + variables: + startx: true + zsh_theme: agnoster + plugins: + - git + - kubectl + - zsh-autosuggestions + - zsh-syntax-highlighting + - zsh-kubectl-prompt + - asdf + - flatpak + local_vars: + - GPG_TTY=$(tty) + exports: + - DISABLE_UPDATE_PROMPT=true + - EDITOR=lvim + - GPG_TTY + - HISTTIMEFORMAT="%d/%m/%y %T " + - HOSTALIASES=~/.hosts + - LANG=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + - PASSWORD_STORE_CLIP_TIME=180 + - PATH="$PATH:/snap/bin" + - PATH="$PATH:$HOME/bin" + - PATH="$PATH:$HOME/go/bin" + - PATH="$PATH:$HOME/.local/bin" + - PATH="$PATH:$HOME/.stew/bin" + - PATH="$PATH:$HOME/install/flutter/bin" + - SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock + - VAGRANT_HOME='~/.vagrant.d' + - KUBECONFIG="${HOME}/.kube/config" + - HOSTALIASES=~/.hosts + - RPROMPT='%{$fg[blue]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}' + - XDG_CONFIG_HOME=~/.config/ + scripts: [] + bind_keys: + - bindkey '^ ' autosuggest-accept + aliases: [] + sources: [] + vault: [] + evals: + - direnv hook zsh + - kubectl completion zsh + misc: + - unalias gr + run: + init: none diff --git a/roles/components/README.md b/roles/components/README.md index 7f1b9c3..d90e4cb 100644 --- a/roles/components/README.md +++ b/roles/components/README.md @@ -1,13 +1,13 @@ [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine) ========= -[Ansible Role Components](https://galaxy.ansible.com/shellshock1953/components) +[Ansible Role Components](https://galaxy.ansible.com/dnullproject/components) ========= Component-oriented ansible role. Allow quick and easy install, configure, and run common programs. Also, great tool to manage your .dotfiles via ansible. -[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/dnull-project/components/master.svg)](https://results.pre-commit.ci/latest/github/dnull-project/components/master) +[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/dnullproject/components/master.svg)](https://results.pre-commit.ci/latest/github/dnullproject/components/master) Idea -------------- @@ -34,8 +34,6 @@ Thats all You need to start using Polybar or ZSH, or Dunst, of Rofi, or wherever Example Playbook (Polybar) ---------------- -Real life usage can be found [here](https://gitlab.com/shellshock.dnull/ansible). - `ansible playbook.yml` ```yaml @@ -131,8 +129,6 @@ echo "Polybar launched..." Another example Playbook (Dunst) ---------------- -Real life usage can be found [here](https://gitlab.com/shellshock.dnull/ansible). - `ansible playbook.yml` ```yaml diff --git a/roles/components/tasks/deps.yml b/roles/components/tasks/deps.yml index 244ed44..dce2fea 100644 --- a/roles/components/tasks/deps.yml +++ b/roles/components/tasks/deps.yml @@ -9,7 +9,7 @@ verbosity: 2 - name: '{{ prefix }} checking deps' stat: - path: ~/.dnull/{{ item }} + path: ~/.components/{{ item }} with_items: '{{ deps }}' register: ideps - fail: diff --git a/roles/components/tasks/install.yml b/roles/components/tasks/install.yml index 1289bfb..f6045c0 100644 --- a/roles/components/tasks/install.yml +++ b/roles/components/tasks/install.yml @@ -156,11 +156,11 @@ content: '{{ component_install_post }}' when: component_install_post - file: - path: ~/.dnull + path: ~/.components state: directory - - name: '{{ prefix }}[deps] Storing deps in ~/.dnull/{{ name }}' + - name: '{{ prefix }}[deps] Storing deps in ~/.components/{{ name }}' copy: - dest: ~/.dnull/{{ name }} + dest: ~/.components/{{ name }} content: | {{ ansible_date_time.iso8601 }} changed_when: false