diff --git a/Ansible/facts/dotfiles.fact b/Ansible/facts/dotfiles.fact new file mode 100755 index 0000000..78714dc --- /dev/null +++ b/Ansible/facts/dotfiles.fact @@ -0,0 +1,4 @@ +#!/usr/bin/env zsh + +dotfiles_root=$(git rev-parse --show-toplevel) +echo "{ \"path\": \"${dotfiles_root}\" }" diff --git a/Ansible/inventory.yml b/Ansible/inventory.yml new file mode 100644 index 0000000..d9c3146 --- /dev/null +++ b/Ansible/inventory.yml @@ -0,0 +1,2 @@ +all: + localhost: diff --git a/Ansible/play-setup.yml b/Ansible/play-setup.yml new file mode 100644 index 0000000..d74b0a7 --- /dev/null +++ b/Ansible/play-setup.yml @@ -0,0 +1,11 @@ +--- +- name: Set up dotfiles + hosts: localhost + connection: local + module_defaults: + ansible.builtin.setup: + fact_path: "./facts" + tasks: + - name: Include eryn role + ansible.builtin.include_role: + name: eryn diff --git a/Ansible/roles/eryn/tasks/main.yml b/Ansible/roles/eryn/tasks/main.yml new file mode 100644 index 0000000..fedd6b6 --- /dev/null +++ b/Ansible/roles/eryn/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: Configure ZSH + import_tasks: zsh.yml diff --git a/Ansible/roles/eryn/tasks/symlink_dotfile.yml b/Ansible/roles/eryn/tasks/symlink_dotfile.yml new file mode 100644 index 0000000..1eb89a5 --- /dev/null +++ b/Ansible/roles/eryn/tasks/symlink_dotfile.yml @@ -0,0 +1,8 @@ +--- +- name: "Symlink {{ dotfile_src }}" + ansible.builtin.file: + src: "{{ ansible_local.dotfiles.path }}/{{ dotfile_src }}" + dest: "~/.{{ dotfile_dest | default(dotfile_src) }}" + owner: "{{ ansible_user_id }}" + mode: 0644 + state: link diff --git a/Ansible/roles/eryn/tasks/zsh.yml b/Ansible/roles/eryn/tasks/zsh.yml new file mode 100644 index 0000000..527411b --- /dev/null +++ b/Ansible/roles/eryn/tasks/zsh.yml @@ -0,0 +1,34 @@ +--- +- name: "zsh : Set user shell" + ansible.builtin.user: + name: "{{ ansible_user_id }}" + shell: /bin/zsh + state: present + +- name: "zsh : Symlink startup files" + ansible.builtin.include_tasks: symlink_dotfile.yml + vars: + dotfile_src: "{{ item.src | default(item) }}" + dotfile_dest: "{{ item.dest | default(item) }}" + loop: + - zshenv + - zshrc + - zprofile + +- name: "zsh : Install user functions" + block: + - name: "zsh : Create zsh directory" + ansible.builtin.file: + path: "{{ _zsh_dir }}" + owner: "{{ ansible_user_id }}" + mode: 0755 + state: directory + + - name: "zsh : Symlink functions directory" + ansible.builtin.include_tasks: symlink_dotfile.yml + vars: + dotfile_src: "{{ item }}" + loop: + - zsh/func + vars: + _zsh_dir: "~/.zsh"