first commit
This commit is contained in:
34
tasks/main.yml
Normal file
34
tasks/main.yml
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
# Make sure zsh is installed and set to the user's default shell.
|
||||
- name: "OMZ | include zsh.yml tasks."
|
||||
include_tasks: "zsh.yml"
|
||||
tags:
|
||||
- "zsh"
|
||||
- "configure"
|
||||
- "configurezsh"
|
||||
|
||||
# Install oh-my-zsh.
|
||||
- name: "OMZ | include oh-my-zsh.yml tasks."
|
||||
include_tasks: oh-my-zsh-install.yml
|
||||
tags:
|
||||
- "oh-my-zsh"
|
||||
- "install"
|
||||
- "installohmyzsh"
|
||||
|
||||
# Configure oh-my-zsh with a custom .zshrc template if omz_zshrc_create
|
||||
# is set to 'true'.
|
||||
- name: "OMZ | include oh-my-zsh-zshrc.yml tasks."
|
||||
include_tasks: oh-my-zsh-zshrc.yml
|
||||
tags:
|
||||
- "oh-my-zsh"
|
||||
- "configure"
|
||||
- "configureohmyzsh"
|
||||
|
||||
# Finally, add exports etc to .zshrc /last/ (i.e. so they get added to whaterver
|
||||
# .zshrc exists.
|
||||
- name: "OMZ | include zsh-zshrc.yml tasks."
|
||||
include_tasks: zsh-zshrc.yml
|
||||
tags:
|
||||
- "zsh"
|
||||
- "configure"
|
||||
- "configurezsh"
|
21
tasks/oh-my-zsh-install.yml
Normal file
21
tasks/oh-my-zsh-install.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: "OMZ | establish install location."
|
||||
set_fact:
|
||||
omz_install_path: "/{{ omz_user_home_dir }}/{{ omz_user.name }}/{{ omz_install_directory }}"
|
||||
|
||||
- name: "OMZ | clone Oh My ZSH repo for user."
|
||||
git:
|
||||
repo: "{{ omz_git_repository }}"
|
||||
dest: "{{ omz_install_path }}"
|
||||
update: "true"
|
||||
accept_hostkey: "true"
|
||||
version: "master"
|
||||
register: "omz_clone"
|
||||
|
||||
- name: "OMZ | set ownership on newly cloned repository."
|
||||
file:
|
||||
path: "{{ omz_install_path }}"
|
||||
owner: "{{ omz_user.name }}"
|
||||
group: "{{ omz_user.group }}"
|
||||
recurse: "true"
|
||||
when: "omz_clone is changed"
|
14
tasks/oh-my-zsh-zshrc.yml
Normal file
14
tasks/oh-my-zsh-zshrc.yml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: "OMZ | derive user .zshrc path."
|
||||
set_fact:
|
||||
omz_user_zshrc_path: "/{{ omz_user_home_dir }}/{{ omz_user.name }}/.zshrc"
|
||||
|
||||
- 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 }}"
|
||||
backup: "{{ omz_zshrc_backup }}"
|
||||
force: "{{ omz_zshrc_force }}"
|
||||
when: "omz_zshrc_create"
|
14
tasks/zsh-zshrc.yml
Normal file
14
tasks/zsh-zshrc.yml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
# Note that we assume this file exists! lineinfile will fail if the file is
|
||||
# not present.
|
||||
- name: "OMZ | export vars to .zshrc if required."
|
||||
blockinfile:
|
||||
dest: "{{ omz_user_zshrc_path }}"
|
||||
block: "{{ omz_user.settings }}"
|
||||
backup: "{{ omz_zshrc_backup }}"
|
||||
when:
|
||||
- "omz_user.settings is defined"
|
||||
# Don't flag this line for checking if the value is empty--checking for an
|
||||
# empty value makes perfect sense.
|
||||
- "omz_user.settings != ''" # noqa 602
|
||||
- "not omz_zshrc_create"
|
32
tasks/zsh.yml
Normal file
32
tasks/zsh.yml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
- name: "OMZ | establish home directory."
|
||||
set_fact:
|
||||
omz_user_home_dir: "{{ (ansible_system == 'Darwin') | ternary('Users', 'home') }}"
|
||||
|
||||
- name: "OMZ | ensure zsh is installed."
|
||||
block:
|
||||
- name: "OMZ | install zsh for Linux."
|
||||
package:
|
||||
name: "zsh"
|
||||
state: "present"
|
||||
when:
|
||||
- "ansible_system == 'Linux'"
|
||||
- "omz_install_zsh"
|
||||
|
||||
- name: "OMZ | install zsh for macOS."
|
||||
homebrew:
|
||||
name: "zsh"
|
||||
state: "present"
|
||||
when:
|
||||
- "ansible_system == 'Darwin'"
|
||||
- "omz_install_zsh"
|
||||
|
||||
- name: "OMZ | get zsh installed path."
|
||||
shell: "command -v zsh"
|
||||
register: omz_zsh_installed_path
|
||||
changed_when: "false"
|
||||
|
||||
- name: "OMZ | get user shell to zsh."
|
||||
user:
|
||||
name: "{{ omz_user.name }}"
|
||||
shell: "{{ omz_zsh_installed_path.stdout }}"
|
Reference in New Issue
Block a user