diff --git a/roles/common/tasks/samba-config-server.yml b/roles/common/tasks/samba-config-server.yml index b63076f..669c8ef 100644 --- a/roles/common/tasks/samba-config-server.yml +++ b/roles/common/tasks/samba-config-server.yml @@ -63,7 +63,7 @@ patterns: - "*.cvd" - "*.cld" - register: clamav_db_files + register: common_clamav_db_files when: - inventory_hostname in groups['samba_server'] - samba_shares | selectattr('vfs_object_virusfilter', 'defined') | selectattr('vfs_object_virusfilter', 'equalto', true) | list | length > 0 @@ -79,7 +79,7 @@ when: - inventory_hostname in groups['samba_server'] - 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: - samba-server - samba-virusfilter @@ -99,10 +99,11 @@ - name: (samba-config-server.yml) Download initial ClamAV virus databases via freshclam ansible.builtin.command: freshclam + changed_when: true when: - inventory_hostname in groups['samba_server'] - 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: - samba-server - samba-virusfilter @@ -170,7 +171,7 @@ loop: "{{ samba_user }}" loop_control: label: "{{ item.name }}" - register: samba_user_getent + register: common_samba_user_getent when: - inventory_hostname in groups['samba_server'] - samba_homes_virusfilter | default(false) | bool @@ -233,17 +234,19 @@ - name: (samba-config-server.yml) Check if file '/etc/samba/smb.conf.ORIG exists' ansible.builtin.stat: path: /etc/samba/smb.conf.ORIG - register: smb_conf_exists + register: common_smb_conf_exists when: - inventory_hostname in groups['samba_server'] tags: - samba-server - 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: - inventory_hostname in groups['samba_server'] - - smb_conf_exists.stat.exists == False + - not common_smb_conf_exists.stat.exists tags: - samba-server @@ -284,7 +287,7 @@ - name: (samba-config-server.yml) Check if file '/root/bin/samba/clean_samba_trash.sh' exists ansible.builtin.stat: path: /root/bin/samba/clean_samba_trash.sh - register: clean_samba_trash_exists + register: common_clean_samba_trash_exists when: - inventory_hostname in groups['samba_server'] tags: @@ -295,9 +298,12 @@ ansible.builtin.template: dest: /root/bin/samba/conf/clean_samba_trash.conf src: root/bin/samba/conf/clean_samba_trash.conf.j2 + owner: root + group: root + mode: "0644" when: - inventory_hostname in groups['samba_server'] - - clean_samba_trash_exists.stat.exists|bool + - common_clean_samba_trash_exists.stat.exists | bool tags: - samba-server - samba-cron @@ -309,7 +315,7 @@ state: absent check_mode: true changed_when: false - register: clean_samba_trash_dirs + register: common_clean_samba_trash_dirs when: - inventory_hostname in groups['samba_server'] tags: [samba-server, samba-cron] @@ -326,8 +332,8 @@ job: "{{ samba_cronjob_trash_dirs.job }}" when: - inventory_hostname in groups['samba_server'] - - clean_samba_trash_exists.stat.exists | bool - - (clean_samba_trash_dirs.found | int) > 0 + - common_clean_samba_trash_exists.stat.exists | bool + - (common_clean_samba_trash_dirs.found | int) > 0 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 ansible.builtin.stat: 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: - inventory_hostname in groups['samba_server'] tags: [samba-server, samba-cron] @@ -346,9 +352,12 @@ ansible.builtin.template: dest: /root/bin/samba/conf/set_permissions_samba_shares.conf src: root/bin/samba/conf/set_permissions_samba_shares.conf.j2 + owner: root + group: root + mode: "0644" when: - 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] - name: (samba-config-server.yml) Creates a cron job for setting permissions to samba dirs @@ -363,5 +372,5 @@ job: "{{ samba_cronjob_permissions.job }}" when: - 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]