Consolidate logrotate and cron files into their main service/package roles if they exist. Standardise on MAX_FILES_CAP in one place

This commit is contained in:
Miguel Jacq 2025-12-28 09:30:21 +11:00
parent cae6246177
commit 303c1b0dd8
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
3 changed files with 208 additions and 57 deletions

View file

@ -138,7 +138,6 @@ def _copy_artifacts(
# If a file was successfully templatised by JinjaTurtle, do NOT
# also materialise the raw copy in the destination files dir.
# (This keeps the output minimal and avoids redundant "raw" files.)
if exclude_rels and rel in exclude_rels:
try:
if os.path.isfile(dst):
@ -165,7 +164,7 @@ def _write_role_scaffold(role_dir: str) -> None:
def _write_playbook_all(path: str, roles: List[str]) -> None:
pb_lines = [
"---",
"- name: Apply all roles on host",
"- name: Apply all roles on all hosts",
" hosts: all",
" become: true",
" roles:",
@ -179,7 +178,7 @@ def _write_playbook_all(path: str, roles: List[str]) -> None:
def _write_playbook_host(path: str, fqdn: str, roles: List[str]) -> None:
pb_lines = [
"---",
f"- name: Apply enroll roles on {fqdn}",
f"- name: Apply all roles on {fqdn}",
f" hosts: {fqdn}",
" become: true",
" roles:",
@ -390,9 +389,9 @@ def _render_generic_files_tasks(
# Using first_found makes roles work in both modes:
# - site-mode: inventory/host_vars/<host>/<role>/.files/...
# - non-site: roles/<role>/files/...
return f"""# Generated by enroll (data-driven tasks)
return f"""# Generated by enroll
- name: Deploy systemd unit files (templates)
- name: Deploy any systemd unit files (templates)
ansible.builtin.template:
src: "{{{{ item.src_rel }}}}.j2"
dest: "{{{{ item.dest }}}}"
@ -406,7 +405,7 @@ def _render_generic_files_tasks(
| list }}}}
notify: "{{{{ item.notify | default([]) }}}}"
- name: Deploy systemd unit files (copies)
- name: Deploy any systemd unit files (raw files)
vars:
_enroll_ff:
files:
@ -433,7 +432,7 @@ def _render_generic_files_tasks(
| list
| length) > 0
- name: Deploy other managed files (templates)
- name: Deploy any other managed files (templates)
ansible.builtin.template:
src: "{{{{ item.src_rel }}}}.j2"
dest: "{{{{ item.dest }}}}"
@ -447,7 +446,7 @@ def _render_generic_files_tasks(
| list }}}}
notify: "{{{{ item.notify | default([]) }}}}"
- name: Deploy other managed files (copies)
- name: Deploy any other managed files (raw files)
vars:
_enroll_ff:
files:
@ -668,11 +667,6 @@ def _manifest_from_bundle_dir(
manifested_service_roles: List[str] = []
manifested_pkg_roles: List[str] = []
# In site_mode, raw harvested files are stored under host-specific inventory
# to avoid cross-host clobber while still sharing a role definition.
# -------------------------
# -------------------------
# Users role (non-system users)
# -------------------------
@ -793,7 +787,7 @@ def _manifest_from_bundle_dir(
# tasks (data-driven)
users_tasks = """---
# Generated by enroll (data-driven tasks)
# Generated by enroll
- name: Ensure groups exist
ansible.builtin.group:
@ -893,8 +887,6 @@ Generated non-system user accounts and SSH public material.
manifested_users_roles.append(role)
# -------------------------
# -------------------------
# etc_custom role (unowned /etc not already attributed)
# -------------------------
@ -1212,8 +1204,6 @@ User-requested extra file harvesting.
manifested_usr_local_custom_roles.append(role)
# -------------------------
# -------------------------
# Service roles
# -------------------------
@ -1315,7 +1305,7 @@ User-requested extra file harvesting.
task_parts: List[str] = []
task_parts.append(
f"""---
# Generated by enroll (data-driven tasks)
# Generated by enroll
- name: Install packages for {role}
ansible.builtin.apt:
@ -1474,7 +1464,7 @@ Generated from `{unit}`.
task_parts: List[str] = []
task_parts.append(
f"""---
# Generated by enroll (data-driven tasks)
# Generated by enroll
- name: Install packages for {role}
ansible.builtin.apt: