Refactor variable names in samba-config-server.yml for consistency and clarity

This commit is contained in:
2026-07-21 01:28:32 +02:00
parent 720fb84fb4
commit b40d3249fb
+24 -15
View File
@@ -63,7 +63,7 @@
patterns: patterns:
- "*.cvd" - "*.cvd"
- "*.cld" - "*.cld"
register: clamav_db_files register: common_clamav_db_files
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- samba_shares | selectattr('vfs_object_virusfilter', 'defined') | selectattr('vfs_object_virusfilter', 'equalto', true) | list | length > 0 - samba_shares | selectattr('vfs_object_virusfilter', 'defined') | selectattr('vfs_object_virusfilter', 'equalto', true) | list | length > 0
@@ -79,7 +79,7 @@
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- samba_shares | selectattr('vfs_object_virusfilter', 'defined') | selectattr('vfs_object_virusfilter', 'equalto', true) | list | length > 0 - samba_shares | selectattr('vfs_object_virusfilter', 'defined') | selectattr('vfs_object_virusfilter', 'equalto', true) | list | length > 0
- clamav_db_files.files | length == 0 - common_clamav_db_files.files | length == 0
tags: tags:
- samba-server - samba-server
- samba-virusfilter - samba-virusfilter
@@ -99,10 +99,11 @@
- name: (samba-config-server.yml) Download initial ClamAV virus databases via freshclam - name: (samba-config-server.yml) Download initial ClamAV virus databases via freshclam
ansible.builtin.command: freshclam ansible.builtin.command: freshclam
changed_when: true
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- samba_shares | selectattr('vfs_object_virusfilter', 'defined') | selectattr('vfs_object_virusfilter', 'equalto', true) | list | length > 0 - samba_shares | selectattr('vfs_object_virusfilter', 'defined') | selectattr('vfs_object_virusfilter', 'equalto', true) | list | length > 0
- clamav_db_files.files | length == 0 - common_clamav_db_files.files | length == 0
tags: tags:
- samba-server - samba-server
- samba-virusfilter - samba-virusfilter
@@ -170,7 +171,7 @@
loop: "{{ samba_user }}" loop: "{{ samba_user }}"
loop_control: loop_control:
label: "{{ item.name }}" label: "{{ item.name }}"
register: samba_user_getent register: common_samba_user_getent
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- samba_homes_virusfilter | default(false) | bool - samba_homes_virusfilter | default(false) | bool
@@ -233,17 +234,19 @@
- name: (samba-config-server.yml) Check if file '/etc/samba/smb.conf.ORIG exists' - name: (samba-config-server.yml) Check if file '/etc/samba/smb.conf.ORIG exists'
ansible.builtin.stat: ansible.builtin.stat:
path: /etc/samba/smb.conf.ORIG path: /etc/samba/smb.conf.ORIG
register: smb_conf_exists register: common_smb_conf_exists
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
tags: tags:
- samba-server - samba-server
- name: (samba-config-server.yml) Backup existing file /etc/samba/smb.conf - name: (samba-config-server.yml) Backup existing file /etc/samba/smb.conf
ansible.builtin.command: cp -a /etc/samba/smb.conf /etc/samba/smb.conf.ORIG ansible.builtin.command:
cmd: cp -a /etc/samba/smb.conf /etc/samba/smb.conf.ORIG
creates: /etc/samba/smb.conf.ORIG
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- smb_conf_exists.stat.exists == False - not common_smb_conf_exists.stat.exists
tags: tags:
- samba-server - samba-server
@@ -284,7 +287,7 @@
- name: (samba-config-server.yml) Check if file '/root/bin/samba/clean_samba_trash.sh' exists - name: (samba-config-server.yml) Check if file '/root/bin/samba/clean_samba_trash.sh' exists
ansible.builtin.stat: ansible.builtin.stat:
path: /root/bin/samba/clean_samba_trash.sh path: /root/bin/samba/clean_samba_trash.sh
register: clean_samba_trash_exists register: common_clean_samba_trash_exists
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
tags: tags:
@@ -295,9 +298,12 @@
ansible.builtin.template: ansible.builtin.template:
dest: /root/bin/samba/conf/clean_samba_trash.conf dest: /root/bin/samba/conf/clean_samba_trash.conf
src: root/bin/samba/conf/clean_samba_trash.conf.j2 src: root/bin/samba/conf/clean_samba_trash.conf.j2
owner: root
group: root
mode: "0644"
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- clean_samba_trash_exists.stat.exists|bool - common_clean_samba_trash_exists.stat.exists | bool
tags: tags:
- samba-server - samba-server
- samba-cron - samba-cron
@@ -309,7 +315,7 @@
state: absent state: absent
check_mode: true check_mode: true
changed_when: false changed_when: false
register: clean_samba_trash_dirs register: common_clean_samba_trash_dirs
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
tags: [samba-server, samba-cron] tags: [samba-server, samba-cron]
@@ -326,8 +332,8 @@
job: "{{ samba_cronjob_trash_dirs.job }}" job: "{{ samba_cronjob_trash_dirs.job }}"
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- clean_samba_trash_exists.stat.exists | bool - common_clean_samba_trash_exists.stat.exists | bool
- (clean_samba_trash_dirs.found | int) > 0 - (common_clean_samba_trash_dirs.found | int) > 0
tags: [samba-server, samba-cron] tags: [samba-server, samba-cron]
# --- # ---
@@ -337,7 +343,7 @@
- name: (samba-config-server.yml) Check if file '/root/bin/samba/set_permissions_samba_shares.sh' exists - name: (samba-config-server.yml) Check if file '/root/bin/samba/set_permissions_samba_shares.sh' exists
ansible.builtin.stat: ansible.builtin.stat:
path: /root/bin/samba/set_permissions_samba_shares.sh path: /root/bin/samba/set_permissions_samba_shares.sh
register: set_permissions_on_samba_shares_exists register: common_set_permissions_on_samba_shares_exists
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
tags: [samba-server, samba-cron] tags: [samba-server, samba-cron]
@@ -346,9 +352,12 @@
ansible.builtin.template: ansible.builtin.template:
dest: /root/bin/samba/conf/set_permissions_samba_shares.conf dest: /root/bin/samba/conf/set_permissions_samba_shares.conf
src: root/bin/samba/conf/set_permissions_samba_shares.conf.j2 src: root/bin/samba/conf/set_permissions_samba_shares.conf.j2
owner: root
group: root
mode: "0644"
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- set_permissions_on_samba_shares_exists.stat.exists | bool - common_set_permissions_on_samba_shares_exists.stat.exists | bool
tags: [samba-server, samba-cron] tags: [samba-server, samba-cron]
- name: (samba-config-server.yml) Creates a cron job for setting permissions to samba dirs - name: (samba-config-server.yml) Creates a cron job for setting permissions to samba dirs
@@ -363,5 +372,5 @@
job: "{{ samba_cronjob_permissions.job }}" job: "{{ samba_cronjob_permissions.job }}"
when: when:
- inventory_hostname in groups['samba_server'] - inventory_hostname in groups['samba_server']
- (clean_samba_trash_dirs.found | int) > 0 # << int -> bool - (common_clean_samba_trash_dirs.found | int) > 0 # << int -> bool
tags: [samba-server, samba-cron] tags: [samba-server, samba-cron]