WIP: Harmonizing the 2 roles i use into 1 big working
This commit is contained in:
@ -3,7 +3,8 @@
|
|||||||
omz_install_zsh: false
|
omz_install_zsh: false
|
||||||
|
|
||||||
# User vars.
|
# User vars.
|
||||||
omz_user: []
|
zsh_users:
|
||||||
|
- "{{ ansible_user_id }}"
|
||||||
|
|
||||||
# Oh My ZSH vars.
|
# Oh My ZSH vars.
|
||||||
omz_git_repository: "https://github.com/robbyrussell/oh-my-zsh.git"
|
omz_git_repository: "https://github.com/robbyrussell/oh-my-zsh.git"
|
||||||
@ -33,14 +34,9 @@ omz_plugins: []
|
|||||||
# Powerlevel10k Git repository url
|
# Powerlevel10k Git repository url
|
||||||
p10k_repository_url: 'https://github.com/romkatv/powerlevel10k.git'
|
p10k_repository_url: 'https://github.com/romkatv/powerlevel10k.git'
|
||||||
|
|
||||||
# Install p10k for the following linux users
|
|
||||||
# Default: the linux user running Ansible
|
|
||||||
p10k_users:
|
|
||||||
- "{{ ansible_user_id }}"
|
|
||||||
|
|
||||||
# Zsh plugin used, zsh, ohmyzsh, prezto, Zim, etc..
|
# Zsh plugin used, zsh, ohmyzsh, prezto, Zim, etc..
|
||||||
# All plugin names can be found here https://github.com/romkatv/powerlevel10k#installation
|
# All plugin names can be found here https://github.com/romkatv/powerlevel10k#installation
|
||||||
zsh_plugin: zsh
|
zsh_plugin: ohmyzsh
|
||||||
|
|
||||||
# Setup p10k theme to use
|
# Setup p10k theme to use
|
||||||
# Valid values: lean, classic, rainbow, pure
|
# Valid values: lean, classic, rainbow, pure
|
||||||
|
@ -1,26 +1,19 @@
|
|||||||
---
|
---
|
||||||
- name: "OMZ | establish install location."
|
|
||||||
set_fact:
|
|
||||||
omz_install_path: >
|
|
||||||
{% if omz_user.name == 'root' %}
|
|
||||||
/root/.{{ omz_install_directory }}
|
|
||||||
{% else %}
|
|
||||||
/home/{{ omz_user.name }}/{{ omz_install_directory }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
- name: "OMZ | clone Oh My ZSH repo for user."
|
- name: "OMZ | clone Oh My ZSH repo for user."
|
||||||
git:
|
git:
|
||||||
repo: "{{ omz_git_repository }}"
|
repo: "{{ omz_git_repository }}"
|
||||||
dest: "{{ omz_install_path }}"
|
dest: "{{ item.ansible_facts.user_home }}/{{ omz_install_directory }}"
|
||||||
update: "true"
|
update: "true"
|
||||||
accept_hostkey: "true"
|
accept_hostkey: "true"
|
||||||
version: "master"
|
version: "master"
|
||||||
register: "omz_clone"
|
register: "omz_clone"
|
||||||
|
with_items: "{{ paths.results }}"
|
||||||
|
|
||||||
- name: "OMZ | set ownership on newly cloned repository."
|
- name: "OMZ | set ownership on newly cloned repository."
|
||||||
file:
|
file:
|
||||||
path: "{{ omz_install_path }}"
|
path: "{{ item.ansible_facts.user_home }}/{{ omz_install_directory }}"
|
||||||
owner: "{{ omz_user.name }}"
|
owner: "{{ item.item }}"
|
||||||
group: "{{ omz_user.group }}"
|
group: "{{ item.item }}"
|
||||||
recurse: "true"
|
recurse: "true"
|
||||||
when: "omz_clone is changed"
|
when: "omz_clone is changed"
|
||||||
|
with_items: "{{ paths.results }}"
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
- name: "OMZ | template .zshrc into place if required."
|
- name: "OMZ | template .zshrc into place if required."
|
||||||
template:
|
template:
|
||||||
src: "{{ omz_zshrc_template }}"
|
src: "{{ omz_zshrc_template }}"
|
||||||
dest: "{{ omz_user_zshrc_path }}"
|
dest: "{{ item.ansible_facts.user_home }}/.zshrc"
|
||||||
owner: "{{ omz_user.name }}"
|
owner: "{{ item.item }}"
|
||||||
group: "{{ omz_user.group }}"
|
group: "{{ item.item }}"
|
||||||
backup: "{{ omz_zshrc_backup }}"
|
backup: "{{ omz_zshrc_backup }}"
|
||||||
force: "{{ omz_zshrc_force }}"
|
force: "{{ omz_zshrc_force }}"
|
||||||
when: "omz_zshrc_create"
|
when: "omz_zshrc_create"
|
||||||
|
with_items: "{{ paths.results }}"
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
shell: "{{ zsh_bin_path }}"
|
shell: "{{ zsh_bin_path }}"
|
||||||
become: true
|
become: true
|
||||||
loop: "{{ p10k_users }}"
|
loop: "{{ zsh_users }}"
|
||||||
|
|
||||||
- name: Setup powerlevel10k
|
- name: Setup powerlevel10k
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "p10k-{{ p10k_style[p10k_prompt_style] }}.zsh.j2"
|
src: "p10k-{{ p10k_style[p10k_prompt_style] }}.zsh.j2"
|
||||||
dest: "{{ item['home'] }}/.p10k.zsh"
|
dest: "{{ item.ansible_facts.user_home }}/.p10k.zsh"
|
||||||
owner: "{{ item['name'] }}"
|
owner: "{{ item.item }}"
|
||||||
group: "{{ item['group'] }}"
|
group: "{{ item.item }}"
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
loop: "{{ p10k_users_information }}"
|
with_items: "{{ paths.results }}"
|
||||||
|
@ -20,52 +20,39 @@
|
|||||||
msg: "You are using ZSH version {{ zsh_version.stdout }}. The minimum required version for Powerlevel10k is 5.1"
|
msg: "You are using ZSH version {{ zsh_version.stdout }}. The minimum required version for Powerlevel10k is 5.1"
|
||||||
when: zsh_version.stdout|float < 5.1
|
when: zsh_version.stdout|float < 5.1
|
||||||
|
|
||||||
- name: Get users information
|
|
||||||
ansible.builtin.user:
|
|
||||||
name: "{{ item }}"
|
|
||||||
state: present
|
|
||||||
register: p10k_users_register
|
|
||||||
loop: "{{ p10k_users }}"
|
|
||||||
|
|
||||||
- name: Extract only 'name', 'home' and 'group' fields from users information
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
p10k_users_information: "{{ p10k_users_information | default([]) + [{'name': item['name'], 'home': item['home'], 'group': item['group']}] }}"
|
|
||||||
no_log: true
|
|
||||||
loop: "{{ p10k_users_register.results }}"
|
|
||||||
|
|
||||||
- name: Install powerlevel10k.
|
- name: Install powerlevel10k.
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
repo: "{{ p10k_repository_url }}"
|
repo: "{{ p10k_repository_url }}"
|
||||||
dest: "{{ item['home'] }}/{{ p10k_path[zsh_plugin] | default('~/powerlevel10k', True) }}"
|
dest: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||||
depth: '1'
|
depth: '1'
|
||||||
update: no
|
update: no
|
||||||
version: 'master'
|
version: 'master'
|
||||||
loop: "{{ p10k_users_information }}"
|
with_items: "{{ paths.results }}"
|
||||||
|
|
||||||
- name: Setup powerlevel10k file permissions.
|
- name: Setup powerlevel10k file permissions
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item['home'] }}/{{ p10k_path[zsh_plugin] | default('~/powerlevel10k', True) }}"
|
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||||
owner: "{{ item['name'] }}"
|
owner: "{{ item.item }}"
|
||||||
group: "{{ item['group'] }}"
|
group: "{{ item.item }}"
|
||||||
recurse: yes
|
recurse: yes
|
||||||
loop: "{{ p10k_users_information }}"
|
with_items: "{{ paths.results }}"
|
||||||
|
|
||||||
- name: Add powerlevel10k to zsh plugin
|
- name: Add powerlevel10k to zsh plugin
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item['home'] }}/{{ p10k_zshrc_config[zsh_plugin]['zsh_file'] }}"
|
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||||
regexp: "{{ p10k_zshrc_config[zsh_plugin]['regexp'] }}"
|
regexp: ".*powerlevel10k.*"
|
||||||
line: "{{ p10k_zshrc_config[zsh_plugin]['line'] }}"
|
line: "source ~/{{ p10k_path }}/powerlevel10k.zsh-theme"
|
||||||
owner: "{{ item['name'] }}"
|
owner: "{{ item.item }}"
|
||||||
group: "{{ item['group'] }}"
|
group: "{{ item.item }}"
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
create: yes
|
create: yes
|
||||||
loop: "{{ p10k_users_information }}"
|
with_items: "{{ paths.results }}"
|
||||||
|
|
||||||
- name: Enable powerlevel10 instant prompt
|
- name: Enable powerlevel10 instant prompt
|
||||||
ansible.builtin.blockinfile:
|
ansible.builtin.blockinfile:
|
||||||
path: "{{ item['home'] }}/{{ p10k_zshrc_config[zsh_plugin]['zsh_file'] }}"
|
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||||
owner: "{{ item['name'] }}"
|
owner: "{{ item.item }}"
|
||||||
group: "{{ item['group'] }}"
|
group: "{{ item.item }}"
|
||||||
block: |
|
block: |
|
||||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||||
@ -73,16 +60,16 @@
|
|||||||
insertbefore: BOF
|
insertbefore: BOF
|
||||||
marker_begin: "BEGIN P10K INSTANT PROMPT"
|
marker_begin: "BEGIN P10K INSTANT PROMPT"
|
||||||
marker_end: "END P10K INSTANT PROMPT"
|
marker_end: "END P10K INSTANT PROMPT"
|
||||||
loop: "{{ p10k_users_information }}"
|
with_items: "{{ paths.results }}"
|
||||||
|
|
||||||
- name: Enable powerlevel10k config file
|
- name: Enable powerlevel10k config file
|
||||||
ansible.builtin.blockinfile:
|
ansible.builtin.blockinfile:
|
||||||
path: "{{ item['home'] }}/{{ p10k_zshrc_config[zsh_plugin]['zsh_file'] }}"
|
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||||
owner: "{{ item['name'] }}"
|
owner: "{{ item.item }}"
|
||||||
group: "{{ item['group'] }}"
|
group: "{{ item.item }}"
|
||||||
block: |
|
block: |
|
||||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
marker_begin: "BEGIN P10K CONFIG FILE"
|
marker_begin: "BEGIN P10K CONFIG FILE"
|
||||||
marker_end: "END P10K CONFIG FILE"
|
marker_end: "END P10K CONFIG FILE"
|
||||||
loop: "{{ p10k_users_information }}"
|
with_items: "{{ paths.results }}"
|
@ -1,64 +1,24 @@
|
|||||||
---
|
---
|
||||||
# Global vars file for ansible-role-p10k
|
# Global vars file for ansible-role-p10k
|
||||||
|
|
||||||
|
- name: Set home location for each users
|
||||||
|
set_fact:
|
||||||
|
user_home: "{{ '/root' if item == 'root' else '/home/' + item }}"
|
||||||
|
with_items: "{{ zsh_users }}"
|
||||||
|
register: paths
|
||||||
|
|
||||||
p10k_style:
|
p10k_style:
|
||||||
lean: 'lean'
|
lean: 'lean'
|
||||||
classic: 'classic'
|
classic: 'classic'
|
||||||
rainbow: 'rainbow'
|
rainbow: 'rainbow'
|
||||||
pure: 'rainbow'
|
pure: 'rainbow'
|
||||||
|
|
||||||
p10k_path:
|
p10k_path: '.oh-my-zsh/custom/themes/powerlevel10k'
|
||||||
zsh: 'powerlevel10k'
|
|
||||||
ohmyzsh: '.oh-my-zsh/custom/themes/powerlevel10k'
|
|
||||||
prezto: 'powerlevel10k'
|
|
||||||
zim: 'powerlevel10k'
|
|
||||||
antibody: 'powerlevel10k'
|
|
||||||
antigen: 'powerlevel10k'
|
|
||||||
zplug: 'powerlevel10k'
|
|
||||||
zgen: 'powerlevel10k'
|
|
||||||
zplugin: 'powerlevel10k'
|
|
||||||
zinit: 'powerlevel10k'
|
|
||||||
|
|
||||||
p10k_zshrc_config:
|
p10k_zshrc_config:
|
||||||
zsh:
|
|
||||||
regexp: '^source '
|
|
||||||
line: 'source ~/powerlevel10k/powerlevel10k.zsh-theme'
|
|
||||||
zsh_file: .zshrc
|
|
||||||
ohmyzsh:
|
|
||||||
regexp: '^ZSH_THEME='
|
regexp: '^ZSH_THEME='
|
||||||
line: 'ZSH_THEME="powerlevel10k/powerlevel10k"'
|
line: 'ZSH_THEME="powerlevel10k/powerlevel10k"'
|
||||||
zsh_file: .zshrc
|
zsh_file: .zshrc
|
||||||
prezto:
|
|
||||||
regexp: '^zstyle :prezto:module:prompt theme'
|
|
||||||
line: 'zstyle :prezto:module:prompt theme powerlevel10k'
|
|
||||||
zsh_file: .zpreztorc
|
|
||||||
zim:
|
|
||||||
regexp: '^zmodule '
|
|
||||||
line: 'zmodule romkatv/powerlevel10k'
|
|
||||||
zsh_file: .zimrc
|
|
||||||
antibody:
|
|
||||||
regexp: '^antibody bundle '
|
|
||||||
line: 'antibody bundle romkatv/powerlevel10k'
|
|
||||||
zsh_file: .zshrc
|
|
||||||
antigen:
|
|
||||||
regexp: '^antigen theme '
|
|
||||||
line: 'antigen theme romkatv/powerlevel10k'
|
|
||||||
zsh_file: .zshrc
|
|
||||||
zplug:
|
|
||||||
regexp: '^zplug '
|
|
||||||
line: 'zplug romkatv/powerlevel10k, as:theme, depth:1'
|
|
||||||
zsh_file: .zshrc
|
|
||||||
zgen:
|
|
||||||
regexp: '^zgen load '
|
|
||||||
line: 'zgen load romkatv/powerlevel10k powerlevel10k'
|
|
||||||
zsh_file: .zshrc
|
|
||||||
zplugin:
|
|
||||||
regexp: '^zplugin ice depth=1; zplugin light'
|
|
||||||
line: 'zplugin ice depth=1; zplugin light romkatv/powerlevel10k'
|
|
||||||
zsh_file: .zshrc
|
|
||||||
zinit:
|
|
||||||
regexp: '^zinit ice depth=1; zinit light'
|
|
||||||
line: 'zinit ice depth=1; zinit light romkatv/powerlevel10k'
|
|
||||||
zsh_file: .zshrc
|
|
||||||
|
|
||||||
time_config:
|
time_config:
|
||||||
no:
|
no:
|
||||||
|
Reference in New Issue
Block a user