aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2022-12-29 15:20:47 +0100
committerRomain Gonçalves <me@rgoncalves.se>2022-12-29 15:54:09 +0100
commitcadc8824e093f37c36263b2aefba3cd680389f0b (patch)
treef25fec4782f585166b314e49b0c30577ecfe9694
parent8ce56f15e0751870b56805010241dcfe8389b10f (diff)
downloadrules-cadc8824e093f37c36263b2aefba3cd680389f0b.tar.gz
feat(roles/_workstation): add makepkg role
-rw-r--r--roles/_workstation/basetools/defaults/main.yml9
-rw-r--r--roles/_workstation/basetools/meta/main.yml21
-rw-r--r--roles/_workstation/basetools/tasks/install.yml22
-rw-r--r--roles/_workstation/basetools/tasks/main.yml8
-rw-r--r--roles/_workstation/makepkg/defaults/main.yml4
-rw-r--r--roles/_workstation/makepkg/meta/main.yml22
-rw-r--r--roles/_workstation/makepkg/tasks/install.yml21
-rw-r--r--roles/_workstation/makepkg/tasks/main.yml16
-rw-r--r--site.workstation.yml1
9 files changed, 123 insertions, 1 deletions
diff --git a/roles/_workstation/basetools/defaults/main.yml b/roles/_workstation/basetools/defaults/main.yml
index 740a870..f26785a 100644
--- a/roles/_workstation/basetools/defaults/main.yml
+++ b/roles/_workstation/basetools/defaults/main.yml
@@ -1,6 +1,13 @@
---
-basetools_distribution_packages: []
+basetools_distribution_packages:
+basetools_makepkg_packages:
+ - conftest
+ - dive-bin
+ - pandoc-bin
+ - pipewatch-git
+ - wkhtmltopdf
+ - yay-bin
basetools_common_packages:
- ansible
- ansible-lint
diff --git a/roles/_workstation/basetools/meta/main.yml b/roles/_workstation/basetools/meta/main.yml
new file mode 100644
index 0000000..f4acc42
--- /dev/null
+++ b/roles/_workstation/basetools/meta/main.yml
@@ -0,0 +1,21 @@
+---
+
+argument_specs:
+ main:
+ short_description: basetools main entrypoint.
+ options:
+ basetools_common_packages:
+ type: list
+ elements: str
+ required: true
+ description: Common packages accross all operating system
+ basetools_distribution_packages:
+ type: list
+ elements: str
+ required: true
+ description: Operating system specific packages
+ basetools_makepkg_packages:
+ type: list
+ elements: str
+ required: true
+ description: Makepkg specific packages
diff --git a/roles/_workstation/basetools/tasks/install.yml b/roles/_workstation/basetools/tasks/install.yml
new file mode 100644
index 0000000..5e24f4e
--- /dev/null
+++ b/roles/_workstation/basetools/tasks/install.yml
@@ -0,0 +1,22 @@
+---
+
+- name: install distribution packages
+ ansible.builtin.package:
+ name: "{{ item }}"
+ state: present
+ loop:
+ - "{{ basetools_common_packages }}"
+ - "{{ basetools_distribution_packages }}"
+
+- name: install community package
+ ansible.builtin.include_role:
+ name: _workstation/makepkg
+ vars:
+ makepkg_package_name: "{{ item }}"
+ loop:
+ - conftest
+ - dive-bin
+ - pandoc-bin
+ - pipewatch-git
+ - wkhtmltopdf
+ when: ansible_distribution in ["Archlinux"]
diff --git a/roles/_workstation/basetools/tasks/main.yml b/roles/_workstation/basetools/tasks/main.yml
index f53d213..6b8e1cd 100644
--- a/roles/_workstation/basetools/tasks/main.yml
+++ b/roles/_workstation/basetools/tasks/main.yml
@@ -11,3 +11,11 @@
loop:
- "{{ basetools_common_packages }}"
- "{{ basetools_distribution_packages }}"
+
+- name: install community package
+ ansible.builtin.include_role:
+ name: _workstation/makepkg
+ vars:
+ makepkg_package_name: "{{ item }}"
+ loop: "{{ basetools_makepkg_packages }}"
+ when: ansible_distribution in ["Archlinux"]
diff --git a/roles/_workstation/makepkg/defaults/main.yml b/roles/_workstation/makepkg/defaults/main.yml
new file mode 100644
index 0000000..96e3521
--- /dev/null
+++ b/roles/_workstation/makepkg/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+
+makepkg_mirror_url: https://aur.archlinux.org
+makepkg_root_build_dir: /tmp/makepkg
diff --git a/roles/_workstation/makepkg/meta/main.yml b/roles/_workstation/makepkg/meta/main.yml
new file mode 100644
index 0000000..07c1a64
--- /dev/null
+++ b/roles/_workstation/makepkg/meta/main.yml
@@ -0,0 +1,22 @@
+---
+
+argument_specs:
+ main:
+ short_description: makepkg main entrypoint.
+ options:
+ makepkg_root_build_dir:
+ type: path
+ required: true
+ description: Local build directory
+ makepkg_package_name:
+ type: str
+ required: true
+ description: Package name (from the AUR)
+ makepkg_user:
+ type: str
+ required: true
+ description: User for building the package
+ makepkg_mirror_url:
+ type: str
+ required: true
+ description: Mirror url (usually the AUR)
diff --git a/roles/_workstation/makepkg/tasks/install.yml b/roles/_workstation/makepkg/tasks/install.yml
new file mode 100644
index 0000000..b9caeef
--- /dev/null
+++ b/roles/_workstation/makepkg/tasks/install.yml
@@ -0,0 +1,21 @@
+---
+
+- name: clone repository # noqa: latest[git]
+ ansible.builtin.git:
+ repo: "{{ makepkg_mirror_url }}/{{ makepkg_package_name }}.git"
+ dest: "{{ makepkg_root_build_dir }}/{{ makepkg_package_name }}"
+ force: true
+ become: true
+ become_user: "{{ makepkg_user }}"
+
+- name: make package # noqa: no-changed-when
+ ansible.builtin.command:
+ cmd: makepkg -fs
+ chdir: "{{ makepkg_root_build_dir }}/{{ makepkg_package_name }}"
+ become: true
+ become_user: "{{ makepkg_user }}"
+
+- name: install package # noqa: no-changed-when
+ ansible.builtin.shell:
+ cmd: pacman --noconfirm -U *.zst
+ chdir: "{{ makepkg_root_build_dir }}/{{ makepkg_package_name }}"
diff --git a/roles/_workstation/makepkg/tasks/main.yml b/roles/_workstation/makepkg/tasks/main.yml
new file mode 100644
index 0000000..1a31fd9
--- /dev/null
+++ b/roles/_workstation/makepkg/tasks/main.yml
@@ -0,0 +1,16 @@
+---
+
+- name: "check that package is present: {{ makepkg_package_name }}"
+ ansible.builtin.command:
+ cmd: pacman -Q {{ makepkg_package_name }}
+ register: makepkg_result_check_package
+ changed_when:
+ - makepkg_result_check_package.rc != 0
+ failed_when:
+ - makepkg_result_check_package.rc == 1
+ - "'was not found' not in makepkg_result_check_package.stderr"
+
+- name: include install task # noqa: no-handler
+ ansible.builtin.include_tasks:
+ file: install.yml
+ when: makepkg_result_check_package.changed
diff --git a/site.workstation.yml b/site.workstation.yml
index a7efba8..07911d1 100644
--- a/site.workstation.yml
+++ b/site.workstation.yml
@@ -13,6 +13,7 @@
shell_workstation_user: "{{ _workstation_user }}"
syncthing_workstation_user: "{{ _workstation_user }}"
yay_workstation_user: "{{ _workstation_user }}"
+ makepkg_user: "{{ _workstation_user }}"
pre_tasks:
- name: verify running as root
remember that computers suck.