develop #1
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
password
|
||||
5
group_vars/all/all.yml
Normal file
5
group_vars/all/all.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default_user: plex
|
||||
default_user_password: "{{ vault_default_user_password }}"
|
||||
pyenv_python_version: 3.9.0
|
||||
...
|
||||
63
group_vars/all/apt.yml
Normal file
63
group_vars/all/apt.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
---
|
||||
packages_to_install:
|
||||
- acl
|
||||
- atop
|
||||
- bash-completion
|
||||
- bc
|
||||
- build-essential
|
||||
- cryptsetup
|
||||
- curl
|
||||
- curl
|
||||
- dnsutils
|
||||
- dos2unix
|
||||
- exim4
|
||||
- git-core
|
||||
- glances
|
||||
- gnupg
|
||||
- gzip
|
||||
- hddtemp
|
||||
- htop
|
||||
- jq
|
||||
- libbz2-dev
|
||||
- libffi-dev
|
||||
- liblzma-dev
|
||||
- libncurses5-dev
|
||||
- libreadline-dev
|
||||
- libsqlite3-dev
|
||||
- libssl-dev
|
||||
- libxml2-dev
|
||||
- libxmlsec1-dev
|
||||
- llvm
|
||||
- lm-sensors
|
||||
- logrotate
|
||||
- lvm2
|
||||
- lynx
|
||||
- mlocate
|
||||
- neofetch
|
||||
- net-tools
|
||||
- netcat
|
||||
- nmap
|
||||
- ntp
|
||||
- parted
|
||||
- pkg-config
|
||||
- psmisc
|
||||
- python-apt
|
||||
- python3-pip
|
||||
- python3-venv
|
||||
- rclone
|
||||
- rename
|
||||
- reptyr
|
||||
- rkhunter
|
||||
- rsync
|
||||
- screen
|
||||
- sshfs
|
||||
- sudo
|
||||
- tk-dev
|
||||
- tmux
|
||||
- ufw
|
||||
- vim
|
||||
- wget
|
||||
- wget
|
||||
- xz-utils
|
||||
- zlib1g-dev
|
||||
- zsh
|
||||
8
group_vars/all/cargo.yml
Normal file
8
group_vars/all/cargo.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
cargo_packages:
|
||||
- cargo-update
|
||||
- exa
|
||||
- bat
|
||||
- fd-find
|
||||
- ripgrep
|
||||
- bottom
|
||||
7
group_vars/all/vault_all.yml
Normal file
7
group_vars/all/vault_all.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
vault_default_user_password: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
65616334373032636534383932373465623634363431323863393839663937613838383566383035
|
||||
6133633038623361636630346233643838623533383333300a356332363165376330376236356665
|
||||
37656230373838373038386234326563656637306236383162383866343163623366356631373862
|
||||
6631616666363137620a363835316632313730623534353336303730363964653231336139383961
|
||||
6361
|
||||
7
hosts
Normal file
7
hosts
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
all:
|
||||
hosts:
|
||||
116.203.200.219:
|
||||
vars:
|
||||
ansible_user: "root"
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_rsa
|
||||
2
old/ansible.cfg
Normal file
2
old/ansible.cfg
Normal file
@@ -0,0 +1,2 @@
|
||||
[defaults]
|
||||
inventory = hosts
|
||||
1679
roles/shell/files/.p10k.zsh
Normal file
1679
roles/shell/files/.p10k.zsh
Normal file
File diff suppressed because it is too large
Load Diff
45
roles/shell/files/.tmux.conf
Normal file
45
roles/shell/files/.tmux.conf
Normal file
@@ -0,0 +1,45 @@
|
||||
######################
|
||||
### DESIGN CHANGES ###
|
||||
######################
|
||||
|
||||
# 256 colours
|
||||
set -g default-terminal "screen-256color"
|
||||
|
||||
# loud or quiet?
|
||||
set -g visual-activity both
|
||||
set -g visual-bell both
|
||||
set -g visual-silence off
|
||||
setw -g monitor-activity off
|
||||
set -g bell-action other
|
||||
|
||||
# modes
|
||||
setw -g clock-mode-colour colour9
|
||||
setw -g mode-style 'fg=colour1 bg=colour18 bold'
|
||||
|
||||
# panes (when splitting)
|
||||
set -g pane-border-style 'fg=colour3 bg=colour0'
|
||||
set -g pane-active-border-style 'bg=colour0 fg=colour7'
|
||||
|
||||
# statusbar
|
||||
set -g status-position bottom
|
||||
set -g status-justify left
|
||||
# bar across the bottom (blank)
|
||||
set -g status-style 'bg=colour3 fg=colour137 dim'
|
||||
set -g status-left ''
|
||||
# date + time fg=font, bg=background
|
||||
set -g status-right '#[fg=colour253,bg=colour15] %d/%m #[fg=colour253,bg=colour15] %H:%M:%S '
|
||||
set -g status-right-length 50
|
||||
set -g status-left-length 20
|
||||
|
||||
# current window (tabs on bottom left)
|
||||
setw -g window-status-current-style 'fg=colour253 bg=colour15 bold'
|
||||
setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F '
|
||||
|
||||
# inactive windows (tabs on bottom left)
|
||||
setw -g window-status-style 'fg=colour253 bg=colour16'
|
||||
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
|
||||
|
||||
setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold'
|
||||
|
||||
# messages
|
||||
set -g message-style 'fg=colour232 bg=colour3 bold'
|
||||
175
roles/shell/tasks/main.yml
Normal file
175
roles/shell/tasks/main.yml
Normal file
@@ -0,0 +1,175 @@
|
||||
---
|
||||
- name: Create default user
|
||||
user:
|
||||
name: "{{ default_user }}"
|
||||
password: "{{ default_user_password | password_hash('sha512') }}"
|
||||
groups: sudo
|
||||
create_home: yes
|
||||
shell: /bin/zsh
|
||||
generate_ssh_key: yes
|
||||
ssh_key_bits: 2048
|
||||
ssh_key_file: .ssh/id_rsa
|
||||
update_password: always
|
||||
state: present
|
||||
|
||||
- name: Ensure sudo group has passwordless sudo privileges
|
||||
lineinfile:
|
||||
dest: /etc/sudoers
|
||||
state: present
|
||||
regexp: "^%sudo"
|
||||
line: "%sudo ALL=(ALL) NOPASSWD:ALL"
|
||||
validate: "/usr/sbin/visudo -cf %s"
|
||||
|
||||
- name: Upgrade apt packages
|
||||
apt:
|
||||
update_cache: yes
|
||||
upgrade: full
|
||||
|
||||
- name: Install apt packages
|
||||
apt:
|
||||
name: "{{ packages_to_install }}"
|
||||
|
||||
- name: Get default user home
|
||||
getent:
|
||||
database: passwd
|
||||
key: "{{ default_user }}"
|
||||
split: ":"
|
||||
|
||||
- name: Set default user home
|
||||
set_fact:
|
||||
default_user_home: "{{ getent_passwd[default_user][4] }}"
|
||||
|
||||
- name: Install .tmux.conf to default user
|
||||
copy:
|
||||
src: .tmux.conf
|
||||
dest: "{{ default_user_home }}/.tmux.conf"
|
||||
owner: "{{ default_user }}"
|
||||
group: "{{default_user}}"
|
||||
force: yes
|
||||
mode: 0644
|
||||
|
||||
- name: Create temporary install directory
|
||||
tempfile:
|
||||
path: "/home/{{ default_user }}"
|
||||
state: directory
|
||||
suffix: .tmp
|
||||
register: temp_install_dir
|
||||
changed_when: false
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Download oh-my-zsh
|
||||
get_url:
|
||||
url: https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||
dest: "{{ temp_install_dir.path }}"
|
||||
mode: 0777
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Install oh-my-zsh
|
||||
shell: "sh {{ temp_install_dir.path }}/install.sh --unattended"
|
||||
args:
|
||||
creates: "{{ default_user_home }}/.oh-my-zsh"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Install powerlevel10k theme
|
||||
git:
|
||||
repo: "https://gitee.com/romkatv/powerlevel10k.git"
|
||||
version: master
|
||||
dest: "{{ default_user_home }}/.oh-my-zsh/custom/themes/powerlevel10k"
|
||||
depth: 1
|
||||
|
||||
- name: Install zsh-syntax-highlighting
|
||||
git:
|
||||
repo: "https://github.com/zsh-users/zsh-syntax-highlighting.git"
|
||||
version: master
|
||||
dest: "{{ default_user_home }}/.zsh/zsh-syntax-highlighting"
|
||||
clone: yes
|
||||
update: yes
|
||||
|
||||
- name: Install zsh-autosuggestions
|
||||
git:
|
||||
repo: https://github.com/zsh-users/zsh-autosuggestions
|
||||
version: master
|
||||
dest: "{{ default_user_home }}/.zsh/zsh-autosuggestions"
|
||||
clone: yes
|
||||
update: yes
|
||||
|
||||
- name: Install .zshrc to default user
|
||||
template:
|
||||
src: .zshrc.j2
|
||||
dest: "{{ default_user_home }}/.zshrc"
|
||||
owner: "{{ default_user }}"
|
||||
group: "{{ default_user }}"
|
||||
force: yes
|
||||
mode: 0644
|
||||
|
||||
- name: Install .p10k.zsh to default user
|
||||
copy:
|
||||
src: .p10k.zsh
|
||||
dest: "{{ default_user_home }}/.p10k.zsh"
|
||||
owner: "{{ default_user }}"
|
||||
group: "{{default_user}}"
|
||||
force: yes
|
||||
mode: 0644
|
||||
|
||||
- name: Install Rustup
|
||||
shell: curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||
args:
|
||||
creates: "{{ default_user_home }}/.cargo/bin/rustup"
|
||||
environment:
|
||||
RUSTUP_HOME: "{{ default_user_home }}/.rustup"
|
||||
CARGO_HOME: "{{ default_user_home }}/.cargo"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Install pyenv
|
||||
shell: curl https://pyenv.run | zsh
|
||||
args:
|
||||
creates: "{{ default_user_home }}/.pyenv/bin/pyenv"
|
||||
environment:
|
||||
PYENV_ROOT: "{{ default_user_home }}/.pyenv"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Install pyenv version of python
|
||||
shell: "{{ default_user_home }}/.pyenv/bin/pyenv install {{ pyenv_python_version }}"
|
||||
args:
|
||||
creates: "{{ default_user_home }}/.pyenv/versions/{{ pyenv_python_version }}/bin/python"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Install pipx
|
||||
command: python3 -m pip install pipx --user
|
||||
args:
|
||||
creates: "{{ default_user_home }}/.local/bin/pipx"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Install poetry
|
||||
shell: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
|
||||
args:
|
||||
creates: "{{ default_user_home }}/.poetry/bin/poetry"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Install poetry plugin for oh-my-zsh
|
||||
shell: |
|
||||
mkdir {{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry
|
||||
{{ default_user_home }}/.poetry/bin/poetry completions zsh > {{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry/_poetry
|
||||
args:
|
||||
creates: "{{ default_user_home }}/.oh-my-zsh/custom/plugins/poetry"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Configure poetry
|
||||
command: "{{ default_user_home }}/.poetry/bin/poetry config virtualenvs.in-project true"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Install base rust programs
|
||||
shell: "{{ default_user_home }}/.cargo/bin/cargo install {{ item }}"
|
||||
loop: "{{ cargo_packages }}"
|
||||
become: true
|
||||
become_user: "{{ default_user }}"
|
||||
209
roles/shell/templates/.zshrc.j2
Normal file
209
roles/shell/templates/.zshrc.j2
Normal file
@@ -0,0 +1,209 @@
|
||||
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
||||
# Initialization code that may require console input (password prompts, [y/n]
|
||||
# confirmations, etc.) must go above this block; everything else may go below.
|
||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
fi
|
||||
|
||||
# If you come from bash you might have to change your $PATH.
|
||||
# export PATH=$HOME/bin:/usr/local/bin:$PATH
|
||||
|
||||
# Path to your oh-my-zsh installation.
|
||||
export ZSH="$HOME/.oh-my-zsh"
|
||||
|
||||
ZSH_THEME="powerlevel10k/powerlevel10k"
|
||||
|
||||
# Set list of themes to pick from when loading at random
|
||||
# Setting this variable when ZSH_THEME=random will cause zsh to load
|
||||
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
|
||||
# If set to an empty array, this variable will have no effect.
|
||||
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
|
||||
|
||||
# Uncomment the following line to use case-sensitive completion.
|
||||
# CASE_SENSITIVE="true"
|
||||
|
||||
# Uncomment the following line to use hyphen-insensitive completion.
|
||||
# Case-sensitive completion must be off. _ and - will be interchangeable.
|
||||
# HYPHEN_INSENSITIVE="true"
|
||||
|
||||
# Uncomment the following line to disable bi-weekly auto-update checks.
|
||||
# DISABLE_AUTO_UPDATE="true"
|
||||
|
||||
# Uncomment the following line to automatically update without prompting.
|
||||
# DISABLE_UPDATE_PROMPT="true"
|
||||
|
||||
# Uncomment the following line to change how often to auto-update (in days).
|
||||
# export UPDATE_ZSH_DAYS=13
|
||||
|
||||
# Uncomment the following line if pasting URLs and other text is messed up.
|
||||
# DISABLE_MAGIC_FUNCTIONS=true
|
||||
|
||||
# Uncomment the following line to disable colors in ls.
|
||||
# DISABLE_LS_COLORS="true"
|
||||
|
||||
# Uncomment the following line to disable auto-setting terminal title.
|
||||
# DISABLE_AUTO_TITLE="true"
|
||||
|
||||
# Uncomment the following line to enable command auto-correction.
|
||||
# ENABLE_CORRECTION="true"
|
||||
|
||||
# Uncomment the following line to display red dots whilst waiting for completion.
|
||||
# COMPLETION_WAITING_DOTS="true"
|
||||
|
||||
# Uncomment the following line if you want to disable marking untracked files
|
||||
# under VCS as dirty. This makes repository status check for large repositories
|
||||
# much, much faster.
|
||||
# DISABLE_UNTRACKED_FILES_DIRTY="true"
|
||||
|
||||
# Uncomment the following line if you want to change the command execution time
|
||||
# stamp shown in the history command output.
|
||||
# You can set one of the optional three formats:
|
||||
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
||||
# or set a custom format using the strftime function format specifications,
|
||||
# see 'man strftime' for details.
|
||||
# HIST_STAMPS="mm/dd/yyyy"
|
||||
|
||||
# Would you like to use another custom folder than $ZSH/custom?
|
||||
# ZSH_CUSTOM=/path/to/new-custom-folder
|
||||
|
||||
# Which plugins would you like to load?
|
||||
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
|
||||
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
# Add wisely, as too many plugins slow down shell startup.
|
||||
plugins=(
|
||||
git
|
||||
sudo
|
||||
colored-man-pages
|
||||
copydir
|
||||
cp
|
||||
jump
|
||||
tmux
|
||||
docker
|
||||
docker-compose
|
||||
poetry
|
||||
)
|
||||
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
# User configuration
|
||||
|
||||
# export MANPATH="/usr/local/man:$MANPATH"
|
||||
|
||||
# You may need to manually set your language environment
|
||||
# export LANG=en_US.UTF-8
|
||||
|
||||
# Preferred editor for local and remote sessions
|
||||
# if [[ -n $SSH_CONNECTION ]]; then
|
||||
# export EDITOR='vim'
|
||||
# else
|
||||
# export EDITOR='mvim'
|
||||
# fi
|
||||
|
||||
# Compilation flags
|
||||
# export ARCHFLAGS="-arch x86_64"
|
||||
|
||||
# Set personal aliases, overriding those provided by oh-my-zsh libs,
|
||||
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
|
||||
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
|
||||
# For a full list of active aliases, run `alias`.
|
||||
#
|
||||
# Example aliases
|
||||
# alias zshconfig="mate ~/.zshrc"
|
||||
# alias ohmyzsh="mate ~/.oh-my-zsh"
|
||||
|
||||
|
||||
HISTSIZE=50000
|
||||
SAVEHIST=10000
|
||||
setopt extended_history
|
||||
setopt hist_expire_dups_first
|
||||
setopt hist_ignore_dups
|
||||
setopt hist_ignore_space
|
||||
setopt inc_append_history
|
||||
setopt share_history
|
||||
|
||||
# Changing directories
|
||||
setopt auto_cd
|
||||
setopt auto_pushd
|
||||
unsetopt pushd_ignore_dups
|
||||
setopt pushdminus
|
||||
|
||||
# Completion
|
||||
setopt auto_menu
|
||||
setopt always_to_end
|
||||
setopt complete_in_word
|
||||
unsetopt flow_control
|
||||
unsetopt menu_complete
|
||||
zstyle ':completion:*:*:*:*:*' menu select
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
|
||||
zstyle ':completion::complete:*' use-cache 1
|
||||
zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR
|
||||
zstyle ':completion:*' list-colors ''
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
||||
|
||||
# Other
|
||||
setopt prompt_subst
|
||||
|
||||
################################################################
|
||||
# ZSH #
|
||||
################################################################
|
||||
|
||||
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
|
||||
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||
|
||||
################################################################
|
||||
# ALIASES #
|
||||
################################################################
|
||||
alias ls="exa"
|
||||
alias ll="exa -l"
|
||||
alias pbat="bat -Pp"
|
||||
alias vsource="source .venv/bin/activate"
|
||||
alias size='du -c -h -d 1 | sort -h'
|
||||
|
||||
################################################################
|
||||
# PATH #
|
||||
################################################################
|
||||
export PATH=/usr/sbin:$PATH
|
||||
export PATH="$PATH:$HOME/.local/bin"
|
||||
|
||||
################################################################
|
||||
# PYTHON #
|
||||
################################################################
|
||||
# Pyenv
|
||||
export PATH="$HOME/.pyenv/bin:$PATH"
|
||||
eval "$(pyenv init -)"
|
||||
eval "$(pyenv virtualenv-init -)"
|
||||
|
||||
# Pipx
|
||||
export PIPX_DEFAULT_PYTHON="$HOME/.pyenv/shims/python3"
|
||||
autoload -U bashcompinit
|
||||
bashcompinit
|
||||
eval "$(register-python-argcomplete pipx)"
|
||||
|
||||
# Poetry
|
||||
export PATH="$HOME/.poetry/bin:$PATH"
|
||||
|
||||
################################################################
|
||||
# RUST #
|
||||
################################################################
|
||||
source "$HOME/.cargo/env"
|
||||
|
||||
################################################################
|
||||
# APPS #
|
||||
################################################################
|
||||
# AWS
|
||||
# complete -C "$HOME/.local/bin/aws_completer" aws
|
||||
|
||||
# TFEnv
|
||||
export PATH="$PATH:$HOME/.tfenv/bin"
|
||||
|
||||
# VSCode
|
||||
export PATH="/usr/local/bin:$PATH"
|
||||
|
||||
################################################################
|
||||
# LEGACY #
|
||||
################################################################
|
||||
# export EDITOR="/usr/local/bin/subl -w"
|
||||
12
tasks.todo
Normal file
12
tasks.todo
Normal file
@@ -0,0 +1,12 @@
|
||||
Tasks:
|
||||
☐ Create initial folder layout @started(21-02-28 23:29)
|
||||
✔ Create test playbook with a task @done(21-03-01 00:16)
|
||||
✔ Document creating a hosts file, and an `ansible.cfg` to create an inventory @done(21-03-01 00:07)
|
||||
<https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html>
|
||||
Alternative to using an `ansible.cfg` is using the flag `-i hosts`
|
||||
Hosts file can contain `ansible_user` and `ansible_ssh_pass` under a `vars` header
|
||||
✔ Test a connection with `ansible all -m ping` @done(21-03-01 00:08)
|
||||
☐ Document commands
|
||||
Run a playbook with `ansible-playbook -b test.yml`
|
||||
If using vault do `--ask-vault-pass`
|
||||
Point to an inventory with `-i hosts`
|
||||
Reference in New Issue
Block a user