Ansible: another take a using Ansible to set up dotfiles

This commit is contained in:
Eryn Wells 2025-01-31 16:27:22 -08:00
parent be6b93cdde
commit 72896c3feb
6 changed files with 62 additions and 0 deletions

4
Ansible/facts/dotfiles.fact Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env zsh
dotfiles_root=$(git rev-parse --show-toplevel)
echo "{ \"path\": \"${dotfiles_root}\" }"

2
Ansible/inventory.yml Normal file
View file

@ -0,0 +1,2 @@
all:
localhost:

11
Ansible/play-setup.yml Normal file
View file

@ -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

View file

@ -0,0 +1,3 @@
---
- name: Configure ZSH
import_tasks: zsh.yml

View file

@ -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

View file

@ -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"