Refactor Ansible tasks and templates for improved consistency and clarity

This commit is contained in:
2026-07-31 02:24:42 +02:00
parent 81ef678904
commit 46327da2ac
52 changed files with 1679 additions and 1461 deletions
+59 -55
View File
@@ -1,66 +1,71 @@
---
# Title: app-x11vnc-server
#
# Author: Luc Rutten
# Version: 1.0
# File: tasks/main.yml
#
# Description:
# Remote support
#
# Source:
# - http://c-nergy.be/blog/?p=8984
# Title: app-x11vnc-server
#
# Author: Luc Rutten
# Version: 1.0
# File: tasks/main.yml
#
# Description:
# Remote support
#
# Source:
# - http://c-nergy.be/blog/?p=8984
- name: "(ubuntu-x11vnc-2404-amd64.yml) Install packages"
apt:
name: "{{ packages }}"
update_cache: yes
state: present
vars:
packages:
- x11vnc
- name: "(ubuntu-x11vnc-2404-amd64.yml) Install packages"
ansible.builtin.apt:
name: "{{ packages }}"
update_cache: true
state: present
vars:
packages:
- x11vnc
- name: "(ubuntu-x11vnc-2404-amd64.yml) get numeric id for group 'gdm'"
shell: echo "$(id -u gdm)"
register: grp_id_gdm
- name: "(ubuntu-x11vnc-2404-amd64.yml) Get numeric id for group 'gdm'"
ansible.builtin.command: id -u gdm
register: common_grp_id_gdm
changed_when: false
- name: "(ubuntu-x11vnc-2404-amd64.yml) Store password"
raw: "x11vnc -storepasswd {{ vnc_password }} /etc/x11vnc.pass"
- name: "(ubuntu-x11vnc-2404-amd64.yml) Store password"
ansible.builtin.command: x11vnc -storepasswd {{ vnc_password }} /etc/x11vnc.pass
changed_when: true
- name: Check if file '/etc/gdm3/custom.conf' exists
stat:
path: /etc/gdm3/custom.conf
register: etc_gdm_custom_conf_exists
- name: Check if file '/etc/gdm3/custom.conf' exists
ansible.builtin.stat:
path: /etc/gdm3/custom.conf
register: common_etc_gdm_custom_conf_exists
- name: Adjust file '/etc/gdm3/custom.conf'
lineinfile:
dest: /etc/gdm3/custom.conf
state: present
regexp: '^WaylandEnable'
line: 'WaylandEnable=false'
insertafter: '^#?\s*WaylandEnable'
when:
- etc_gdm_custom_conf_exists.stat.exists
- name: Adjust file '/etc/gdm3/custom.conf'
ansible.builtin.lineinfile:
dest: /etc/gdm3/custom.conf
state: present
regexp: '^WaylandEnable'
line: 'WaylandEnable=false'
insertafter: '^#?\s*WaylandEnable'
when:
- common_etc_gdm_custom_conf_exists.stat.exists
- name: "(ubuntu-x11vnc-2404-amd64.yml) Set permissions on /etc/x11vnc.pass"
ansible.builtin.file:
path: /etc/x11vnc.pass
owner: root
group: root
mode: "0644"
state: file
- name: "(ubuntu-x11vnc-2404-amd64.yml) Set permissions on /etc/x11vnc.pass"
file:
path: /etc/x11vnc.pass
owner: root
group: root
mode: 0644
- name: "(ubuntu-x11vnc-2404-amd64.yml) Transfer x11vnc.service.j2 to /lib/systemd/system/x11vnc.service"
ansible.builtin.template:
src: lib/systemd/system/x11vnc-gdm3.service.j2
dest: /lib/systemd/system/x11vnc.service
owner: root
group: root
mode: "0644"
- name: "(ubuntu-x11vnc-2404-amd64.yml) Transfer x11vnc.service.j2 to /lib/systemd/system/x11vnc.service"
ansible.builtin.template:
src: lib/systemd/system/x11vnc-gdm3.service.j2
dest: /lib/systemd/system/x11vnc.service
- name: "(ubuntu-x11vnc-2404-amd64.yml) Enable service"
systemd:
name: x11vnc.service
daemon_reload: yes
enabled: yes
state: restarted
- name: "(ubuntu-x11vnc-2404-amd64.yml) Enable service"
ansible.builtin.systemd:
name: x11vnc.service
daemon_reload: true
enabled: true
state: restarted
# - name: "(ubuntu-x11vnc-2404-amd64.yml) Remove whisker menu entry for allusers (except owner and group)"
# file:
@@ -68,4 +73,3 @@
# mode: 0750
# owner: root
# group: root