fix(ansible): split workstation playbook into two plays for Unix vs Windows

A single play with become:true uses sudo by default, which Ansible's
Windows exec wrapper rejects immediately at gather_facts. Split into:
- Play 1: hosts workstations,!workstations_windows — macOS/Linux, sudo
- Play 2: hosts workstations_windows — Windows, become_method:runas

Also set morgana to ansible_connection=local (running Ansible from
morgana itself, so SSH self-lookup fails DNS resolution).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
chrisfu 2026-05-09 22:33:51 -07:00
parent 5cd22c53d9
commit 67b483bcf2
2 changed files with 74 additions and 36 deletions

View File

@ -62,7 +62,7 @@ merlin ansible_host=10.0.0.36 ansible_user=ansible
# #
# Ensure the ansible_user has passwordless-sudo or run with --ask-become-pass. # Ensure the ansible_user has passwordless-sudo or run with --ask-become-pass.
[workstations] [workstations]
morgana.prole.org ansible_user=chrisfu morgana.prole.org ansible_user=chrisfu ansible_connection=local
zinfandel.prole.org ansible_user=chrisfu zinfandel.prole.org ansible_user=chrisfu
# ── Engineer workstations — Windows ────────────────────────────────────────── # ── Engineer workstations — Windows ──────────────────────────────────────────

View File

