working on cleanup and fixing a few format issues

- modifying how installs are done
This commit is contained in:
Matthew Stobbs
2026-02-15 17:57:05 -07:00
parent b1a4780a97
commit e39c3b7046
11 changed files with 201 additions and 139 deletions

View File

@@ -4,48 +4,29 @@
block:
- name: Fetch git repo
vars:
git:
path: "{{ d_cache.path }}/{{ cargo_build.name }}"
repo: "{{ cargo_build.repo }}"
depth: "{{ cargo_build.depth | default(1) }}"
force: "{{ cargo_build.force_git | default(true) }}"
recursive: "{{ cargo_build.recursive | default(true) }}"
version: "{{ cargo_build.version | default(omit) }}"
ansible.builtin.include_tasks:
file: helpers/git.yml
path: "{{ path_source }}/{{ cargo_build.source_dir }}"
repo: "{{ cargo_build.repo }}"
depth: "{{ cargo_build.depth | default(1) }}"
force: "{{ cargo_build.force_git | default(true) }}"
recursive: "{{ cargo_build.recursive | default(true) }}"
version: "{{ cargo_build.version | default(omit) }}"
ansible.builtin.include_tasks: helpers/git.yml
- name: Build cargo release
ansible.builtin.command:
chdir: "{{ d_cache.path }}/{{ cargo_build.name }}"
chdir: "{{ path_source }}/{{ cargo_build.source_dir }}"
argv: "{{ [cargo, build] + cargo_build.build_flags }}"
- name: Clean existing install
vars:
files: "{{ cargo_build.files }}"
ansible.builtin.include_tasks: helpers/clean.yml
- name: Install cargo release
block:
- name: Create missing directories
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ cargo_build.files }}"
loop_control:
loop_var: file
ansible.builtin.file:
state: directory
path: "{{ install_prefix }}/{{ file.to | dirname }}"
mode: '0755'
owner: "{{ cargo_build.owner | default(ansible_user_id) }}"
group: "{{ cargo_build.group | default(ansible_user_gid) }}"
- name: Install release files
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ cargo_build.files }}"
loop_control:
loop_var: file
ansible.builtin.copy:
backup: false
remote_src: true
src: "{{ d_cache.path }}/{{ cargo_build.name }}/{{ file.from }}"
dest: "{{ install_prefix }}/{{ file.to }}"
owner: "{{ cargo_build.owner | default(ansible_user_id) }}"
group: "{{ cargo_build.group | default(ansible_user_gid) }}"
mode: "{{ file.mode | default('0644') }}"
force: "{{ file.force | default(true) }}"
vars:
source_dir: "{{ cargo_build.source_dir }}"
ansible.builtin.include_tasks: helpers/install.yml

View File

@@ -1,10 +1,21 @@
# vim: set filetype=yaml.ansible :
---
- name: Remove file list
become: true
loop: "{{ file_list }}"
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ files }}"
loop_control:
loop_var: file
when:
- file.to is defined
ansible.builtin.file:
state: absent
path: "{{ file }}"
path: "{{ install_prefix }}/{{ file.to }}"
- name: Check for and remove empty directories
loop: "{{ files }}"
loop_control:
loop_var: dir
when:
- file.directory is defined
ansible.builtin.include_tasks: internal/remove_empty_dir.yml

View File

@@ -2,9 +2,9 @@
---
- name: Clone git repository
ansible.builtin.git:
depth: "{{ git.depth | default(1) }}"
dest: "{{ git.path }}"
force: "{{ git.force | default(true) }}"
recursive: "{{ git.recursive | default(true) }}"
repo: "{{ git.repo }}"
version: "{{ git.version | default(omit) }}"
dest: "{{ path }}"
repo: "{{ repo }}"
depth: "{{ depth | default(1) }}"
force: "{{ force | default(true) }}"
recursive: "{{ recursive | default(true) }}"
version: "{{ version | default(omit) }}"

40
tasks/helpers/install.yml Normal file
View File

@@ -0,0 +1,40 @@
# vim: set filetype=yaml.ansible :
#
## Helper: install.yml
## Description: install files defined in dict
## Variables:
## _Note_ This is mutually exclusive to having a 'to' key
## - directory: path prefixed by {{ install_prefix }} of a directory to
## be created
## mode: _optional_, _default_ '0755'
##
## _Note_ This is mutually exclusive to having a 'directory' key
## - to: where to install file to, prefixed with {{ install_prefix }}
## from: source file from build path root for package
## mode: _optional_, _default_ '0644'##
##
## Notes: This is only used when copying files or creating directories
## for installing. If a source package doesn't require you to manually
## copy anthing (go install, as an example), don't use this.
---
- name: Create directories
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ pkg_clean }}"
loop_control:
loop_var: dir
when:
- dir.directory is defined
ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ install_prefix }}/{{ dir.directory }}"
- name: Copy installable files
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ pkg_clean }}"
ansible.builtin.copy:
dest: "{{ install_prefix }}/{{ file.to }}"
mode: "{{ file.mode | default('0644') }}"
src: "{{ file.builddir | default(omit) }}/"