mirror of
https://github.com/fscotto/infra.git
synced 2026-11-25 21:29:51 +00:00
Manage ChatGPT Desktop, OpenCode Desktop, and Cline Desktop with the same install/uninstall lifecycle pattern used by the CLI coding agents: independent flags per app, a shared ai_desktop_apps map, a common pre-task that rejects conflicting install/uninstall pairs, and explicit install and removal task flows. ChatGPT opts in per host through chatgpt_desktop_install_enabled, Cline opts in through the desktop_gnome group vars, and OpenCode Desktop keeps removal selected so the retired opencode RPM and every cached download converge away on graphical hosts. Removal never touches user data, GNOME favorites, or the npm-managed CLI counterparts.
296 lines
9.8 KiB
YAML
296 lines
9.8 KiB
YAML
---
|
|
- name: Ensure GNOME desktop user config directories exist
|
|
tags: [dotfiles, dotfiles:desktop, gnome]
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ username }}"
|
|
group: "{{ user_group }}"
|
|
mode: "0755"
|
|
loop:
|
|
- "{{ user_home }}/.config"
|
|
- "{{ user_home }}/.config/autostart"
|
|
- "{{ user_home }}/.local"
|
|
- "{{ user_home }}/.local/bin"
|
|
- "{{ user_home }}/.bashrc.d"
|
|
- "{{ user_home }}/.tmux"
|
|
- "{{ user_home }}/.tmux/bin"
|
|
- "{{ user_home }}/.tmux/plugins"
|
|
|
|
- name: Ensure GNOME desktop private directories exist
|
|
tags: [dotfiles, dotfiles:desktop, gnome]
|
|
ansible.builtin.file:
|
|
path: "{{ item.path }}"
|
|
state: directory
|
|
owner: "{{ username }}"
|
|
group: "{{ user_group }}"
|
|
mode: "{{ item.mode }}"
|
|
loop:
|
|
- path: "{{ user_home }}/.gnupg"
|
|
mode: "0700"
|
|
- path: "{{ user_home }}/.ssh"
|
|
mode: "0700"
|
|
- path: "{{ user_home }}/.local/state/ssh/sockets"
|
|
mode: "0700"
|
|
|
|
- name: Copy GNOME desktop dotfiles
|
|
tags: [dotfiles, dotfiles:desktop, gnome]
|
|
ansible.builtin.copy:
|
|
src: "{{ playbook_dir }}/../dotfiles/desktop/{{ item.src }}"
|
|
dest: "{{ user_home }}/{{ item.dest }}"
|
|
owner: "{{ username }}"
|
|
group: "{{ user_group }}"
|
|
mode: "{{ item.mode }}"
|
|
loop: "{{ (desktop_common_dotfiles | default([])) + (desktop_gnome_dotfiles | default([])) }}"
|
|
loop_control:
|
|
label: "{{ item.dest }}"
|
|
|
|
- name: Configure GNOME gpg-agent for Fedora
|
|
tags: [dotfiles, dotfiles:desktop, git, gnome]
|
|
ansible.builtin.copy:
|
|
dest: "{{ user_home }}/.gnupg/gpg-agent.conf"
|
|
content: |
|
|
pinentry-program /usr/bin/pinentry-gnome3
|
|
enable-ssh-support
|
|
default-cache-ttl 600
|
|
max-cache-ttl 7200
|
|
owner: "{{ username }}"
|
|
group: "{{ user_group }}"
|
|
mode: "0600"
|
|
notify: Reload GNOME gpg-agent
|
|
|
|
- name: Render GNOME git configuration with private values
|
|
tags: [dotfiles, dotfiles:desktop, git, gnome]
|
|
ansible.builtin.template:
|
|
src: desktop/.gitconfig.j2
|
|
dest: "{{ user_home }}/.gitconfig"
|
|
owner: "{{ username }}"
|
|
group: "{{ user_group }}"
|
|
mode: "0644"
|
|
|
|
- name: Define GNOME managed tmux plugin directories
|
|
tags: [dotfiles, dotfiles:desktop, tmux, gnome]
|
|
ansible.builtin.set_fact:
|
|
gnome_tmux_managed_plugin_names:
|
|
- tpm
|
|
- tmux-sensible
|
|
- tmux-autoreload
|
|
- tmux-resurrect
|
|
- tmux-continuum
|
|
- tmux-yank
|
|
|
|
- name: Check whether GNOME tmux plugin directories are git checkouts
|
|
tags: [dotfiles, dotfiles:desktop, tmux, gnome]
|
|
ansible.builtin.stat:
|
|
path: "{{ user_home }}/.tmux/plugins/{{ item }}/.git"
|
|
loop: "{{ gnome_tmux_managed_plugin_names }}"
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
register: gnome_tmux_plugin_git_state
|
|
|
|
- name: Remove stale vendored GNOME tmux plugin directories
|
|
tags: [dotfiles, dotfiles:desktop, tmux, gnome]
|
|
ansible.builtin.file:
|
|
path: "{{ user_home }}/.tmux/plugins/{{ item.item }}"
|
|
state: absent
|
|
loop: "{{ gnome_tmux_plugin_git_state.results }}"
|
|
loop_control:
|
|
label: "{{ item.item }}"
|
|
when:
|
|
- item.stat.exists == false
|
|
|
|
- name: Bootstrap GNOME tmux plugin manager checkout
|
|
tags: [dotfiles, dotfiles:desktop, tmux, gnome]
|
|
ansible.builtin.git:
|
|
repo: https://github.com/tmux-plugins/tpm
|
|
dest: "{{ user_home }}/.tmux/plugins/tpm"
|
|
version: master
|
|
update: true
|
|
become_user: "{{ username }}"
|
|
environment:
|
|
HOME: "{{ user_home }}"
|
|
|
|
- name: Install GNOME tmux plugins through TPM
|
|
tags: [dotfiles, dotfiles:desktop, tmux, gnome]
|
|
ansible.builtin.shell: |
|
|
set -e
|
|
tmux start-server \; set-environment -g TMUX_PLUGIN_MANAGER_PATH "{{ user_home }}/.tmux/plugins/"
|
|
"{{ user_home }}/.tmux/plugins/tpm/bin/install_plugins"
|
|
become_user: "{{ username }}"
|
|
environment:
|
|
HOME: "{{ user_home }}"
|
|
register: gnome_tmux_plugin_install
|
|
changed_when: >-
|
|
(gnome_tmux_plugin_install.stdout | default('')) is search('download success') or
|
|
(gnome_tmux_plugin_install.stderr | default('')) is search('download success')
|
|
|
|
- name: Gather GNOME desktop user account data
|
|
tags: [gnome]
|
|
ansible.builtin.getent:
|
|
database: passwd
|
|
key: "{{ username }}"
|
|
when: (gnome_gsettings_settings | default([])) | length > 0
|
|
|
|
- name: Set GNOME desktop session environment
|
|
tags: [gnome]
|
|
ansible.builtin.set_fact:
|
|
gnome_user_uid: "{{ ansible_facts.getent_passwd[username][1] }}"
|
|
gnome_gsettings_environment:
|
|
HOME: "{{ user_home }}"
|
|
XDG_RUNTIME_DIR: "/run/user/{{ ansible_facts.getent_passwd[username][1] }}"
|
|
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ ansible_facts.getent_passwd[username][1] }}/bus"
|
|
when: (gnome_gsettings_settings | default([])) | length > 0
|
|
|
|
- name: Read current GNOME managed settings
|
|
tags: [gnome]
|
|
ansible.builtin.command:
|
|
argv:
|
|
- gsettings
|
|
- get
|
|
- "{{ item.schema }}{{ ':' ~ item.path if item.path is defined else '' }}"
|
|
- "{{ item.key }}"
|
|
become_user: "{{ username }}"
|
|
environment: "{{ gnome_gsettings_environment }}"
|
|
loop: "{{ gnome_gsettings_settings | default([]) }}"
|
|
loop_control:
|
|
label: >-
|
|
{{ item.schema }}{{ ':' ~ item.path if item.path is defined else '' }} {{ item.key }}
|
|
register: gnome_gsettings_current
|
|
changed_when: false
|
|
|
|
- name: Apply GNOME managed settings
|
|
tags: [gnome]
|
|
ansible.builtin.command:
|
|
argv:
|
|
- gsettings
|
|
- set
|
|
- "{{ item.item.schema }}{{ ':' ~ item.item.path if item.item.path is defined else '' }}"
|
|
- "{{ item.item.key }}"
|
|
- "{{ item.item.value }}"
|
|
become_user: "{{ username }}"
|
|
environment: "{{ gnome_gsettings_environment }}"
|
|
loop: "{{ gnome_gsettings_current.results | default([]) }}"
|
|
loop_control:
|
|
label: >-
|
|
{{ item.item.schema }}{{ ':' ~ item.item.path if item.item.path is defined else '' }} {{ item.item.key }}
|
|
changed_when: true
|
|
when: item.stdout | trim != item.item.value
|
|
|
|
- name: Check whether SSH host ed25519 key exists on GNOME desktop
|
|
tags: [services, gnome]
|
|
ansible.builtin.stat:
|
|
path: /etc/ssh/ssh_host_ed25519_key
|
|
register: gnome_ssh_host_ed25519_key
|
|
when:
|
|
- (host_sshd_settings | default({})) | length > 0
|
|
or (host_sshd_allow_users | default([])) | length > 0
|
|
|
|
- name: Generate missing SSH host keys on GNOME desktop
|
|
tags: [services, gnome]
|
|
ansible.builtin.command: ssh-keygen -A
|
|
changed_when: true
|
|
when:
|
|
- (host_sshd_settings | default({})) | length > 0
|
|
or (host_sshd_allow_users | default([])) | length > 0
|
|
- not gnome_ssh_host_ed25519_key.stat.exists
|
|
|
|
- name: Define safe GNOME SSH daemon settings
|
|
tags: [services, gnome]
|
|
ansible.builtin.set_fact:
|
|
gnome_sshd_settings_effective: >-
|
|
{{
|
|
host_sshd_settings | default({})
|
|
if (
|
|
(host_authorized_ssh_keys | default([])) | length > 0
|
|
or (host_sshd_settings | default({})).PasswordAuthentication | default('yes') != 'no'
|
|
)
|
|
else (
|
|
host_sshd_settings | default({}) | dict2items
|
|
| rejectattr('key', 'in', ['PasswordAuthentication', 'KbdInteractiveAuthentication'])
|
|
| items2dict
|
|
)
|
|
}}
|
|
|
|
- name: Warn when keeping SSH password authentication enabled on GNOME desktop
|
|
tags: [services, gnome]
|
|
ansible.builtin.debug:
|
|
msg: >-
|
|
SSH password authentication hardening was skipped because no authorized SSH
|
|
keys are defined for this host. Set host_authorized_ssh_keys via vault
|
|
variables, then re-run the playbook to disable password authentication.
|
|
when:
|
|
- "'sshd' in (host_enabled_services | default([]))"
|
|
- (host_sshd_settings | default({})).PasswordAuthentication | default('yes') == 'no'
|
|
- (host_authorized_ssh_keys | default([])) | length == 0
|
|
|
|
- name: Ensure GNOME desktop user authorized_keys file exists
|
|
tags: [services, dotfiles, gnome]
|
|
ansible.builtin.file:
|
|
path: "{{ user_home }}/.ssh/authorized_keys"
|
|
state: touch
|
|
owner: "{{ username }}"
|
|
group: "{{ user_group }}"
|
|
mode: "0600"
|
|
when: (host_authorized_ssh_keys | default([])) | length > 0
|
|
|
|
- name: Manage GNOME desktop user authorized SSH keys exclusively
|
|
tags: [services, dotfiles, gnome]
|
|
ansible.posix.authorized_key:
|
|
user: "{{ username }}"
|
|
key: "{{ host_authorized_ssh_keys | join('\n') }}"
|
|
state: present
|
|
exclusive: true
|
|
manage_dir: false
|
|
when: (host_authorized_ssh_keys | default([])) | length > 0
|
|
|
|
- name: Apply SSH daemon settings on GNOME desktop
|
|
tags: [services, gnome]
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/ssh/sshd_config
|
|
regexp: '^\s*{{ item.key }}\s+'
|
|
line: "{{ item.key }} {{ item.value }}"
|
|
state: present
|
|
validate: "sshd -t -f %s"
|
|
notify: Reload SSH service
|
|
loop: "{{ gnome_sshd_settings_effective | default({}) | dict2items }}"
|
|
loop_control:
|
|
label: "{{ item.key }}"
|
|
when: (gnome_sshd_settings_effective | default({})) | length > 0
|
|
|
|
- name: Restrict SSH login to allowed GNOME desktop users
|
|
tags: [services, gnome]
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/ssh/sshd_config
|
|
regexp: '^\s*AllowUsers\s+'
|
|
line: "AllowUsers {{ host_sshd_allow_users | join(' ') }}"
|
|
state: present
|
|
validate: "sshd -t -f %s"
|
|
notify: Reload SSH service
|
|
when: (host_sshd_allow_users | default([])) | length > 0
|
|
|
|
- name: Apply host firewalld rich rules on GNOME desktop
|
|
tags: [services, packages, gnome]
|
|
ansible.posix.firewalld:
|
|
rich_rule: "{{ item }}"
|
|
permanent: true
|
|
immediate: true
|
|
state: enabled
|
|
loop: "{{ host_firewalld_rich_rules | default([]) }}"
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
when: workstation_firewall_backend | default('firewalld') == 'firewalld'
|
|
|
|
- name: Configure Thunderbird for iCloud
|
|
tags: [dotfiles, dotfiles:desktop, gnome, thunderbird]
|
|
ansible.builtin.import_tasks: thunderbird.yml
|
|
when: thunderbird_icloud_enabled | default(false) | bool
|
|
|
|
- name: Configure native VS Code
|
|
tags: [vscode]
|
|
ansible.builtin.import_tasks: vscode.yml
|
|
|
|
- name: Pin Cline Desktop in GNOME
|
|
tags: [cline_desktop]
|
|
ansible.builtin.import_tasks: cline_desktop.yml
|
|
when: cline_desktop_install_enabled | default(false) | bool
|