From 20b2d74c404102740b63a0efc723f1ad60073cc9 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Mon, 3 Nov 2025 23:05:10 +0100 Subject: Add dotfiles setup role w/testing --- configure.yml | 3 +++ group_vars/all.yml | Bin 2273 -> 2433 bytes group_vars/all.yml.example | 6 ++++++ molecule/archlinux/converge.yml | 1 + molecule/debian/converge.yml | 1 + molecule/raspberrypi/converge.yml | 1 + molecule/ubuntu/converge.yml | 1 + roles/dotfiles/meta/argument_specs.yml | 14 ++++++++++++++ roles/dotfiles/meta/main.yml | 20 ++++++++++++++++++++ roles/dotfiles/tasks/main.yml | 15 +++++++++++++++ roles/stow/meta/argument_specs.yml | 6 ++++++ roles/stow/meta/main.yml | 18 ++++++++++++++++++ roles/stow/tasks/main.yml | 6 ++++++ 13 files changed, 92 insertions(+) create mode 100644 roles/dotfiles/meta/argument_specs.yml create mode 100644 roles/dotfiles/meta/main.yml create mode 100644 roles/dotfiles/tasks/main.yml create mode 100644 roles/stow/meta/argument_specs.yml create mode 100644 roles/stow/meta/main.yml create mode 100644 roles/stow/tasks/main.yml diff --git a/configure.yml b/configure.yml index fb39af96..78d1569e 100644 --- a/configure.yml +++ b/configure.yml @@ -16,6 +16,7 @@ - role: "ansible" - role: "rsync" - role: "gpg" + - role: "dotfiles" - name: "Ubuntu configure" gather_facts: true @@ -35,6 +36,7 @@ - role: "gnome" - role: "rsync" - role: "gpg" + - role: "dotfiles" - name: "Raspberry Pi configure" gather_facts: true @@ -52,3 +54,4 @@ - role: "prometheus" - role: "grafana" - role: "gpg" + - role: "dotfiles" diff --git a/group_vars/all.yml b/group_vars/all.yml index 14d4fd79..d70c9333 100644 Binary files a/group_vars/all.yml and b/group_vars/all.yml differ diff --git a/group_vars/all.yml.example b/group_vars/all.yml.example index 1c6a84fe..5fc30d82 100644 --- a/group_vars/all.yml.example +++ b/group_vars/all.yml.example @@ -29,6 +29,12 @@ password_policy_maxrepeat: 3 password_policy_maxclassrepeat: 0 password_policy_gecoscheck: 0 +dotfiles_repo_url: "https://git.sr.ht/~a14m/.rc" +dotfiles_setup_script: | + cd ~/.rc + stow --no-folding . + git remote set-url origin git@git.sr.ht:~a14m/.rc + wireguard_autostart_connection: "wg-vpn0" wireguard_connections: wg-vpn0: | diff --git a/molecule/archlinux/converge.yml b/molecule/archlinux/converge.yml index 8c99bc49..b091f109 100644 --- a/molecule/archlinux/converge.yml +++ b/molecule/archlinux/converge.yml @@ -40,3 +40,4 @@ - role: "gnome" - role: "rsync" - role: "gpg" + - role: "dotfiles" diff --git a/molecule/debian/converge.yml b/molecule/debian/converge.yml index 578ac2c3..8d6dd739 100644 --- a/molecule/debian/converge.yml +++ b/molecule/debian/converge.yml @@ -51,3 +51,4 @@ - role: "gnome" - role: "rsync" - role: "gpg" + - role: "dotfiles" diff --git a/molecule/raspberrypi/converge.yml b/molecule/raspberrypi/converge.yml index 43bbb9a0..1784bd62 100644 --- a/molecule/raspberrypi/converge.yml +++ b/molecule/raspberrypi/converge.yml @@ -41,3 +41,4 @@ - role: "gnome" - role: "rsync" - role: "gpg" + - role: "dotfiles" diff --git a/molecule/ubuntu/converge.yml b/molecule/ubuntu/converge.yml index fad0e5a6..66d2a208 100644 --- a/molecule/ubuntu/converge.yml +++ b/molecule/ubuntu/converge.yml @@ -40,3 +40,4 @@ - role: "gnome" - role: "rsync" - role: "gpg" + - role: "dotfiles" diff --git a/roles/dotfiles/meta/argument_specs.yml b/roles/dotfiles/meta/argument_specs.yml new file mode 100644 index 00000000..699cfe19 --- /dev/null +++ b/roles/dotfiles/meta/argument_specs.yml @@ -0,0 +1,14 @@ +--- +argument_specs: + main: + short_description: "Configure dotfile repo" + description: "Configure dotfile repo" + options: + dotfiles_repo_url: + type: "str" + description: "The dotfiles git repo URL" + required: true + dotfiles_setup_script: + type: "str" + description: "The dotfiles setup script" + required: true diff --git a/roles/dotfiles/meta/main.yml b/roles/dotfiles/meta/main.yml new file mode 100644 index 00000000..110e20f8 --- /dev/null +++ b/roles/dotfiles/meta/main.yml @@ -0,0 +1,20 @@ +--- +dependencies: + - role: "git" + - role: "stow" +galaxy_info: + author: "a14m" + description: "Configure dotfiles repo" + company: "kartoffeln.work GmbH." + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "ArchLinux" + versions: + - "all" + - name: "Ubuntu" + versions: + - "noble" + - name: "Debian" + versions: + - "bookworm" diff --git a/roles/dotfiles/tasks/main.yml b/roles/dotfiles/tasks/main.yml new file mode 100644 index 00000000..51b2e817 --- /dev/null +++ b/roles/dotfiles/tasks/main.yml @@ -0,0 +1,15 @@ +--- +- name: "Clone dotfiles git repo" + ansible.builtin.git: + repo: "{{ dotfiles_repo_url }}" + dest: "{{ ansible_env.HOME }}/.rc" + clone: true + update: false + single_branch: true + version: main + +- name: "Setup dotfiles" + ansible.builtin.shell: + cmd: "{{ dotfiles_setup_script }}" + executable: /bin/bash + creates: "{{ ansible_env.HOME }}/.bash_profile" diff --git a/roles/stow/meta/argument_specs.yml b/roles/stow/meta/argument_specs.yml new file mode 100644 index 00000000..f28fd6a4 --- /dev/null +++ b/roles/stow/meta/argument_specs.yml @@ -0,0 +1,6 @@ +--- +argument_specs: + main: + short_description: "Install stow on Linux distribution" + description: "Install stow on Linux distribution" + options: {} diff --git a/roles/stow/meta/main.yml b/roles/stow/meta/main.yml new file mode 100644 index 00000000..b80706ce --- /dev/null +++ b/roles/stow/meta/main.yml @@ -0,0 +1,18 @@ +--- +dependencies: [] +galaxy_info: + author: "a14m" + description: "Install stow" + company: "kartoffeln.work GmbH." + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "ArchLinux" + versions: + - "all" + - name: "Ubuntu" + versions: + - "noble" + - name: "Debian" + versions: + - "bookworm" diff --git a/roles/stow/tasks/main.yml b/roles/stow/tasks/main.yml new file mode 100644 index 00000000..bbed9279 --- /dev/null +++ b/roles/stow/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: "Ensure stow is installed" + become: true + ansible.builtin.package: + name: "stow" + state: "present" -- cgit v1.2.3