Merge branch 'zsh'
This commit is contained in:
commit
322c5bc711
@ -1,2 +1,6 @@
|
||||
[defaults]
|
||||
pipelining = True
|
||||
# Need to allow world readable tmpfiles for switching to an
|
||||
# unprivileged user other than the connection user because the setfacl
|
||||
# command fails on ZFS on FreeBSD.
|
||||
allow_world_readable_tmpfiles = True
|
||||
|
@ -1,7 +1,6 @@
|
||||
os_flavor: "linux"
|
||||
users:
|
||||
talexander:
|
||||
per_user: true
|
||||
initialize: true
|
||||
uid: 11235
|
||||
gid: 1000
|
||||
|
@ -5,3 +5,4 @@
|
||||
- sudo
|
||||
- users
|
||||
- zrepl
|
||||
- zsh
|
||||
|
33
ansible/roles/per_user/tasks/main.yaml
Normal file
33
ansible/roles/per_user/tasks/main.yaml
Normal file
@ -0,0 +1,33 @@
|
||||
- name: account $HOME
|
||||
shell: "echo $HOME"
|
||||
register: account_homedir
|
||||
changed_when: false
|
||||
check_mode: no
|
||||
|
||||
- name: account name
|
||||
command: id -un
|
||||
register: account_name
|
||||
changed_when: false
|
||||
check_mode: no
|
||||
|
||||
- name: group name
|
||||
command: id -gn
|
||||
register: group_name
|
||||
changed_when: false
|
||||
check_mode: no
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ account_homedir.stdout }}/{{ item }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
owner: "{{ account_name.stdout }}"
|
||||
group: "{{ group_name.stdout }}"
|
||||
loop:
|
||||
- .config/ansible_deploy
|
||||
|
||||
- import_tasks: tasks/peruser_freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/peruser_linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
0
ansible/roles/per_user/tasks/peruser_freebsd.yaml
Normal file
0
ansible/roles/per_user/tasks/peruser_freebsd.yaml
Normal file
9
ansible/roles/per_user/tasks/peruser_linux.yaml
Normal file
9
ansible/roles/per_user/tasks/peruser_linux.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ account_homedir.stdout }}/{{ item }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
owner: "{{ account_name.stdout }}"
|
||||
group: "{{ group_name.stdout }}"
|
||||
loop:
|
||||
- .config/systemd/user # user unit files
|
@ -4,8 +4,8 @@
|
||||
- sudo
|
||||
state: present
|
||||
|
||||
- include: tasks/freebsd.yaml
|
||||
- import_tasks: tasks/freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- include: tasks/linux.yaml
|
||||
- import_tasks: tasks/linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
||||
|
@ -1,6 +1,5 @@
|
||||
users:
|
||||
talexander:
|
||||
per_user: true
|
||||
initialize: true
|
||||
uid: 11235
|
||||
gid: 11235
|
||||
|
@ -24,8 +24,8 @@
|
||||
validate: "zrepl configcheck --config %s"
|
||||
notify: "restart zrepl"
|
||||
|
||||
- include: tasks/freebsd.yaml
|
||||
- import_tasks: tasks/freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- include: tasks/linux.yaml
|
||||
- import_tasks: tasks/linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
||||
|
@ -1,2 +1,2 @@
|
||||
- include: tasks/common.yaml
|
||||
- import_tasks: tasks/common.yaml
|
||||
when: zfs_snapshot_datasets is defined
|
||||
|
1
ansible/roles/zsh/defaults/main.yaml
Normal file
1
ansible/roles/zsh/defaults/main.yaml
Normal file
@ -0,0 +1 @@
|
||||
additional_zshrc_files: []
|
47
ansible/roles/zsh/files/zshrc
Normal file
47
ansible/roles/zsh/files/zshrc
Normal file
@ -0,0 +1,47 @@
|
||||
# Lines configured by zsh-newuser-install
|
||||
HISTFILE=~/.zhistory
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=100000
|
||||
setopt appendhistory notify
|
||||
unsetopt beep
|
||||
bindkey -e
|
||||
# End of lines configured by zsh-newuser-install
|
||||
# The following lines were added by compinstall
|
||||
#
|
||||
|
||||
# Use menu complete immediately instead of after the first tab
|
||||
setopt MENU_COMPLETE
|
||||
|
||||
zstyle :compinstall filename "$HOME/.zshrc"
|
||||
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
# End of lines added by compinstall
|
||||
|
||||
# Enable the 2d menu for tab completion
|
||||
zstyle ':completion:*' menu select
|
||||
|
||||
autoload colors zsh/terminfo
|
||||
if [[ "$terminfo[colors]" -ge 8 ]]; then
|
||||
colors
|
||||
fi
|
||||
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
|
||||
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
|
||||
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
|
||||
(( count = $count + 1 ))
|
||||
done
|
||||
PR_NO_COLOR="%{$terminfo[sgr0]%}"
|
||||
PS1="[$PR_BLUE%n$PR_WHITE@$PR_GREEN%U%m%u$PR_NO_COLOR:$PR_RED%2c$PR_NO_COLOR]%(!.#.$) "
|
||||
|
||||
source $HOME/.config/ansible_deploy/zsh-histdb/sqlite-history.zsh
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
source $HOME/.config/ansible_deploy/zsh-histdb/histdb-interactive.zsh
|
||||
bindkey '^r' _histdb-isearch
|
||||
|
||||
# TODO: Consider moving to /etc/profile.d
|
||||
while read file; do
|
||||
if [ -e "$file" ]; then
|
||||
source "$file"
|
||||
fi
|
||||
done <<<"$(find $HOME/.config/ansible_deploy/zshrc -maxdepth 1 -type f -name '*.zsh' -print)"
|
4
ansible/roles/zsh/handlers/main.yaml
Normal file
4
ansible/roles/zsh/handlers/main.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
- name: restart zrepl
|
||||
service:
|
||||
name: zrepl
|
||||
state: restarted
|
2
ansible/roles/zsh/meta/main.yaml
Normal file
2
ansible/roles/zsh/meta/main.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- users
|
17
ansible/roles/zsh/tasks/freebsd.yaml
Normal file
17
ansible/roles/zsh/tasks/freebsd.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
- name: Install packages
|
||||
package:
|
||||
name:
|
||||
- zsh
|
||||
- sqlite3
|
||||
- git
|
||||
- py39-jmespath # Needed on machine running ansible for json_query
|
||||
state: present
|
||||
|
||||
- include_tasks:
|
||||
file: tasks/peruser.yaml
|
||||
apply:
|
||||
become: yes
|
||||
become_user: "{{ initialize_user }}"
|
||||
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
|
||||
loop_control:
|
||||
loop_var: initialize_user
|
17
ansible/roles/zsh/tasks/linux.yaml
Normal file
17
ansible/roles/zsh/tasks/linux.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
- name: Install packages
|
||||
package:
|
||||
name:
|
||||
- zsh
|
||||
- sqlite
|
||||
- git
|
||||
- python-jmespath # Needed on machine running ansible for json_query
|
||||
state: present
|
||||
|
||||
- include_tasks:
|
||||
file: tasks/peruser.yaml
|
||||
apply:
|
||||
become: yes
|
||||
become_user: "{{ initialize_user }}"
|
||||
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
|
||||
loop_control:
|
||||
loop_var: initialize_user
|
5
ansible/roles/zsh/tasks/main.yaml
Normal file
5
ansible/roles/zsh/tasks/main.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
- import_tasks: tasks/freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
34
ansible/roles/zsh/tasks/peruser.yaml
Normal file
34
ansible/roles/zsh/tasks/peruser.yaml
Normal file
@ -0,0 +1,34 @@
|
||||
- include_role:
|
||||
name: per_user
|
||||
|
||||
- name: clone zsh-histdb repo
|
||||
git:
|
||||
repo: "https://github.com/larkery/zsh-histdb.git"
|
||||
dest: "{{ account_homedir.stdout }}/.config/ansible_deploy/zsh-histdb"
|
||||
version: "6c7159be9de8586ac2f19d179d562cf5d10a2bab"
|
||||
diff: false
|
||||
|
||||
- name: Create zshrc additional imports directory
|
||||
file:
|
||||
name: "{{ account_homedir.stdout }}/.config/ansible_deploy/zshrc"
|
||||
state: directory
|
||||
mode: 0700
|
||||
owner: "{{ account_name.stdout }}"
|
||||
group: "{{ group_name.stdout }}"
|
||||
|
||||
- name: Configure zshrc additional imports
|
||||
copy:
|
||||
src: "files/zshrc_{{ item }}"
|
||||
dest: "{{ account_homedir.stdout }}/.config/ansible_deploy/zshrc/{{ item }}.zsh"
|
||||
mode: 0600
|
||||
owner: "{{ account_name.stdout }}"
|
||||
group: "{{ group_name.stdout }}"
|
||||
loop: "{{ additional_zshrc_files }}"
|
||||
|
||||
- name: Configure zshrc
|
||||
copy:
|
||||
src: files/zshrc
|
||||
dest: "{{ account_homedir.stdout }}/.zshrc"
|
||||
mode: 0600
|
||||
owner: "{{ account_name.stdout }}"
|
||||
group: "{{ group_name.stdout }}"
|
Loading…
x
Reference in New Issue
Block a user