From 457db3ced207652b60b900ba500d2077176fc3cc Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 27 Apr 2026 08:35:28 -0700 Subject: [PATCH] ansible: implement install + policy + pending tasks Adds the apt_repository / apt steps that pull authforge-daemon, -pam, and -cli (with -gui gated behind authforge_install_gui), the template step that renders /etc/authforge/policy.d/90-fleet.conf and notifies the restart handler, and a loop that calls `authforgectl pending set` for each entry in authforge_pending_users. The template emits TOML that round-trips through tomllib for both the empty-stacks default and a populated multi-stack config. Co-Authored-By: Claude Opus 4.7 (1M context) --- ansible-role/tasks/main.yml | 52 +++++++++++++++++++++++++++ ansible-role/templates/policy.conf.j2 | 18 ++++++++++ 2 files changed, 70 insertions(+) create mode 100644 ansible-role/tasks/main.yml create mode 100644 ansible-role/templates/policy.conf.j2 diff --git a/ansible-role/tasks/main.yml b/ansible-role/tasks/main.yml new file mode 100644 index 0000000..55ed839 --- /dev/null +++ b/ansible-role/tasks/main.yml @@ -0,0 +1,52 @@ +--- +- name: Add the AuthForge PPA + ansible.builtin.apt_repository: + repo: "{{ authforge_ppa }}" + state: present + update_cache: true + +- name: Install AuthForge headless components + ansible.builtin.apt: + name: + - authforge-daemon + - authforge-pam + - authforge-cli + state: present + update_cache: true + +- name: Install AuthForge GUI (optional) + ansible.builtin.apt: + name: authforge-gui + state: present + when: authforge_install_gui | bool + +- name: Ensure /etc/authforge/policy.d exists + ansible.builtin.file: + path: /etc/authforge/policy.d + state: directory + owner: root + group: root + mode: "0755" + +- name: Render fleet policy file + ansible.builtin.template: + src: policy.conf.j2 + dest: /etc/authforge/policy.d/90-fleet.conf + owner: root + group: root + mode: "0644" + notify: restart authforge-daemon + +- name: Mark users as pending-enrollment + ansible.builtin.command: + argv: + - authforgectl + - pending + - set + - "{{ item.user }}" + - --methods + - "{{ item.methods | join(',') }}" + loop: "{{ authforge_pending_users }}" + loop_control: + label: "{{ item.user }}" + changed_when: true diff --git a/ansible-role/templates/policy.conf.j2 b/ansible-role/templates/policy.conf.j2 new file mode 100644 index 0000000..c9d56cf --- /dev/null +++ b/ansible-role/templates/policy.conf.j2 @@ -0,0 +1,18 @@ +# {{ ansible_managed }} +# Fleet-managed AuthForge policy. Hand-edits will be overwritten on the next +# Ansible run. To override locally, drop a higher-numbered file in +# /etc/authforge/policy.d/ (e.g. 99-local.conf). + +{% for stack, cfg in authforge_stacks.items() %} +[stacks.{{ stack }}] +mode = "{{ cfg.mode }}" +methods = {{ cfg.methods | to_json }} + +{% endfor %} +[storage] +backend = "{{ authforge_storage_backend }}" +central_path = "{{ authforge_storage_central_path }}" + +[firstrun] +default_required_methods = {{ authforge_firstrun_methods | to_json }} +deadline_hours = {{ authforge_firstrun_deadline_hours }}