@ -12,13 +12,21 @@
# 2. Deploys Chrome managed preferences (AuthServerAllowlist) so Chrome/Edge # 2. Deploys Chrome managed preferences (AuthServerAllowlist) so Chrome/Edge
# automatically negotiates Kerberos for *.prole.org without any per-user # automatically negotiates Kerberos for *.prole.org without any per-user
# browser configuration. # browser configuration.
# 3. Symlinks/copies a krb5.conf into place for any Kerberos CLI tools. # 3. On Windows: writes the equivalent HKLM registry keys (no GPO required).
# #
# USAGE # USAGE
# ----- # -----
# # All managed workstations: # # All managed workstations (macOS + Windows):
# ansible-playbook infrastructure/playbooks/workstation_kerberos.yml # ansible-playbook infrastructure/playbooks/workstation_kerberos.yml
# #
# # macOS / Linux only:
# ansible-playbook infrastructure/playbooks/workstation_kerberos.yml \
# --limit workstations
#
# # Windows only:
# ansible-playbook infrastructure/playbooks/workstation_kerberos.yml \
# --limit workstations_windows
#
# # Single machine: # # Single machine:
# ansible-playbook infrastructure/playbooks/workstation_kerberos.yml \ # ansible-playbook infrastructure/playbooks/workstation_kerberos.yml \
# --limit <hostname> # --limit <hostname>
@ -29,16 +37,22 @@
# #
# HOSTS # HOSTS
# ----- # -----
# Targets the "workstations" inventory group. Add new machines there as # [workstations] — macOS / Linux endpoints (become: sudo)
# engineering headcount grows — no playbook changes required. # [workstations_windows] — Windows endpoints (become: runas)
# Add new machines to the appropriate group; no playbook changes required.
# #
# ADDING A NEW REALM # ADDING A NEW REALM
# ------------------ # ------------------
# Extend the krb5_realms list in vars below. The template generates the # Extend the krb5_realms list in vars below. The template generates the
# [realms] and [domain_realm] sections automatically. # [realms] and [domain_realm] sections automatically.
- name: Configure Kerberos client and browser SPNEGO on managed workstations # ============================================================================
hosts: workstations # Play 1 — macOS / Linux workstations
# Uses sudo (the default become plugin for Unix targets).
# morgana runs ansible_connection=local so DNS self-lookup is not required.
# ============================================================================
- name: Configure Kerberos client and browser SPNEGO on macOS/Linux workstations
hosts: "workstations,!workstations_windows"
gather_facts: true gather_facts: true
become: true become: true
@ -89,7 +103,6 @@
{{ d }} = {{ r.realm }} {{ d }} = {{ r.realm }}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
when: ansible_os_family != "Windows"
# macOS also checks this legacy path; symlink for compatibility. # macOS also checks this legacy path; symlink for compatibility.
- name: Symlink macOS legacy Kerberos config - name: Symlink macOS legacy Kerberos config
@ -192,32 +205,6 @@
- /etc/chromium/policies/managed - /etc/chromium/policies/managed
when: ansible_os_family != "Darwin" when: ansible_os_family != "Darwin"
# -----------------------------------------------------------------------
# 2c. Chrome + Edge managed policy — Windows
# Policy lives in the registry under HKLM\SOFTWARE\Policies\<vendor>\<app>.
# No GPO infrastructure required — win_regedit writes keys directly.
# If the machine is later joined to PROLE.ORG AD, these keys can be
# replaced by a proper GPO; they are idempotent either way.
# -----------------------------------------------------------------------
- name: Set Chrome SPNEGO policy keys (Windows)
ansible.windows.win_regedit:
path: "{{ item.path }}"
name: "{{ item.name }}"
data: "{{ chrome_negotiate_domains }}"
type: String
state: present
loop:
- path: HKLM:\SOFTWARE\Policies\Google\Chrome
name: AuthServerAllowlist
- path: HKLM:\SOFTWARE\Policies\Google\Chrome
name: AuthNegotiateDelegateAllowlist
- path: HKLM:\SOFTWARE\Policies\Microsoft\Edge
name: AuthServerAllowlist
- path: HKLM:\SOFTWARE\Policies\Microsoft\Edge
name: AuthNegotiateDelegateAllowlist
when: ansible_os_family == "Windows"
notify: Restart Chrome (Windows)
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# 3. Verify — print where to check policy was applied # 3. Verify — print where to check policy was applied
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
@ -238,9 +225,60 @@
Ask the user to quit Chrome completely (Cmd-Q) and relaunch. Ask the user to quit Chrome completely (Cmd-Q) and relaunch.
Managed preferences take effect on next launch — no reinstall needed. Managed preferences take effect on next launch — no reinstall needed.
- name: Restart Chrome (Windows)
# ============================================================================
# Play 2 — Windows workstations
# Uses runas (the correct become plugin for Windows targets).
# No krb5.conf needed — Windows uses built-in SSPI/Kerberos via AD domain join.
# Browser policy is written to HKLM registry keys directly (no GPO required).
# If the machine later joins the PROLE.ORG Samba AD domain, these keys can be
# replaced or supplemented by a proper GPO; win_regedit is idempotent.
# ============================================================================
- name: Configure browser SPNEGO policy on Windows workstations
hosts: workstations_windows
gather_facts: true
become: true
become_method: runas
become_user: SYSTEM
vars:
chrome_negotiate_domains: "*.prole.org"
tasks:
# -----------------------------------------------------------------------
# Chrome + Edge managed policy via registry
# HKLM\SOFTWARE\Policies\Google\Chrome\AuthServerAllowlist
# HKLM\SOFTWARE\Policies\Microsoft\Edge\AuthServerAllowlist
# -----------------------------------------------------------------------
- name: Set Chrome SPNEGO policy keys
ansible.windows.win_regedit:
path: "{{ item.path }}"
name: "{{ item.name }}"
data: "{{ chrome_negotiate_domains }}"
type: String
state: present
loop:
- path: HKLM:\SOFTWARE\Policies\Google\Chrome
name: AuthServerAllowlist
- path: HKLM:\SOFTWARE\Policies\Google\Chrome
name: AuthNegotiateDelegateAllowlist
- path: HKLM:\SOFTWARE\Policies\Microsoft\Edge
name: AuthServerAllowlist
- path: HKLM:\SOFTWARE\Policies\Microsoft\Edge
name: AuthNegotiateDelegateAllowlist
notify: Restart browsers (Windows)
- name: Show policy verification URL
ansible.builtin.debug:
msg: >
Chrome/Edge registry policy applied on {{ inventory_hostname }}.
Verify at chrome://policy or edge://policy.
Expected: AuthServerAllowlist = {{ chrome_negotiate_domains }}
handlers:
- name: Restart browsers (Windows)
ansible.builtin.debug: ansible.builtin.debug:
msg: > msg: >
Chrome/Edge policy updated on {{ inventory_hostname }}. Chrome/Edge policy updated on {{ inventory_hostname }}.
Ask the user to close all Chrome and Edge windows and relaunch. Ask the user to close all Chrome and Edge windows and relaunch.
Registry policy takes effect on next browser start — no reinstall needed. Registry policy takes effect on next browser start.