mirror of
https://github.com/fscotto/infra.git
synced 2026-09-27 19:03:47 +00:00
Refactor workstation to Fedora WSL target
This commit is contained in:
@@ -25,47 +25,6 @@
|
||||
- "'workstation_dev_fedora' in group_names"
|
||||
- fedora_manage_docker_repo | default(false)
|
||||
|
||||
- name: Configure Google Chrome repository on Fedora
|
||||
tags: [packages]
|
||||
ansible.builtin.yum_repository:
|
||||
name: google-chrome
|
||||
description: Google Chrome
|
||||
baseurl: "https://dl.google.com/linux/chrome/rpm/stable/$basearch"
|
||||
enabled: true
|
||||
gpgcheck: true
|
||||
gpgkey: https://dl.google.com/linux/linux_signing_key.pub
|
||||
state: present
|
||||
when:
|
||||
- workstation_manage_google_chrome | default(false)
|
||||
- fedora_manage_google_chrome_repo | default(false)
|
||||
|
||||
- name: Configure Visual Studio Code repository on Fedora
|
||||
tags: [packages, vscode]
|
||||
ansible.builtin.yum_repository:
|
||||
name: vscode
|
||||
description: Visual Studio Code
|
||||
baseurl: https://packages.microsoft.com/yumrepos/vscode
|
||||
enabled: true
|
||||
gpgcheck: true
|
||||
gpgkey: https://packages.microsoft.com/keys/microsoft.asc
|
||||
state: present
|
||||
when:
|
||||
- "'workstation_host_linux' in group_names"
|
||||
- fedora_manage_vscode_repo | default(false)
|
||||
|
||||
- name: Configure IntelliJ IDEA COPR repository on Fedora
|
||||
tags: [packages]
|
||||
ansible.builtin.get_url:
|
||||
url: >-
|
||||
https://copr.fedorainfracloud.org/coprs/{{ fedora_intellij_copr_owner }}/{{ fedora_intellij_copr_project }}/repo/fedora-{{ ansible_facts['distribution_major_version'] }}/{{ fedora_intellij_copr_owner }}-{{ fedora_intellij_copr_project }}-fedora-{{ ansible_facts['distribution_major_version'] }}.repo
|
||||
dest: /etc/yum.repos.d/{{ fedora_intellij_copr_owner }}-{{ fedora_intellij_copr_project }}-fedora-{{ ansible_facts['distribution_major_version'] }}.repo
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when:
|
||||
- "'workstation_host_linux' in group_names"
|
||||
- fedora_manage_intellij_repo | default(false)
|
||||
|
||||
- name: Refresh dnf package metadata
|
||||
tags: [packages]
|
||||
ansible.builtin.dnf:
|
||||
@@ -84,11 +43,6 @@
|
||||
if 'workstation_dev_fedora' in group_names
|
||||
else []
|
||||
)
|
||||
+ (
|
||||
['google-chrome-stable']
|
||||
if workstation_manage_google_chrome | default(false)
|
||||
else []
|
||||
)
|
||||
+ (profile_packages | default([]))
|
||||
+ (
|
||||
(fedora_desktop_packages | default([]))
|
||||
@@ -103,7 +57,7 @@
|
||||
else []
|
||||
)
|
||||
+ (
|
||||
(fedora_workstation_dev_packages | default(workstation_dev_packages | default([])))
|
||||
(fedora_dev_packages | default([]))
|
||||
if 'workstation_dev_fedora' in group_names
|
||||
else []
|
||||
)
|
||||
@@ -112,19 +66,6 @@
|
||||
if 'workstation_dev_wsl' in group_names
|
||||
else []
|
||||
)
|
||||
+ (
|
||||
(workstation_host_linux_packages_fedora | default(workstation_host_linux_packages | default([])))
|
||||
if 'workstation_host_linux' in group_names
|
||||
else []
|
||||
)
|
||||
+ (
|
||||
[fedora_intellij_package_name]
|
||||
if (
|
||||
'workstation_host_linux' in group_names
|
||||
and fedora_manage_intellij_repo | default(false)
|
||||
)
|
||||
else []
|
||||
)
|
||||
+ (host_packages | default([]))
|
||||
)
|
||||
| difference(fedora_excluded_packages | default([]))
|
||||
@@ -139,100 +80,6 @@
|
||||
state: absent
|
||||
when: (fedora_removed_packages | default([])) | length > 0
|
||||
|
||||
- name: Ensure architecture is supported for LazyGit release
|
||||
tags: [packages]
|
||||
ansible.builtin.fail:
|
||||
msg: "Unsupported architecture {{ ansible_facts['architecture'] }} for LazyGit release"
|
||||
when:
|
||||
- fedora_manage_lazygit | default(false)
|
||||
- ansible_facts['architecture'] not in ['x86_64', 'aarch64', 'arm64']
|
||||
|
||||
- name: Read installed LazyGit version
|
||||
tags: [packages]
|
||||
ansible.builtin.command: /usr/local/bin/lazygit --version
|
||||
register: fedora_lazygit_version_check
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: false
|
||||
when: fedora_manage_lazygit | default(false)
|
||||
|
||||
- name: Ensure temporary LazyGit extraction directory is absent
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/lazygit_{{ fedora_lazygit_version }}"
|
||||
state: absent
|
||||
when:
|
||||
- fedora_manage_lazygit | default(false)
|
||||
- fedora_lazygit_version not in (fedora_lazygit_version_check.stdout | default(''))
|
||||
|
||||
- name: Create temporary LazyGit extraction directory
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/lazygit_{{ fedora_lazygit_version }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
when:
|
||||
- fedora_manage_lazygit | default(false)
|
||||
- fedora_lazygit_version not in (fedora_lazygit_version_check.stdout | default(''))
|
||||
|
||||
- name: Download LazyGit release archive
|
||||
tags: [packages]
|
||||
ansible.builtin.get_url:
|
||||
url: >-
|
||||
https://github.com/jesseduffield/lazygit/releases/download/v{{ fedora_lazygit_version }}/lazygit_{{
|
||||
fedora_lazygit_version }}_Linux_{{
|
||||
'x86_64' if ansible_facts['architecture'] == 'x86_64'
|
||||
else 'arm64'
|
||||
}}.tar.gz
|
||||
dest: "/tmp/lazygit_{{ fedora_lazygit_version }}.tar.gz"
|
||||
mode: "0644"
|
||||
when:
|
||||
- fedora_manage_lazygit | default(false)
|
||||
- fedora_lazygit_version not in (fedora_lazygit_version_check.stdout | default(''))
|
||||
|
||||
- name: Extract LazyGit release archive
|
||||
tags: [packages]
|
||||
ansible.builtin.unarchive:
|
||||
src: "/tmp/lazygit_{{ fedora_lazygit_version }}.tar.gz"
|
||||
dest: "/tmp/lazygit_{{ fedora_lazygit_version }}"
|
||||
remote_src: true
|
||||
when:
|
||||
- fedora_manage_lazygit | default(false)
|
||||
- fedora_lazygit_version not in (fedora_lazygit_version_check.stdout | default(''))
|
||||
|
||||
- name: Install LazyGit binary
|
||||
tags: [packages]
|
||||
ansible.builtin.copy:
|
||||
src: "/tmp/lazygit_{{ fedora_lazygit_version }}/lazygit"
|
||||
dest: /usr/local/bin/lazygit
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
remote_src: true
|
||||
when:
|
||||
- fedora_manage_lazygit | default(false)
|
||||
- fedora_lazygit_version not in (fedora_lazygit_version_check.stdout | default(''))
|
||||
|
||||
- name: Remove downloaded LazyGit archive
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/lazygit_{{ fedora_lazygit_version }}.tar.gz"
|
||||
state: absent
|
||||
when:
|
||||
- fedora_manage_lazygit | default(false)
|
||||
- fedora_lazygit_version not in (fedora_lazygit_version_check.stdout | default(''))
|
||||
|
||||
- name: Remove temporary LazyGit extraction directory
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/lazygit_{{ fedora_lazygit_version }}"
|
||||
state: absent
|
||||
when:
|
||||
- fedora_manage_lazygit | default(false)
|
||||
- fedora_lazygit_version not in (fedora_lazygit_version_check.stdout | default(''))
|
||||
|
||||
- name: Add user to docker group
|
||||
tags: [packages]
|
||||
ansible.builtin.user:
|
||||
@@ -262,11 +109,6 @@
|
||||
(
|
||||
(fedora_flatpak_packages | default([]))
|
||||
+ (host_flatpak_packages | default([]))
|
||||
+ (
|
||||
(workstation_flatpak_packages | default([]))
|
||||
if 'workstation_host_linux' in group_names
|
||||
else []
|
||||
)
|
||||
)
|
||||
| unique
|
||||
}}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
---
|
||||
- name: Gather installed package facts
|
||||
tags: [packages]
|
||||
ansible.builtin.package_facts:
|
||||
manager: auto
|
||||
|
||||
- name: Copy Ubuntu dotfiles
|
||||
tags: [dotfiles, dotfiles:common]
|
||||
ansible.builtin.copy:
|
||||
@@ -16,75 +11,6 @@
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
|
||||
- name: Ensure architecture is supported for Google Chrome
|
||||
tags: [packages]
|
||||
ansible.builtin.fail:
|
||||
msg: "Unsupported architecture {{ ansible_facts['architecture'] }} for Google Chrome stable package"
|
||||
when:
|
||||
- workstation_manage_google_chrome | default(false)
|
||||
- ansible_facts['architecture'] != 'x86_64'
|
||||
|
||||
- name: Download Google Chrome Debian package
|
||||
tags: [packages]
|
||||
ansible.builtin.get_url:
|
||||
url: https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
||||
dest: /tmp/google-chrome-stable_current_amd64.deb
|
||||
mode: "0644"
|
||||
when:
|
||||
- workstation_manage_google_chrome | default(false)
|
||||
- "'google-chrome-stable' not in (ansible_facts.packages | default({}))"
|
||||
|
||||
- name: Install Google Chrome from downloaded Debian package
|
||||
tags: [packages]
|
||||
ansible.builtin.apt:
|
||||
deb: /tmp/google-chrome-stable_current_amd64.deb
|
||||
state: present
|
||||
when:
|
||||
- workstation_manage_google_chrome | default(false)
|
||||
- "'google-chrome-stable' not in (ansible_facts.packages | default({}))"
|
||||
|
||||
- name: Remove downloaded Google Chrome Debian package
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: /tmp/google-chrome-stable_current_amd64.deb
|
||||
state: absent
|
||||
when:
|
||||
- workstation_manage_google_chrome | default(false)
|
||||
- "'google-chrome-stable' not in (ansible_facts.packages | default({}))"
|
||||
|
||||
- name: Download glab Debian package
|
||||
tags: [packages]
|
||||
ansible.builtin.get_url:
|
||||
url: >-
|
||||
https://gitlab.com/gitlab-org/cli/-/releases/v{{ workstation_glab_version }}/downloads/glab_{{ workstation_glab_version }}_linux_{{
|
||||
'amd64' if ansible_facts['architecture'] == 'x86_64'
|
||||
else 'arm64' if ansible_facts['architecture'] in ['aarch64', 'arm64']
|
||||
else ansible_facts['architecture']
|
||||
}}.deb
|
||||
dest: "/tmp/glab_{{ workstation_glab_version }}.deb"
|
||||
mode: "0644"
|
||||
when:
|
||||
- workstation_manage_glab | default(false)
|
||||
- ansible_facts.packages['glab'] is not defined or ansible_facts.packages['glab'][0].version != workstation_glab_version
|
||||
|
||||
- name: Install glab from downloaded Debian package
|
||||
tags: [packages]
|
||||
ansible.builtin.apt:
|
||||
deb: "/tmp/glab_{{ workstation_glab_version }}.deb"
|
||||
state: present
|
||||
when:
|
||||
- workstation_manage_glab | default(false)
|
||||
- ansible_facts.packages['glab'] is not defined or ansible_facts.packages['glab'][0].version != workstation_glab_version
|
||||
|
||||
- name: Remove downloaded glab Debian package
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/glab_{{ workstation_glab_version }}.deb"
|
||||
state: absent
|
||||
when:
|
||||
- workstation_manage_glab | default(false)
|
||||
- ansible_facts.packages['glab'] is not defined or ansible_facts.packages['glab'][0].version != workstation_glab_version
|
||||
|
||||
- name: Ensure Docker apt keyrings directory exists
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
@@ -141,25 +67,8 @@
|
||||
if (emacs_enabled | default(false) | bool)
|
||||
else []
|
||||
)
|
||||
+ (workstation_dev_packages | default([]))
|
||||
+ (
|
||||
(workstation_host_linux_packages | default([]))
|
||||
if 'workstation_host_linux' in group_names
|
||||
else []
|
||||
)
|
||||
+ (
|
||||
(workstation_dev_wsl_packages | default([]))
|
||||
if 'workstation_dev_wsl' in group_names
|
||||
else []
|
||||
)
|
||||
+ (desktop_common_packages | default([]))
|
||||
+ (host_packages | default([]))
|
||||
)
|
||||
| difference(
|
||||
(workstation_dev_wsl_excluded_packages | default([]))
|
||||
if 'workstation_dev_wsl' in group_names
|
||||
else []
|
||||
)
|
||||
| unique
|
||||
}}
|
||||
state: present
|
||||
@@ -171,127 +80,3 @@
|
||||
groups: docker
|
||||
append: true
|
||||
when: (ubuntu_docker_packages | default([])) | length > 0
|
||||
|
||||
- name: Ensure architecture is supported for croc GitHub release
|
||||
tags: [packages]
|
||||
ansible.builtin.fail:
|
||||
msg: "Unsupported architecture {{ ansible_facts['architecture'] }} for croc GitHub release"
|
||||
when:
|
||||
- workstation_manage_croc | default(false)
|
||||
- ansible_facts['architecture'] not in ['x86_64', 'aarch64', 'arm64']
|
||||
|
||||
- name: Read installed croc version
|
||||
tags: [packages]
|
||||
ansible.builtin.command: /usr/local/bin/croc --version
|
||||
register: croc_version_check
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: false
|
||||
when: workstation_manage_croc | default(false)
|
||||
|
||||
- name: Ensure temporary croc extraction directory is absent
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/croc_{{ workstation_croc_version }}"
|
||||
state: absent
|
||||
when:
|
||||
- workstation_manage_croc | default(false)
|
||||
- workstation_croc_version not in (croc_version_check.stdout | default(''))
|
||||
|
||||
- name: Create temporary croc extraction directory
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/croc_{{ workstation_croc_version }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
when:
|
||||
- workstation_manage_croc | default(false)
|
||||
- workstation_croc_version not in (croc_version_check.stdout | default(''))
|
||||
|
||||
- name: Download croc GitHub release archive
|
||||
tags: [packages]
|
||||
ansible.builtin.get_url:
|
||||
url: >-
|
||||
{{
|
||||
'https://github.com/schollz/croc/releases/download/'
|
||||
~ workstation_croc_version
|
||||
~ '/croc_'
|
||||
~ workstation_croc_version
|
||||
~ '_Linux-'
|
||||
~ (
|
||||
'64bit' if ansible_facts['architecture'] == 'x86_64'
|
||||
else 'ARM64' if ansible_facts['architecture'] in ['aarch64', 'arm64']
|
||||
else ansible_facts['architecture']
|
||||
)
|
||||
~ '.tar.gz'
|
||||
}}
|
||||
dest: "/tmp/croc_{{ workstation_croc_version }}.tar.gz"
|
||||
mode: "0644"
|
||||
when:
|
||||
- workstation_manage_croc | default(false)
|
||||
- workstation_croc_version not in (croc_version_check.stdout | default(''))
|
||||
|
||||
- name: Extract croc GitHub release archive
|
||||
tags: [packages]
|
||||
ansible.builtin.unarchive:
|
||||
src: "/tmp/croc_{{ workstation_croc_version }}.tar.gz"
|
||||
dest: "/tmp/croc_{{ workstation_croc_version }}"
|
||||
remote_src: true
|
||||
when:
|
||||
- workstation_manage_croc | default(false)
|
||||
- workstation_croc_version not in (croc_version_check.stdout | default(''))
|
||||
|
||||
- name: Install croc binary
|
||||
tags: [packages]
|
||||
ansible.builtin.copy:
|
||||
src: "/tmp/croc_{{ workstation_croc_version }}/croc"
|
||||
dest: /usr/local/bin/croc
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
remote_src: true
|
||||
when:
|
||||
- workstation_manage_croc | default(false)
|
||||
- workstation_croc_version not in (croc_version_check.stdout | default(''))
|
||||
|
||||
- name: Remove downloaded croc archive
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/croc_{{ workstation_croc_version }}.tar.gz"
|
||||
state: absent
|
||||
when:
|
||||
- workstation_manage_croc | default(false)
|
||||
- workstation_croc_version not in (croc_version_check.stdout | default(''))
|
||||
|
||||
- name: Remove temporary croc extraction directory
|
||||
tags: [packages]
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/croc_{{ workstation_croc_version }}"
|
||||
state: absent
|
||||
when:
|
||||
- workstation_manage_croc | default(false)
|
||||
- workstation_croc_version not in (croc_version_check.stdout | default(''))
|
||||
|
||||
- name: Remove workstation snap packages
|
||||
tags: [packages]
|
||||
community.general.snap:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
loop: "{{ workstation_removed_snap_packages | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
when: (workstation_removed_snap_packages | default([])) | length > 0
|
||||
|
||||
- name: Install workstation snap packages
|
||||
tags: [packages]
|
||||
community.general.snap:
|
||||
name: "{{ item.name }}"
|
||||
classic: "{{ item.classic | default(false) }}"
|
||||
channel: "{{ item.channel | default(omit) }}"
|
||||
state: present
|
||||
loop: "{{ workstation_snap_packages | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: (workstation_snap_packages | default([])) | length > 0
|
||||
|
||||
@@ -76,15 +76,6 @@
|
||||
register: workstation_wsl_systemd_config
|
||||
when: workstation_wsl_systemd_enabled | default(false)
|
||||
|
||||
- name: Install WSL Python packages for Windows remoting
|
||||
tags: [packages]
|
||||
ansible.builtin.pip:
|
||||
name: "{{ workstation_dev_wsl_python_packages | default([]) }}"
|
||||
executable: pip3
|
||||
extra_args: --break-system-packages
|
||||
state: present
|
||||
when: (workstation_dev_wsl_python_packages | default([])) | length > 0
|
||||
|
||||
- name: Note when WSL must be restarted
|
||||
tags: [packages, services]
|
||||
ansible.builtin.debug:
|
||||
|
||||
@@ -1,262 +0,0 @@
|
||||
---
|
||||
- name: Copy workstation host Linux dotfiles
|
||||
tags: [dotfiles, dotfiles:workstation, gnome]
|
||||
ansible.builtin.copy:
|
||||
src: "{{ playbook_dir }}/../dotfiles/workstation_host_linux/{{ item.src }}"
|
||||
dest: "{{ user_home }}/{{ item.dest }}"
|
||||
owner: "{{ username }}"
|
||||
group: "{{ user_group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop: "{{ workstation_host_linux_dotfiles | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
|
||||
- name: Ensure GNOME extension directories exist
|
||||
tags: [packages, gnome]
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ username }}"
|
||||
group: "{{ user_group }}"
|
||||
mode: "0755"
|
||||
loop:
|
||||
- "{{ user_home }}/.cache/gnome-shell/extensions"
|
||||
- "{{ user_home }}/.local/share/gnome-shell/extensions"
|
||||
|
||||
- name: Gather workstation user account data
|
||||
tags: [packages, gnome]
|
||||
ansible.builtin.getent:
|
||||
database: passwd
|
||||
key: "{{ username }}"
|
||||
|
||||
- name: Set workstation GNOME session environment
|
||||
tags: [packages, gnome]
|
||||
ansible.builtin.set_fact:
|
||||
workstation_user_uid: "{{ ansible_facts.getent_passwd[username][1] }}"
|
||||
workstation_gnome_extension_dir: "{{ user_home }}/.cache/gnome-shell/extensions"
|
||||
workstation_gnome_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"
|
||||
|
||||
- name: Read current workstation 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: "{{ workstation_gnome_environment }}"
|
||||
loop: "{{ workstation_gnome_managed_settings | default([]) }}"
|
||||
loop_control:
|
||||
label: >-
|
||||
{{ item.schema }}{{ ':' ~ item.path if item.path is defined else '' }} {{ item.key }}
|
||||
register: workstation_gnome_managed_settings_current
|
||||
changed_when: false
|
||||
|
||||
- name: Apply workstation 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: "{{ workstation_gnome_environment }}"
|
||||
loop: "{{ workstation_gnome_managed_settings_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: Apply workstation GNOME extension dconf settings
|
||||
tags: [gnome]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- dconf
|
||||
- write
|
||||
- "{{ item.path }}{{ item.key }}"
|
||||
- "{{ item.value }}"
|
||||
become_user: "{{ username }}"
|
||||
loop: "{{ workstation_gnome_extension_dconf_settings | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}{{ item.key }}"
|
||||
changed_when: true
|
||||
|
||||
- name: Check whether VS Code CLI is available on workstation host
|
||||
tags: [packages, vscode]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- code
|
||||
- --version
|
||||
become_user: "{{ username }}"
|
||||
environment:
|
||||
HOME: "{{ user_home }}"
|
||||
register: workstation_vscode_cli
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: (workstation_host_vscode_extensions | default([])) | length > 0
|
||||
|
||||
- name: Ensure VS Code CLI is available before managing extensions
|
||||
tags: [packages, vscode]
|
||||
ansible.builtin.fail:
|
||||
msg: Ensure Visual Studio Code is installed before managing workstation VS Code extensions.
|
||||
when:
|
||||
- (workstation_host_vscode_extensions | default([])) | length > 0
|
||||
- workstation_vscode_cli.rc != 0
|
||||
|
||||
- name: Read installed VS Code extensions on workstation host
|
||||
tags: [packages, vscode]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- code
|
||||
- --list-extensions
|
||||
become_user: "{{ username }}"
|
||||
environment:
|
||||
HOME: "{{ user_home }}"
|
||||
register: workstation_vscode_extensions_current
|
||||
changed_when: false
|
||||
when:
|
||||
- (workstation_host_vscode_extensions | default([])) | length > 0
|
||||
- workstation_vscode_cli.rc == 0
|
||||
|
||||
- name: Install VS Code extensions on workstation host
|
||||
tags: [packages, vscode]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- code
|
||||
- --install-extension
|
||||
- "{{ item }}"
|
||||
- --force
|
||||
become_user: "{{ username }}"
|
||||
environment:
|
||||
HOME: "{{ user_home }}"
|
||||
loop: "{{ workstation_host_vscode_extensions | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
when:
|
||||
- workstation_vscode_cli.rc == 0
|
||||
- item not in (workstation_vscode_extensions_current.stdout_lines | default([]))
|
||||
|
||||
- name: Download workstation GNOME extension archives
|
||||
tags: [packages, gnome]
|
||||
ansible.builtin.get_url:
|
||||
url: >-
|
||||
https://extensions.gnome.org/download-extension/{{ item.uuid }}.shell-extension.zip?version_tag={{ item.version_tag }}
|
||||
dest: "{{ workstation_gnome_extension_dir }}/{{ item.uuid }}.zip"
|
||||
owner: "{{ username }}"
|
||||
group: "{{ user_group }}"
|
||||
mode: "0644"
|
||||
loop: "{{ workstation_gnome_extensions | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.uuid }}"
|
||||
|
||||
- name: Check installed workstation GNOME extensions
|
||||
tags: [packages, gnome]
|
||||
ansible.builtin.stat:
|
||||
path: "{{ user_home }}/.local/share/gnome-shell/extensions/{{ item.uuid }}/metadata.json"
|
||||
loop: "{{ workstation_gnome_extensions | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.uuid }}"
|
||||
register: workstation_gnome_extension_install_state
|
||||
|
||||
- name: Install workstation GNOME extensions from downloaded archives
|
||||
tags: [packages, gnome]
|
||||
ansible.builtin.command:
|
||||
cmd: "gnome-extensions install --force {{ workstation_gnome_extension_dir }}/{{ item.uuid }}.zip"
|
||||
become_user: "{{ username }}"
|
||||
environment: "{{ workstation_gnome_environment }}"
|
||||
loop: "{{ workstation_gnome_extensions | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.uuid }}"
|
||||
when: >-
|
||||
not (
|
||||
workstation_gnome_extension_install_state.results
|
||||
| selectattr('item.uuid', 'equalto', item.uuid)
|
||||
| map(attribute='stat.exists')
|
||||
| first
|
||||
| default(false)
|
||||
)
|
||||
|
||||
- name: Read current workstation GNOME enabled extensions
|
||||
tags: [gnome]
|
||||
ansible.builtin.command:
|
||||
cmd: gsettings get org.gnome.shell enabled-extensions
|
||||
become_user: "{{ username }}"
|
||||
environment: "{{ workstation_gnome_environment }}"
|
||||
register: workstation_enabled_gnome_extensions_current
|
||||
changed_when: false
|
||||
|
||||
- name: Compute desired workstation GNOME enabled extensions
|
||||
tags: [gnome]
|
||||
ansible.builtin.set_fact:
|
||||
workstation_enabled_gnome_extensions_current_list: >-
|
||||
{{
|
||||
(
|
||||
workstation_enabled_gnome_extensions_current.stdout
|
||||
| default('')
|
||||
| regex_search('\[.*\]')
|
||||
| default('[]', true)
|
||||
)
|
||||
| from_yaml
|
||||
}}
|
||||
|
||||
- name: Build desired workstation GNOME enabled extensions list
|
||||
tags: [gnome]
|
||||
ansible.builtin.set_fact:
|
||||
workstation_enabled_gnome_extensions_desired: >-
|
||||
{{
|
||||
(
|
||||
workstation_enabled_gnome_extensions_current_list
|
||||
+ (
|
||||
workstation_gnome_extensions
|
||||
| default([])
|
||||
| selectattr('enabled', 'defined')
|
||||
| selectattr('enabled')
|
||||
| map(attribute='uuid')
|
||||
| list
|
||||
)
|
||||
)
|
||||
| difference(workstation_disabled_gnome_extensions | default([]))
|
||||
| unique
|
||||
| sort
|
||||
}}
|
||||
|
||||
- name: Build workstation GNOME extensions gsettings payload
|
||||
tags: [gnome]
|
||||
ansible.builtin.set_fact:
|
||||
workstation_enabled_gnome_extensions_desired_gsettings: >-
|
||||
[{% for extension_uuid in workstation_enabled_gnome_extensions_desired -%}
|
||||
'{{ extension_uuid | replace("'", "\\'") }}'{% if not loop.last %}, {% endif %}
|
||||
{%- endfor %}]
|
||||
|
||||
- name: Determine whether workstation GNOME enabled extensions must change
|
||||
tags: [gnome]
|
||||
ansible.builtin.set_fact:
|
||||
workstation_gnome_extensions_state_changed: >-
|
||||
{{ (workstation_enabled_gnome_extensions_current_list | sort) != workstation_enabled_gnome_extensions_desired }}
|
||||
|
||||
- name: Apply workstation GNOME enabled extensions list
|
||||
tags: [gnome]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- gsettings
|
||||
- set
|
||||
- org.gnome.shell
|
||||
- enabled-extensions
|
||||
- "{{ workstation_enabled_gnome_extensions_desired_gsettings }}"
|
||||
become_user: "{{ username }}"
|
||||
environment: "{{ workstation_gnome_environment }}"
|
||||
changed_when: workstation_gnome_extensions_state_changed
|
||||
when: workstation_gnome_extensions_state_changed
|
||||
|
||||
- name: Enable UFW firewall on workstation
|
||||
tags: [services, packages]
|
||||
community.general.ufw:
|
||||
state: enabled
|
||||
when: workstation_firewall_backend | default('ufw') == 'ufw'
|
||||
Reference in New Issue
Block a user