mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-12-20 15:53:13 +00:00
Integrated setup for integration tests
This commit is contained in:
4
Makefile
4
Makefile
@@ -153,7 +153,7 @@ test-lint: build-missing
|
|||||||
test-unit: build-missing
|
test-unit: build-missing
|
||||||
@TEST_TYPE="unit" bash scripts/tests/code.sh
|
@TEST_TYPE="unit" bash scripts/tests/code.sh
|
||||||
|
|
||||||
test-integration: build-missing
|
test-integration: setup-clean build-missing
|
||||||
@TEST_TYPE="integration" bash scripts/tests/code.sh
|
@TEST_TYPE="integration" bash scripts/tests/code.sh
|
||||||
|
|
||||||
# Backwards compatible target (kept)
|
# Backwards compatible target (kept)
|
||||||
@@ -161,7 +161,7 @@ test-messy: test-lint test-unit test-integration
|
|||||||
@echo "📑 Checking Ansible syntax…"
|
@echo "📑 Checking Ansible syntax…"
|
||||||
ansible-playbook -i localhost, -c local $(foreach f,$(wildcard group_vars/all/*.yml),-e @$(f)) playbook.yml --syntax-check
|
ansible-playbook -i localhost, -c local $(foreach f,$(wildcard group_vars/all/*.yml),-e @$(f)) playbook.yml --syntax-check
|
||||||
|
|
||||||
test: clean setup test-messy
|
test: setup-clean test-messy
|
||||||
@echo "✅ Full test (setup + tests) executed."
|
@echo "✅ Full test (setup + tests) executed."
|
||||||
|
|
||||||
# Debug helper
|
# Debug helper
|
||||||
|
|||||||
37
roles/desk-dotlinker/README.md
Normal file
37
roles/desk-dotlinker/README.md
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Dotlinker (doli) 🧷
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This Ansible role ensures the `doli` (dotlinker) CLI is installed (via `pkgmgr`)
|
||||||
|
and applies dotlinker mappings provided by the calling role.
|
||||||
|
|
||||||
|
The role is intentionally generic: it does not know anything about Nextcloud or other apps.
|
||||||
|
It can be included multiple times from different roles, each time with a different set of mappings.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Call this role via `include_role` and pass mappings through `dotlinker_mappings`:
|
||||||
|
|
||||||
|
- `name`: unique mapping id
|
||||||
|
- `backend`: `cloud` or `chezmoi`
|
||||||
|
- `src`: source path (original location)
|
||||||
|
- `dest`: destination path (required for `cloud`)
|
||||||
|
|
||||||
|
The role will register mappings using `doli add` and can optionally run `doli pull`.
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
- `dotlinker_user` (required): user to run `doli` as
|
||||||
|
- `dotlinker_config_path` (default: `~/.config/dotlinker/config.yaml`)
|
||||||
|
- `dotlinker_cli_name` (default: `doli`)
|
||||||
|
- `dotlinker_package_name` (default: `doli`)
|
||||||
|
- `dotlinker_replace` (default: `true`): pass `--replace` to `doli add`
|
||||||
|
- `dotlinker_apply` (default: `true`): run `doli pull` after adding mappings
|
||||||
|
|
||||||
|
## Credits 📝
|
||||||
|
|
||||||
|
Developed and maintained by **Kevin Veen-Birkenbach**.
|
||||||
|
Learn more at [www.veen.world](https://www.veen.world)
|
||||||
|
|
||||||
|
Part of the [Infinito.Nexus Project](https://s.infinito.nexus/code)
|
||||||
|
License: [Infinito.Nexus NonCommercial License](https://s.infinito.nexus/license)
|
||||||
1
roles/desk-dotlinker/config/main.yml
Normal file
1
roles/desk-dotlinker/config/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
17
roles/desk-dotlinker/defaults/main.yml
Normal file
17
roles/desk-dotlinker/defaults/main.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Package name in pkgmgr
|
||||||
|
dotlinker_package_name: "doli"
|
||||||
|
|
||||||
|
# Binary name
|
||||||
|
dotlinker_cli_name: "doli"
|
||||||
|
|
||||||
|
# If true, doli add will use --replace
|
||||||
|
dotlinker_replace: true
|
||||||
|
|
||||||
|
# If true, run doli pull after registering mappings
|
||||||
|
dotlinker_apply: true
|
||||||
|
|
||||||
|
# Default config path (can be overridden by caller)
|
||||||
|
dotlinker_config_path: "~/.config/dotlinker/config.yaml"
|
||||||
|
|
||||||
|
# Mappings provided by caller (list of dicts)
|
||||||
|
dotlinker_mappings: []
|
||||||
23
roles/desk-dotlinker/meta/main.yml
Normal file
23
roles/desk-dotlinker/meta/main.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: "Kevin Veen-Birkenbach"
|
||||||
|
description: "Installs and applies dotlinker (doli) mappings (generic role)."
|
||||||
|
license: "Infinito.Nexus NonCommercial License"
|
||||||
|
license_url: "https://s.infinito.nexus/license"
|
||||||
|
company: |
|
||||||
|
Kevin Veen-Birkenbach
|
||||||
|
Consulting & Coaching Solutions
|
||||||
|
https://www.veen.world
|
||||||
|
min_ansible_version: "2.9"
|
||||||
|
platforms:
|
||||||
|
- name: Archlinux
|
||||||
|
versions:
|
||||||
|
- rolling
|
||||||
|
galaxy_tags:
|
||||||
|
- dotfiles
|
||||||
|
- cloud
|
||||||
|
- desktop
|
||||||
|
- automation
|
||||||
|
repository: https://s.infinito.nexus/code
|
||||||
|
issue_tracker_url: https://s.infinito.nexus/issues
|
||||||
|
documentation: "https://docs.infinito.nexus/"
|
||||||
7
roles/desk-dotlinker/tasks/01_install.yml
Normal file
7
roles/desk-dotlinker/tasks/01_install.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
- name: Install dotlinker via pkgmgr
|
||||||
|
include_role:
|
||||||
|
name: pkgmgr-install
|
||||||
|
vars:
|
||||||
|
package_name: "{{ dotlinker_package_name }}"
|
||||||
|
|
||||||
|
- include_tasks: utils/once/flag.yml
|
||||||
42
roles/desk-dotlinker/tasks/02_apply.yml
Normal file
42
roles/desk-dotlinker/tasks/02_apply.yml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
- name: Ensure dotlinker user is defined
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- dotlinker_user is defined
|
||||||
|
- dotlinker_user | length > 0
|
||||||
|
fail_msg: "dotlinker_user must be provided by the calling role."
|
||||||
|
|
||||||
|
- name: Ensure dotlinker config directory exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ dotlinker_config_path | dirname }}"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ dotlinker_user }}"
|
||||||
|
group: "{{ dotlinker_user }}"
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Register mappings in dotlinker
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv: >-
|
||||||
|
{{
|
||||||
|
([dotlinker_cli_name, '-c', dotlinker_config_path, 'add']
|
||||||
|
+ (['--replace'] if (dotlinker_replace | bool) else [])
|
||||||
|
+ ['-N', item.name, '-b', item.backend, '-s', item.src]
|
||||||
|
+ (['-d', item.dest] if item.backend == 'cloud' else [])
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
become: true
|
||||||
|
become_user: "{{ dotlinker_user }}"
|
||||||
|
loop: "{{ dotlinker_mappings }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
|
when: dotlinker_mappings | length > 0
|
||||||
|
|
||||||
|
- name: Apply dotlinker mappings (pull)
|
||||||
|
ansible.builtin.command: >
|
||||||
|
{{ dotlinker_cli_name | quote }}
|
||||||
|
-c {{ (dotlinker_config_path ) | quote }}
|
||||||
|
pull
|
||||||
|
become: true
|
||||||
|
become_user: "{{ dotlinker_user }}"
|
||||||
|
when:
|
||||||
|
- dotlinker_apply | bool
|
||||||
|
- dotlinker_mappings | length > 0
|
||||||
7
roles/desk-dotlinker/tasks/main.yml
Normal file
7
roles/desk-dotlinker/tasks/main.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
# Install ONCE per play/host, but allow apply multiple times with different mappings
|
||||||
|
- include_tasks: 01_install.yml
|
||||||
|
when: run_once_desk_dotlinker is not defined
|
||||||
|
|
||||||
|
# Apply mappings EVERY time the role is included (with whatever dotlinker_mappings the caller passes)
|
||||||
|
- include_tasks: 02_apply.yml
|
||||||
1
roles/desk-dotlinker/vars/main.yml
Normal file
1
roles/desk-dotlinker/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
application_id: desk-dotlinker
|
||||||
Reference in New Issue
Block a user