Skip to content

Commit

Permalink
setup dotfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
avafloww committed May 11, 2023
1 parent bf55f66 commit 5f96e0f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
inventory=inventory.yml
remote_user=ava
stdout_callback=yaml
vault_password_file=util/op-get-password.sh

[privilege_escalation]
become=True
Expand Down
1 change: 1 addition & 0 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ terraform_vars:
- libvirt_host

libvirt_host: krile # temporary hack (famous last words)
dotfiles_github_user: avafloww
31 changes: 31 additions & 0 deletions roles/common/tasks/dotfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- name: Setup dotfiles
become: false
block:
- name: Set shell to /bin/zsh
user:
name: '{{ ansible_user }}'
shell: /bin/zsh
when: ansible_user != 'root'

- name: Check if chezmoi is installed
stat:
path: ~/bin/chezmoi
register: chezmoi_installed
changed_when: chezmoi_installed.stat.exists == false

- name: Install chezmoi
shell: sh -c "$(curl -fsLS get.chezmoi.io)"
when: chezmoi_installed.changed

- name: Setup dotfiles
shell: ~/bin/chezmoi init --apply {{ dotfiles_github_user }}
when: chezmoi_installed.changed

- name: Update dotfiles
shell: ~/bin/chezmoi update
when: not chezmoi_installed.changed

- name: Execute zsh to finalize dotfiles setup
shell: zsh -i -l -c 'exit 0'
register: zsh_exec
failed_when: zsh_exec.rc != 0
1 change: 1 addition & 0 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- import_tasks: debian.yml
when: ansible_os_family == 'Debian'
- import_tasks: dotfiles.yml

0 comments on commit 5f96e0f

Please sign in to comment.