diff options
-rw-r--r-- | roles/_workstation/dotfiles.yml | 27 | ||||
-rw-r--r-- | roles/_workstation/dotfiles/defaults/main.yml | 4 | ||||
-rw-r--r-- | roles/_workstation/dotfiles/tasks/main.yml | 27 | ||||
-rw-r--r-- | site.workstation.yml | 5 |
4 files changed, 63 insertions, 0 deletions
diff --git a/roles/_workstation/dotfiles.yml b/roles/_workstation/dotfiles.yml new file mode 100644 index 0000000..90b9f44 --- /dev/null +++ b/roles/_workstation/dotfiles.yml @@ -0,0 +1,27 @@ +- name: install yadm + ansible.builtin.package: + name: yadm + state: present + +- name: retrieve yadm path # noqa no-changed-when command-instead-of-shell + ansible.builtin.shell: yes n | yadm clone "{{ workstation_dotfiles_repo }}" + register: workstation_dotfiles_clone_result + changed_when: + - workstation_dotfiles_clone_result.rc != 0 + - "'Git repo already exists' not in + workstation_dotfiles_clone_result.stderr" + failed_when: + - workstation_dotfiles_clone_result.rc != 0 + - "'Git repo already exists' not in + workstation_dotfiles_clone_result.stderr" + +- name: check that yadm bootstrap script exists + ansible.builtin.stat: + path: "/home/{{ workstation_user }}/.config/yadm/bootstrap" + register: workstation_dotfiles_bootstrap_result + +- name: execute yadm bootstrap + ansible.builtin.command: yadm bootstrap + when: + - workstation_dotfiles_bootstrap_result.stat.exists + - workstation_dotfiles_bootstrap_result.stat.executable diff --git a/roles/_workstation/dotfiles/defaults/main.yml b/roles/_workstation/dotfiles/defaults/main.yml new file mode 100644 index 0000000..fdf9e39 --- /dev/null +++ b/roles/_workstation/dotfiles/defaults/main.yml @@ -0,0 +1,4 @@ +--- + +dotfiles_repo_url: ssh://git-internal@rgoncalves.se:71/~/_/dots +dotfiles_workstation_user: null diff --git a/roles/_workstation/dotfiles/tasks/main.yml b/roles/_workstation/dotfiles/tasks/main.yml new file mode 100644 index 0000000..4b11e3c --- /dev/null +++ b/roles/_workstation/dotfiles/tasks/main.yml @@ -0,0 +1,27 @@ +--- + +- name: install yadm + ansible.builtin.package: + name: yadm + state: present + +- name: clone repository + ansible.builtin.shell: yes n | yadm clone "{{ dotfiles_repo_url }}" + register: dotfiles_clone_result + changed_when: + - dotfiles_clone_result.rc != 0 + - "'Git repo already exists' not in dotfiles_clone_result.stderr" + failed_when: + - dotfiles_clone_result.rc != 0 + - "'Git repo already exists' not in dotfiles_clone_result.stderr" + +- name: check that yadm bootstrap script exists + ansible.builtin.stat: + path: "/home/{{ dotfiles_workstation_user }}/.config/yadm/bootstrap" + register: dotfiles_bootstrap_result + +- name: execute yadm bootstrap + ansible.builtin.command: yadm bootstrap + when: + - dotfiles_bootstrap_result.stat.exists + - dotfiles_bootstrap_result.stat.executable diff --git a/site.workstation.yml b/site.workstation.yml index 1e618c3..37118a2 100644 --- a/site.workstation.yml +++ b/site.workstation.yml @@ -7,6 +7,7 @@ basegroups_workstation_user: "{{_workstation_user }}" doas_workstation_user: "{{ _workstation_user }}" dockerd_workstation_user: "{{ _workstation_user }}" + dotfiles_workstation_user: "{{ _workstation_user }}" libvirt_workstation_user: "{{ _workstation_user }}" pipewire_workstation_user: "{{ _workstation_user }}" shell_workstation_user: "{{ _workstation_user }}" @@ -63,3 +64,7 @@ when: ansible_distribution in ["OpenBSD"] - role: _workstation/kernel when: ansible_distribution in ["OpenBSD"] + + - role: _workstation/dotfiles + become: true + become_user: "{{ dotfiles_workstation_user }}" |