From 0506eb266555a46354e1d3a9d6d7bef5df3bf1dd Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 25 Feb 2024 21:16:00 +0100 Subject: [PATCH] added several ansible roles --- ansible/ansible.cfg | 2 +- ansible/inventory/hosts | 10 +- ansible/inventory/hosts.bak | 3 + ansible/playbook.yml | 15 +- ansible/requirements.yml | 1 + ansible/roles/bat/tasks/.gitkeep | 0 ansible/roles/bat/tasks/main.yml | 30 +++ ansible/roles/bat/templates/.gitkeep | 0 ansible/roles/bat/templates/bat.rc | 1 + ansible/roles/bw/tasks/main.yml | 7 + ansible/roles/cheat/tasks/main.yml | 61 ++++++ ansible/roles/cheat/templates/cheat/cheat.zsh | 68 ++++++ ansible/roles/cheat/templates/cheat/conf.yml | 83 ++++++++ .../roles/cheat/templates/cheat/glowpager.sh | 15 ++ ansible/roles/cheat/templates/glow/dark.json | 196 ++++++++++++++++++ ansible/roles/cheat/templates/glow/glow.yml | 10 + ansible/roles/general/tasks/cargo.yml | 15 ++ ansible/roles/general/tasks/go.yml | 29 +++ ansible/roles/general/tasks/main.yml | 7 + ansible/roles/lsd/tasks/.gitkeep | 0 ansible/roles/lsd/tasks/main.yml | 31 +++ ansible/roles/lsd/templates/.gitkeep | 0 ansible/roles/lsd/templates/colors.yaml | 27 +++ ansible/roles/lsd/templates/config.yaml | 28 +++ ansible/roles/lsd/templates/lsd.rc | 17 ++ ansible/roles/zsh/tasks/main.yml | 9 + 26 files changed, 652 insertions(+), 13 deletions(-) create mode 100644 ansible/inventory/hosts.bak create mode 100644 ansible/requirements.yml delete mode 100644 ansible/roles/bat/tasks/.gitkeep create mode 100644 ansible/roles/bat/tasks/main.yml delete mode 100644 ansible/roles/bat/templates/.gitkeep create mode 100644 ansible/roles/bat/templates/bat.rc create mode 100644 ansible/roles/bw/tasks/main.yml create mode 100644 ansible/roles/cheat/tasks/main.yml create mode 100644 ansible/roles/cheat/templates/cheat/cheat.zsh create mode 100644 ansible/roles/cheat/templates/cheat/conf.yml create mode 100755 ansible/roles/cheat/templates/cheat/glowpager.sh create mode 100644 ansible/roles/cheat/templates/glow/dark.json create mode 100644 ansible/roles/cheat/templates/glow/glow.yml create mode 100644 ansible/roles/general/tasks/cargo.yml create mode 100644 ansible/roles/general/tasks/go.yml create mode 100644 ansible/roles/general/tasks/main.yml delete mode 100644 ansible/roles/lsd/tasks/.gitkeep create mode 100644 ansible/roles/lsd/tasks/main.yml delete mode 100644 ansible/roles/lsd/templates/.gitkeep create mode 100644 ansible/roles/lsd/templates/colors.yaml create mode 100644 ansible/roles/lsd/templates/config.yaml create mode 100644 ansible/roles/lsd/templates/lsd.rc create mode 100644 ansible/roles/zsh/tasks/main.yml diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index c54d66f..8cc3085 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -1,6 +1,6 @@ [defaults] INVENTORY = inventory -interpreter_python= /usr/bin/python3.10 +interpreter_python= /usr/bin/python3 [ssh_connecctions] pipelining = true diff --git a/ansible/inventory/hosts b/ansible/inventory/hosts index a6fc9b7..6729dc8 100644 --- a/ansible/inventory/hosts +++ b/ansible/inventory/hosts @@ -1,3 +1,7 @@ -[home] -rootserver -localhost +home: + hosts: + localhost: + ansible_connection: local +all: + children: + home: diff --git a/ansible/inventory/hosts.bak b/ansible/inventory/hosts.bak new file mode 100644 index 0000000..a6fc9b7 --- /dev/null +++ b/ansible/inventory/hosts.bak @@ -0,0 +1,3 @@ +[home] +rootserver +localhost diff --git a/ansible/playbook.yml b/ansible/playbook.yml index 5e6f8d3..746e669 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -1,9 +1,6 @@ -- name: Install zsh - hosts: home - tasks: - - name: Install zsh - become: yes - apt: - name: - - zsh - state: present +- hosts: home + roles: + - role: general + - role: bat + - role: lsd + - role: cheat diff --git a/ansible/requirements.yml b/ansible/requirements.yml new file mode 100644 index 0000000..1a1bf98 --- /dev/null +++ b/ansible/requirements.yml @@ -0,0 +1 @@ +- src: community.general diff --git a/ansible/roles/bat/tasks/.gitkeep b/ansible/roles/bat/tasks/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/ansible/roles/bat/tasks/main.yml b/ansible/roles/bat/tasks/main.yml new file mode 100644 index 0000000..38e65c5 --- /dev/null +++ b/ansible/roles/bat/tasks/main.yml @@ -0,0 +1,30 @@ +- name: Install bat + community.general.cargo: + name: bat + path: '{{ ansible_user_dir }}/.cargo' + state: latest + locked: true + executable: /usr/bin/cargo + +- name: Create required folders + file: + state: directory + dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/{{ item.path }}" + with_filetree: ../templates + when: item.state == 'directory' + +- name: Install bat config files + template: + src: "{{ item.src }}" + dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/bat/{{ item.path }}" + owner: "{{ ansible_user_uid }}" + group: "{{ ansible_user_gid }}" + mode: '{{ item.mode }}' + with_filetree: templates/bat/ + +- name: Add to .zshrc + lineinfile: + path: "{{ ansible_user_dir }}/.zshrc" + insertafter: '\[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}.* \] && source {{ lookup("env", "XDG_CONFIG_HOME") }}.*' + regexp: '\[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}/bat/bat\.rc \] && source {{ lookup("env", "XDG_CONFIG_HOME") }}/bat/bat\.rc' + line: '[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}/bat/bat.rc ] && source {{ lookup("env", "XDG_CONFIG_HOME") }}/bat/bat.rc' diff --git a/ansible/roles/bat/templates/.gitkeep b/ansible/roles/bat/templates/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/ansible/roles/bat/templates/bat.rc b/ansible/roles/bat/templates/bat.rc new file mode 100644 index 0000000..e695dd8 --- /dev/null +++ b/ansible/roles/bat/templates/bat.rc @@ -0,0 +1 @@ +alias cat='bat --paging=never' \ No newline at end of file diff --git a/ansible/roles/bw/tasks/main.yml b/ansible/roles/bw/tasks/main.yml new file mode 100644 index 0000000..6ab81b9 --- /dev/null +++ b/ansible/roles/bw/tasks/main.yml @@ -0,0 +1,7 @@ +# Check if bw can be run +# Run bw --version + +# Run curl https://vault.bitwarden.com/download/?app=cli&platform=linux +# Check for Version String -> Update if newer + +# Add configuration files diff --git a/ansible/roles/cheat/tasks/main.yml b/ansible/roles/cheat/tasks/main.yml new file mode 100644 index 0000000..2f8acf5 --- /dev/null +++ b/ansible/roles/cheat/tasks/main.yml @@ -0,0 +1,61 @@ +- name: Install glow + become: true + shell: go install github.com/charmbracelet/glow@latest + environment: + GOPATH: "{{ go_path }}" + register: glow + changed_when: glow.stdout + when: result is succeeded + +- debug: var=glow verbosity=2 + +- name: Install cheat + become: true + shell: go install github.com/cheat/cheat/cmd/cheat@latest + environment: + GOPATH: "{{ go_path }}" + register: cheat + changed_when: cheat.stdout + when: result is succeeded + +- debug: var=cheat verbosity=2 + +- name: Create required folders + file: + state: directory + dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/{{ item.path }}" + with_filetree: ../templates + when: item.state == 'directory' + +- name: Install glow config files + template: + src: "{{ item.src }}" + dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/glow/{{ item.path }}" + owner: "{{ ansible_user_uid }}" + group: "{{ ansible_user_gid }}" + mode: '{{ item.mode }}' + with_filetree: templates/glow/ + +- name: Install cheat config files + template: + src: "{{ item.src }}" + dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/cheat/{{ item.path }}" + owner: "{{ ansible_user_uid }}" + group: "{{ ansible_user_gid }}" + mode: '{{ item.mode }}' + with_filetree: templates/cheat/ + +- name: Add to .zshrc + lineinfile: + path: "{{ ansible_user_dir }}/.zshrc" + insertafter: '\[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}.* \] && source {{ lookup("env", "XDG_CONFIG_HOME") }}.*' + regexp: '\[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}/cheat/cheat\.zsh \] && source {{ lookup("env", "XDG_CONFIG_HOME") }}/cheat/cheat\.zsh' + line: '[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}/cheat/cheat.zsh ] && source {{ lookup("env", "XDG_CONFIG_HOME") }}/cheat/cheat.zsh' + +- name: Download Cheatsheets + git: + accept_newhostkey: true + repo: 'git@git.cbeck.tech:kamu/cheatsheets.git' + dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/cheat/cheatsheets" + environment: + GIT_GERMINAL_PROMPT: 0 diff --git a/ansible/roles/cheat/templates/cheat/cheat.zsh b/ansible/roles/cheat/templates/cheat/cheat.zsh new file mode 100644 index 0000000..d644045 --- /dev/null +++ b/ansible/roles/cheat/templates/cheat/cheat.zsh @@ -0,0 +1,68 @@ +#compdef cheat +# {{ ansible_managed }} + +local cheats taglist pathlist + +_cheat_complete_personal_cheatsheets() +{ + cheats=("${(f)$(cheat -l -t hacking | tail -n +3 | cut -d' ' -f1)}") + _describe -t cheats 'cheats' cheats +} + +_cheat_complete_full_cheatsheets() +{ + cheats=("${(f)$(cheat -l | tail -n +3 | cut -d' ' -f1)}") + _describe -t cheats 'cheats' cheats +} + +_cheat_complete_tags() +{ + taglist=("${(f)$(cheat -T)}") + _describe -t taglist 'taglist' taglist +} + +_cheat_complete_paths() +{ + pathlist=("${(f)$(cheat -d | cut -d':' -f1)}") + _describe -t pathlist 'pathlist' pathlist +} + +_cheat() { + + _arguments -C \ + '(--init)--init[Write a default config file to stdout]: :->none' \ + '(-c --colorize)'{-c,--colorize}'[Colorize output]: :->none' \ + '(-d --directories)'{-d,--directories}'[List cheatsheet directories]: :->none' \ + '(-e --edit)'{-e,--edit}'[Edit ]: :->personal' \ + '(-l --list)'{-l,--list}'[List cheatsheets]: :->full' \ + '(-p --path)'{-p,--path}'[Return only sheets found on path ]: :->pathlist' \ + '(-r --regex)'{-r,--regex}'[Treat search as a regex]: :->none' \ + '(-s --search)'{-s,--search}'[Search cheatsheets for ]: :->none' \ + '(-t --tag)'{-t,--tag}'[Return only sheets matching ]: :->taglist' \ + '(-T --tags)'{-T,--tags}'[List all tags in use]: :->none' \ + '(-v --version)'{-v,--version}'[Print the version number]: :->none' \ + '(--rm)--rm[Remove (delete) ]: :->personal' + + case $state in + (none) + _cheat_complete_full_cheatsheets + ;; + (full) + _cheat_complete_full_cheatsheets + ;; + (personal) + _cheat_complete_personal_cheatsheets + ;; + (taglist) + _cheat_complete_tags + ;; + (pathlist) + _cheat_complete_paths + ;; + (*) + _cheat_complete_full_cheatsheets + ;; + esac +} + +compdef _cheat cheat diff --git a/ansible/roles/cheat/templates/cheat/conf.yml b/ansible/roles/cheat/templates/cheat/conf.yml new file mode 100644 index 0000000..840ea79 --- /dev/null +++ b/ansible/roles/cheat/templates/cheat/conf.yml @@ -0,0 +1,83 @@ +# {{ ansible_managed }} + +# The editor to use with 'cheat -e '. Defaults to $EDITOR or $VISUAL. +editor: /usr/local/bin/nvim + +# Should 'cheat' always colorize output? +colorize: false + +# Which 'chroma' colorscheme should be applied to the output? +# Options are available here: +# https://github.com/alecthomas/chroma/tree/master/styles +style: monokai + +# Which 'chroma' "formatter" should be applied? +# One of: "terminal", "terminal256", "terminal16m" +formatter: terminal256 + +# Through which pager should output be piped? +# 'less -FRX' is recommended on Unix systems +# 'more' is recommended on Windows +# pager: 'bat --lessopen --paging=never -l md -p' +pager: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/cheat/glowpager.sh" +# Cheatpaths are paths at which cheatsheets are available on your local +# filesystem. +# +# It is useful to sort cheatsheets into different cheatpaths for organizational +# purposes. For example, you might want one cheatpath for community +# cheatsheets, one for personal cheatsheets, one for cheatsheets pertaining to +# your day job, one for code snippets, etc. +# +# Cheatpaths are scoped, such that more "local" cheatpaths take priority over +# more "global" cheatpaths. (The most global cheatpath is listed first in this +# file; the most local is listed last.) For example, if there is a 'tar' +# cheatsheet on both global and local paths, you'll be presented with the local +# one by default. ('cheat -p' can be used to view cheatsheets from alternative +# cheatpaths.) +# +# Cheatpaths can also be tagged as "read only". This instructs cheat not to +# automatically create cheatsheets on a read-only cheatpath. Instead, when you +# would like to edit a read-only cheatsheet using 'cheat -e', cheat will +# perform a copy-on-write of that cheatsheet from a read-only cheatpath to a +# writeable cheatpath. +# +# This is very useful when you would like to maintain, for example, a +# "pristine" repository of community cheatsheets on one cheatpath, and an +# editable personal reponsity of cheatsheets on another cheatpath. +# +# Cheatpaths can be also configured to automatically apply tags to cheatsheets +# on certain paths, which can be useful for querying purposes. +# Example: 'cheat -t work jenkins'. +# +# Community cheatsheets must be installed separately, though you may have +# downloaded them automatically when installing 'cheat'. If not, you may +# download them here: +# +# https://github.com/cheat/cheatsheets +cheatpaths: + # Cheatpath properties mean the following: + # 'name': the name of the cheatpath (view with 'cheat -d', filter with 'cheat -p') + # 'path': the filesystem path of the cheatsheet directory (view with 'cheat -d') + # 'tags': tags that should be automatically applied to sheets on this path + # 'readonly': shall user-created ('cheat -e') cheatsheets be saved here? + # - name: community + # path: /home/kali/.config/cheat/cheatsheets/community + # tags: [ community ] + # readonly: true + + # If you have personalized cheatsheets, list them last. They will take + # precedence over the more global cheatsheets. + - name: hacking + path: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/cheat/cheatsheets/hacking" + tags: [ hacking ] + readonly: false + + # While it requires no configuration here, it's also worth noting that + # cheat will automatically append directories named '.cheat' within the + # current working directory to the 'cheatpath'. This can be very useful if + # you'd like to closely associate cheatsheets with, for example, a directory + # containing source code. + # + # Such "directory-scoped" cheatsheets will be treated as the most "local" + # cheatsheets, and will override less "local" cheatsheets. Similarly, + # directory-scoped cheatsheets will always be editable ('readonly: false'). diff --git a/ansible/roles/cheat/templates/cheat/glowpager.sh b/ansible/roles/cheat/templates/cheat/glowpager.sh new file mode 100755 index 0000000..378667e --- /dev/null +++ b/ansible/roles/cheat/templates/cheat/glowpager.sh @@ -0,0 +1,15 @@ +#! /bin/bash +# {{ ansible_managed }} + +# Create a temporary file +FILENAME=$(mktemp) + +# Save the original file name in our temp file +cat > $FILENAME +# Get the file content and substitute environment variables +TEMPCONTENT=$(command cat $FILENAME | envsubst '$LHOST') +# Delete the tempfile again +rm $TEMPFILE + +# Output the content as markdown with glow +echo "$TEMPCONTENT" | glow --style "$XDG_CONFIG_HOME/glow/dark.json" diff --git a/ansible/roles/cheat/templates/glow/dark.json b/ansible/roles/cheat/templates/glow/dark.json new file mode 100644 index 0000000..758de83 --- /dev/null +++ b/ansible/roles/cheat/templates/glow/dark.json @@ -0,0 +1,196 @@ +{ + "document": { + "block_prefix": "\n", + "block_suffix": "\n", + "margin": 2 + }, + "block_quote": { + "indent": 1, + "indent_token": "│ " + }, + "paragraph": {}, + "list": { + "level_indent": 2 + }, + "heading": { + "block_suffix": "\n", + "color": "#0f63bd", + "bold": true + }, + "h1": { + "prefix": "\u001b[38;5;1;0m󰉫\u001b[m ", + "suffix": " ", + "color": "#0ca8fb", + "background_color": "", + "bold": true + }, + "h2": { + "prefix": " 󰉬  " + }, + "h3": { + "prefix": " 󰉭 - " + }, + "h4": { + "prefix": " 󰉮 - " + }, + "h5": { + "prefix": " 󰉯 - " + }, + "h6": { + "prefix": " 󰉰 - ", + "color": "6", + "bold": false + }, + "text": {}, + "strikethrough": { + "crossed_out": true + }, + "emph": { + "italic": true + }, + "strong": { + "bold": true + }, + "hr": { + "color": "240", + "format": "\n--------\n" + }, + "item": { + "block_prefix": "• " + }, + "enumeration": { + "block_prefix": ". " + }, + "task": { + "ticked": "[✓] ", + "unticked": "[ ] " + }, + "link": { + "color": "30", + "underline": true + }, + "link_text": { + "color": "35", + "bold": true + }, + "image": { + "color": "212", + "underline": true + }, + "image_text": { + "color": "243", + "format": "Image: {{ '{{' }}.text{{ '}}' }} →" + }, + "code": { + "prefix": " ", + "suffix": " ", + "color": "#F1F1F1", + "background_color": "#011f2a" + }, + "code_block": { + "color": "244", + "margin": 2, + "chroma": { + "text": { + "color": "#C4C4C4" + }, + "error": { + "color": "#F1F1F1", + "background_color": "#F05B5B" + }, + "comment": { + "color": "#676767" + }, + "comment_preproc": { + "color": "#FF875F" + }, + "keyword": { + "color": "#00AAFF" + }, + "keyword_reserved": { + "color": "#FF5FD2" + }, + "keyword_namespace": { + "color": "#FF5F87" + }, + "keyword_type": { + "color": "#6E6ED8" + }, + "operator": { + "color": "#EF8080" + }, + "punctuation": { + "color": "#E8E8A8" + }, + "name": { + "color": "#C4C4C4" + }, + "name_builtin": { + "color": "#FF8EC7" + }, + "name_tag": { + "color": "#B083EA" + }, + "name_attribute": { + "color": "#7A7AE6" + }, + "name_class": { + "color": "#F1F1F1", + "underline": true, + "bold": true + }, + "name_constant": {}, + "name_decorator": { + "color": "#FFFF87" + }, + "name_exception": {}, + "name_function": { + "color": "#00D787" + }, + "name_other": {}, + "literal": {}, + "literal_number": { + "color": "#6EEFC0" + }, + "literal_date": {}, + "literal_string": { + "color": "#C69669" + }, + "literal_string_escape": { + "color": "#AFFFD7" + }, + "generic_deleted": { + "color": "#FD5B5B" + }, + "generic_emph": { + "italic": true + }, + "generic_inserted": { + "color": "#00D787" + }, + "generic_strong": { + "bold": true + }, + "generic_subheading": { + "color": "#777777" + }, + "background": { + "background_color": "#373737" + } + } + }, + "table": { + "margin": 4, + "center_separator": "\u001b[38;5;14m┼\u001b[m", + "column_separator": "\u001b[38;5;14m│\u001b[m", + "row_separator": "\u001b[38;5;14m─\u001b[m", + "color":"#F1F1F1" + }, + "definition_list": {}, + "definition_term": {}, + "definition_description": { + "block_prefix": "\n🠶 " + }, + "html_block": {}, + "html_span": {} +} diff --git a/ansible/roles/cheat/templates/glow/glow.yml b/ansible/roles/cheat/templates/glow/glow.yml new file mode 100644 index 0000000..af55df9 --- /dev/null +++ b/ansible/roles/cheat/templates/glow/glow.yml @@ -0,0 +1,10 @@ +# style name or JSON path (default "auto") +style: "$XDG_CONFIG_HOME/glow/dark.json" +# show local files only; no network (TUI-mode only) +local: true +# mouse support (TUI-mode only) +mouse: false +# use pager to display markdown +pager: false +# word-wrap at width +width: 150 diff --git a/ansible/roles/general/tasks/cargo.yml b/ansible/roles/general/tasks/cargo.yml new file mode 100644 index 0000000..68444a0 --- /dev/null +++ b/ansible/roles/general/tasks/cargo.yml @@ -0,0 +1,15 @@ + +- name: Install Cargo + become: true + package: + name: + - cargo + +- name: Add Go to PATH + lineinfile: + path: "{{ ansible_user_dir }}/.zshrc" + insertafter: 'export PATH="$PATH.*' + regexp: 'export PATH="$PATH:{{ ansible_user_dir }}/\.cargo/bin"' + line: 'export PATH="$PATH:{{ ansible_user_dir }}/.cargo/bin"' + + diff --git a/ansible/roles/general/tasks/go.yml b/ansible/roles/general/tasks/go.yml new file mode 100644 index 0000000..b292414 --- /dev/null +++ b/ansible/roles/general/tasks/go.yml @@ -0,0 +1,29 @@ +- name: Install Go + become: true + package: + name: + - golang + +- name: check go version + command: go version + register: result + changed_when: no + ignore_errors: true + +- name: Print return information from the previous task + ansible.builtin.debug: + var: result + verbosity: 2 + +- set_fact: + go_path: "{{ lookup('env', 'GOPATH') | default(ansible_env.HOME+'/go', true) }}" + when: result is succeeded + +- name: Add Go to PATH + lineinfile: + path: "{{ ansible_user_dir }}/.zshrc" + insertafter: 'export PATH="$PATH.*' + regexp: 'export PATH="$PATH:{{ ansible_user_dir }}/go/bin"' + line: 'export PATH="$PATH:{{ ansible_user_dir }}/go/bin"' + + diff --git a/ansible/roles/general/tasks/main.yml b/ansible/roles/general/tasks/main.yml new file mode 100644 index 0000000..4a05460 --- /dev/null +++ b/ansible/roles/general/tasks/main.yml @@ -0,0 +1,7 @@ +- name: Install Cargo + include_tasks: + file: cargo.yml + +- name: Install Go + include_tasks: + file: go.yml diff --git a/ansible/roles/lsd/tasks/.gitkeep b/ansible/roles/lsd/tasks/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/ansible/roles/lsd/tasks/main.yml b/ansible/roles/lsd/tasks/main.yml new file mode 100644 index 0000000..fde1627 --- /dev/null +++ b/ansible/roles/lsd/tasks/main.yml @@ -0,0 +1,31 @@ +- name: Install lsd + become: true + community.general.cargo: + name: lsd + locked: true + path: '{{ ansible_user_dir }}/.cargo' + executable: /usr/bin/cargo + +- name: Create required folders + file: + state: directory + dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/{{ item.path }}" + with_filetree: ../templates + when: item.state == 'directory' + +- name: Install lsd config files + template: + src: "{{ item.src }}" + dest: "{{ lookup('env', 'XDG_CONFIG_HOME') }}/lsd/{{ item.path }}" + owner: "{{ ansible_user_uid }}" + group: "{{ ansible_user_gid }}" + mode: '{{ item.mode }}' + with_filetree: templates/lsd/ + +- name: Add to .zshrc + lineinfile: + path: "{{ ansible_user_dir }}/.zshrc" + insertafter: '\[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}.* \] && source {{ lookup("env", "XDG_CONFIG_HOME") }}.*' + regexp: '\[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}/lsd/lsd\.rc \] && source {{ lookup("env", "XDG_CONFIG_HOME") }}/lsd/lsd\.rc' + line: '[ -f {{ lookup("env", "XDG_CONFIG_HOME") }}/lsd/lsd.rc ] && source {{ lookup("env", "XDG_CONFIG_HOME") }}/lsd/lsd.rc' + diff --git a/ansible/roles/lsd/templates/.gitkeep b/ansible/roles/lsd/templates/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/ansible/roles/lsd/templates/colors.yaml b/ansible/roles/lsd/templates/colors.yaml new file mode 100644 index 0000000..46a16b4 --- /dev/null +++ b/ansible/roles/lsd/templates/colors.yaml @@ -0,0 +1,27 @@ +user: 253 +group: 253 +permission: + read: dark_green + write: dark_yellow + exec: dark_red + exec-sticky: 5 + no-access: 245 + octal: 6 + acl: dark_cyan + context: cyan +date: + hour-old: [0x00, 0xAF, 0xFF] + day-old: [0x00,0x5f,0xaf] + older: 245 +size: + none: 240 + small: 245 + medium: 250 + large: white +inode: + valid: 13 + invalid: 245 +links: + valid: 13 + invalid: 245 +tree-edge: 245 \ No newline at end of file diff --git a/ansible/roles/lsd/templates/config.yaml b/ansible/roles/lsd/templates/config.yaml new file mode 100644 index 0000000..7b50adb --- /dev/null +++ b/ansible/roles/lsd/templates/config.yaml @@ -0,0 +1,28 @@ +blocks: + - permission + - user + - group + - size + - date + - name + +color: + # When to colorize the output. + # When "classic" is set, this is set to "never". + # Possible values: never, auto, always + when: auto + # How to colorize the output. + # When "classic" is set, this is set to "no-color". + # Possible values: default, + # when specifying , lsd will look up theme file + # XDG Base Directory if relative, e.g. ~/.config/lsd/themes/.yaml, + # The file path if absolute + theme: custom + +# == Sorting == +sorting: + column: name + dir-grouping: first + +no-symlink: false +symlink-arrow: ⇒ \ No newline at end of file diff --git a/ansible/roles/lsd/templates/lsd.rc b/ansible/roles/lsd/templates/lsd.rc new file mode 100644 index 0000000..f81c183 --- /dev/null +++ b/ansible/roles/lsd/templates/lsd.rc @@ -0,0 +1,17 @@ +alias ls='lsd --config-file $KHOME/.config/lsd/config.yaml' +# --- +alias l='ls -l' +alias la='ls -a' +alias ll='ls -lah' +alias lt='ls -a --tree --depth 2 --ignore-glob .git' +alias lt2='ls -a --tree --depth 3 --ignore-glob .git' +alias lt3='ls -a --tree --depth 4 --ignore-glob .git' +alias lt4='ls -a --tree --depth 5 --ignore-glob .git' +alias lt5='ls -a --tree --depth 6 --ignore-glob .git' +alias ltu='ls -a --tree --ignore-glob .git' +alias ltl='ls -lah --tree --depth 2 --ignore-glob .git' +alias ltl2='ls -lah --tree --depth 3 --ignore-glob .git' +alias ltl3='ls -lah --tree --depth 4 --ignore-glob .git' +alias ltl4='ls -lah --tree --depth 5 --ignore-glob .git' +alias ltl5='ls -lah --tree --depth 6 --ignore-glob .git' +alias ltlu='ls -lah --tree --ignore-glob .git' diff --git a/ansible/roles/zsh/tasks/main.yml b/ansible/roles/zsh/tasks/main.yml new file mode 100644 index 0000000..5e6f8d3 --- /dev/null +++ b/ansible/roles/zsh/tasks/main.yml @@ -0,0 +1,9 @@ +- name: Install zsh + hosts: home + tasks: + - name: Install zsh + become: yes + apt: + name: + - zsh + state: present