Ansible: another take a using Ansible to set up dotfiles
This commit is contained in:
parent
be6b93cdde
commit
72896c3feb
6 changed files with 62 additions and 0 deletions
4
Ansible/facts/dotfiles.fact
Executable file
4
Ansible/facts/dotfiles.fact
Executable 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
2
Ansible/inventory.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
all:
|
||||||
|
localhost:
|
11
Ansible/play-setup.yml
Normal file
11
Ansible/play-setup.yml
Normal 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
|
3
Ansible/roles/eryn/tasks/main.yml
Normal file
3
Ansible/roles/eryn/tasks/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
- name: Configure ZSH
|
||||||
|
import_tasks: zsh.yml
|
8
Ansible/roles/eryn/tasks/symlink_dotfile.yml
Normal file
8
Ansible/roles/eryn/tasks/symlink_dotfile.yml
Normal 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
|
34
Ansible/roles/eryn/tasks/zsh.yml
Normal file
34
Ansible/roles/eryn/tasks/zsh.yml
Normal 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"
|
Loading…
Add table
Add a link
Reference in a new issue