WIP: Harmonizing the 2 roles i use into 1 big working
This commit is contained in:
@ -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."
|
||||
git:
|
||||
repo: "{{ omz_git_repository }}"
|
||||
dest: "{{ omz_install_path }}"
|
||||
dest: "{{ item.ansible_facts.user_home }}/{{ omz_install_directory }}"
|
||||
update: "true"
|
||||
accept_hostkey: "true"
|
||||
version: "master"
|
||||
register: "omz_clone"
|
||||
with_items: "{{ paths.results }}"
|
||||
|
||||
- name: "OMZ | set ownership on newly cloned repository."
|
||||
file:
|
||||
path: "{{ omz_install_path }}"
|
||||
owner: "{{ omz_user.name }}"
|
||||
group: "{{ omz_user.group }}"
|
||||
path: "{{ item.ansible_facts.user_home }}/{{ omz_install_directory }}"
|
||||
owner: "{{ item.item }}"
|
||||
group: "{{ item.item }}"
|
||||
recurse: "true"
|
||||
when: "omz_clone is changed"
|
||||
with_items: "{{ paths.results }}"
|
||||
|
@ -6,9 +6,10 @@
|
||||
- name: "OMZ | template .zshrc into place if required."
|
||||
template:
|
||||
src: "{{ omz_zshrc_template }}"
|
||||
dest: "{{ omz_user_zshrc_path }}"
|
||||
owner: "{{ omz_user.name }}"
|
||||
group: "{{ omz_user.group }}"
|
||||
dest: "{{ item.ansible_facts.user_home }}/.zshrc"
|
||||
owner: "{{ item.item }}"
|
||||
group: "{{ item.item }}"
|
||||
backup: "{{ omz_zshrc_backup }}"
|
||||
force: "{{ omz_zshrc_force }}"
|
||||
when: "omz_zshrc_create"
|
||||
with_items: "{{ paths.results }}"
|
||||
|
@ -4,13 +4,13 @@
|
||||
name: "{{ item }}"
|
||||
shell: "{{ zsh_bin_path }}"
|
||||
become: true
|
||||
loop: "{{ p10k_users }}"
|
||||
loop: "{{ zsh_users }}"
|
||||
|
||||
- name: Setup powerlevel10k
|
||||
ansible.builtin.template:
|
||||
src: "p10k-{{ p10k_style[p10k_prompt_style] }}.zsh.j2"
|
||||
dest: "{{ item['home'] }}/.p10k.zsh"
|
||||
owner: "{{ item['name'] }}"
|
||||
group: "{{ item['group'] }}"
|
||||
dest: "{{ item.ansible_facts.user_home }}/.p10k.zsh"
|
||||
owner: "{{ item.item }}"
|
||||
group: "{{ item.item }}"
|
||||
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"
|
||||
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.
|
||||
ansible.builtin.git:
|
||||
repo: "{{ p10k_repository_url }}"
|
||||
dest: "{{ item['home'] }}/{{ p10k_path[zsh_plugin] | default('~/powerlevel10k', True) }}"
|
||||
dest: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||
depth: '1'
|
||||
update: no
|
||||
version: 'master'
|
||||
loop: "{{ p10k_users_information }}"
|
||||
with_items: "{{ paths.results }}"
|
||||
|
||||
- name: Setup powerlevel10k file permissions.
|
||||
- name: Setup powerlevel10k file permissions
|
||||
ansible.builtin.file:
|
||||
path: "{{ item['home'] }}/{{ p10k_path[zsh_plugin] | default('~/powerlevel10k', True) }}"
|
||||
owner: "{{ item['name'] }}"
|
||||
group: "{{ item['group'] }}"
|
||||
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||
owner: "{{ item.item }}"
|
||||
group: "{{ item.item }}"
|
||||
recurse: yes
|
||||
loop: "{{ p10k_users_information }}"
|
||||
with_items: "{{ paths.results }}"
|
||||
|
||||
- name: Add powerlevel10k to zsh plugin
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ item['home'] }}/{{ p10k_zshrc_config[zsh_plugin]['zsh_file'] }}"
|
||||
regexp: "{{ p10k_zshrc_config[zsh_plugin]['regexp'] }}"
|
||||
line: "{{ p10k_zshrc_config[zsh_plugin]['line'] }}"
|
||||
owner: "{{ item['name'] }}"
|
||||
group: "{{ item['group'] }}"
|
||||
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||
regexp: ".*powerlevel10k.*"
|
||||
line: "source ~/{{ p10k_path }}/powerlevel10k.zsh-theme"
|
||||
owner: "{{ item.item }}"
|
||||
group: "{{ item.item }}"
|
||||
mode: '0644'
|
||||
create: yes
|
||||
loop: "{{ p10k_users_information }}"
|
||||
with_items: "{{ paths.results }}"
|
||||
|
||||
- name: Enable powerlevel10 instant prompt
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ item['home'] }}/{{ p10k_zshrc_config[zsh_plugin]['zsh_file'] }}"
|
||||
owner: "{{ item['name'] }}"
|
||||
group: "{{ item['group'] }}"
|
||||
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||
owner: "{{ item.item }}"
|
||||
group: "{{ item.item }}"
|
||||
block: |
|
||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
@ -73,16 +60,16 @@
|
||||
insertbefore: BOF
|
||||
marker_begin: "BEGIN P10K INSTANT PROMPT"
|
||||
marker_end: "END P10K INSTANT PROMPT"
|
||||
loop: "{{ p10k_users_information }}"
|
||||
with_items: "{{ paths.results }}"
|
||||
|
||||
- name: Enable powerlevel10k config file
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ item['home'] }}/{{ p10k_zshrc_config[zsh_plugin]['zsh_file'] }}"
|
||||
owner: "{{ item['name'] }}"
|
||||
group: "{{ item['group'] }}"
|
||||
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
|
||||
owner: "{{ item.item }}"
|
||||
group: "{{ item.item }}"
|
||||
block: |
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||
insertafter: EOF
|
||||
marker_begin: "BEGIN P10K CONFIG FILE"
|
||||
marker_end: "END P10K CONFIG FILE"
|
||||
loop: "{{ p10k_users_information }}"
|
||||
with_items: "{{ paths.results }}"
|
Reference in New Issue
Block a user