added several ansible roles

This commit is contained in:
2024-02-25 21:16:00 +01:00
parent 0569464dbc
commit 0506eb2665
26 changed files with 652 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
[defaults]
INVENTORY = inventory
interpreter_python= /usr/bin/python3.10
interpreter_python= /usr/bin/python3
[ssh_connecctions]
pipelining = true

View File

@@ -1,3 +1,7 @@
[home]
rootserver
localhost
home:
hosts:
localhost:
ansible_connection: local
all:
children:
home:

View File

@@ -0,0 +1,3 @@
[home]
rootserver
localhost

View File

@@ -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

1
ansible/requirements.yml Normal file
View File

@@ -0,0 +1 @@
- src: community.general

View File

@@ -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'

View File

@@ -0,0 +1 @@
alias cat='bat --paging=never'

View File

@@ -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

View File

@@ -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

View File

@@ -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 <sheet>]: :->personal' \
'(-l --list)'{-l,--list}'[List cheatsheets]: :->full' \
'(-p --path)'{-p,--path}'[Return only sheets found on path <name>]: :->pathlist' \
'(-r --regex)'{-r,--regex}'[Treat search <phrase> as a regex]: :->none' \
'(-s --search)'{-s,--search}'[Search cheatsheets for <phrase>]: :->none' \
'(-t --tag)'{-t,--tag}'[Return only sheets matching <tag>]: :->taglist' \
'(-T --tags)'{-T,--tags}'[List all tags in use]: :->none' \
'(-v --version)'{-v,--version}'[Print the version number]: :->none' \
'(--rm)--rm[Remove (delete) <sheet>]: :->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

View File

@@ -0,0 +1,83 @@
# {{ ansible_managed }}
# The editor to use with 'cheat -e <sheet>'. 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').

View File

@@ -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"

View File

@@ -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": {}
}

View File

@@ -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

View File

@@ -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"'

View File

@@ -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"'

View File

@@ -0,0 +1,7 @@
- name: Install Cargo
include_tasks:
file: cargo.yml
- name: Install Go
include_tasks:
file: go.yml

View File

@@ -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'

View File

@@ -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

View File

@@ -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, <theme-file-name>
# when specifying <theme-file-name>, lsd will look up theme file
# XDG Base Directory if relative, e.g. ~/.config/lsd/themes/<theme-file-name>.yaml,
# The file path if absolute
theme: custom
# == Sorting ==
sorting:
column: name
dir-grouping: first
no-symlink: false
symlink-arrow:

View File

@@ -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'

View File

@@ -0,0 +1,9 @@
- name: Install zsh
hosts: home
tasks:
- name: Install zsh
become: yes
apt:
name:
- zsh
state: present