aboutsummaryrefslogtreecommitdiffstats
path: root/roles/common
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-11-02 13:20:53 +0100
committerbinary <me@rgoncalves.se>2020-11-02 13:20:53 +0100
commit67c0e448276e46fafd47db73dfc0031786a18dc0 (patch)
treefa7635500542cab95325907f9a0b173bf621f74f /roles/common
parent1e059c8be273e090ed27a198e1b7b7ca5c0257b3 (diff)
downloadinfrastructure-67c0e448276e46fafd47db73dfc0031786a18dc0.tar.gz
Refactor utils and hostname to common role
Diffstat (limited to 'roles/common')
-rw-r--r--roles/common/files/tmux.conf24
-rw-r--r--roles/common/files/zshrc30
-rw-r--r--roles/common/tasks/main.yml52
3 files changed, 106 insertions, 0 deletions
diff --git a/roles/common/files/tmux.conf b/roles/common/files/tmux.conf
new file mode 100644
index 0000000..2816065
--- /dev/null
+++ b/roles/common/files/tmux.conf
@@ -0,0 +1,24 @@
+# /etc/tmux.conf ~~ rgoncalves.se infrastructure
+
+# keybinds
+unbind C-b
+set -g prefix `
+bind-key n last-window
+bind-key m send-prefix
+bind-key ` last-window
+bind-key e send-prefix
+
+# options
+set -sg escape-time 0
+set -g mouse off
+set -g default-terminal "screen-256color"
+set -g status-right-length 50
+set -g status-left-length 20
+set-option -g history-limit 5000
+setw -g mode-keys vi
+
+# statusbar
+set -g status-position bottom
+set -g status-bg colour255
+set -g status-fg colour235
+
diff --git a/roles/common/files/zshrc b/roles/common/files/zshrc
new file mode 100644
index 0000000..7635057
--- /dev/null
+++ b/roles/common/files/zshrc
@@ -0,0 +1,30 @@
+# /etc/zshrc configuration ~~ rgoncalves.se infrastructure
+
+# export environment variables
+export TERM=xterm-256color
+export LANG=en_US.UTF-8
+
+# zsh options
+CASE_SENSITIVE="false"
+
+# autocomplete
+autoload -U history-search-end
+zle -N history-beginning-search-backward-end history-search-end
+zle -N history-beginning-search-forward-end history-search-end
+bindkey "^[[A" history-beginning-search-backward-end
+bindkey "^[[B" history-beginning-search-forward-end
+bindkey "^[[1;5C" forward-word
+bindkey "^[[1;5D" backward-word
+bindkey "\e[3~" delete-char
+bindkey '^[[Z' reverse-menu-complete
+
+zstyle ':completion:*' completer _complete
+zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+l:|=* r:|=*'
+autoload -Uz compinit
+compinit -u
+
+# aliases
+alias cdd="cd .."
+
+# prompt
+PROMPT="%B %n@%m %~ %# %b"
diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml
new file mode 100644
index 0000000..7dbc5dd
--- /dev/null
+++ b/roles/common/tasks/main.yml
@@ -0,0 +1,52 @@
+
+# common ~~ tasks/main.yml
+
+---
+
+- name: Check installation of package "{{ item }}"
+ become: yes
+
+ package:
+ name: "{{ item }}"
+ state: present
+
+ loop:
+ - "{{ packages.zsh }}"
+ - "{{ packages.curl }}"
+ - "{{ packages.tmux }}"
+ - "{{ packages.wget }}"
+ - "{{ packages.figlet }}"
+ - "{{ packages.neovim }}"
+
+ ignore_errors: yes
+
+
+- name: Copy zshrc configuration file
+ copy:
+ src: zshrc
+ dest: /etc/zshrc
+ owner: root
+ group: "{{ group.root }}"
+ mode: 0644
+
+- name: Copy tmux configuration file
+ copy:
+ src: tmux.conf
+ dest: /etc/tmux.conf
+ owner: root
+ group: "{{ group.root }}"
+ mode: 0644
+
+- name: Synchronize host hostname with config hostname
+ hostname:
+ name: "{{ inventory_hostname }}"
+
+- name: Retrieve all valid users for zsh
+ shell: awk -F ":" '{ if($3 > 999 && $3 < 16000) { print $1 }}' /etc/passwd
+ register: valid_users_shell
+
+- name: Change shell for all valid users to zsh
+ user:
+ name: "{{ item }}"
+ shell: "{{ path_zsh_bin }}"
+ loop: "{{ valid_users_shell.stdout_lines }}"
remember that computers suck.