From f6cc5f974667fe02c3bb5a01da1b81b07fae47f8 Mon Sep 17 00:00:00 2001 From: Bert Van Vreckem Date: Thu, 4 Oct 2018 23:15:28 +0200 Subject: [PATCH] Add code to install user defined custom config files --- tasks/main.yml | 28 ++++++++++++++++++++++++++++ vars/os_Archlinux.yml | 5 +++-- vars/os_Debian.yml | 5 +++-- vars/os_RedHat.yml | 5 +++-- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 6f619cc..cf0a26c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -85,6 +85,34 @@ notify: - Restart Samba services tags: samba + +- name: Install global include file + template: + src: "{{ samba_global_include }}" + dest: "{{ samba_configuration_dir }}" + validate: 'testparm -s %s' + when: samba_global_include is defined + notify: + - Restart Samba services + +- name: Install homes include file + template: + src: "{{ samba_homes_include }}" + dest: "{{ samba_configuration_dir }}" + validate: 'testparm -s %s' + when: samba_homes_include is defined + notify: + - Restart Samba services + +- name: Install share specific include files + template: + src: "{{ item.include_file }}" + dest: "{{ samba_configuration_dir }}" + validate: 'testparm -s %s' + when: item.include_file is defined + notify: + - Restart Samba services + with_items: "{{ samba_shares }}" - name: Create username map file if needed template: diff --git a/vars/os_Archlinux.yml b/vars/os_Archlinux.yml index 67934a8..b6c1bf6 100644 --- a/vars/os_Archlinux.yml +++ b/vars/os_Archlinux.yml @@ -10,8 +10,9 @@ samba_vfs_packages: [] samba_selinux_packages: [] samba_selinux_booleans: [] -samba_configuration: /etc/samba/smb.conf -samba_username_map_file: /etc/samba/smbusers +samba_configuration_dir: /etc/samba +samba_configuration: "{{ samba_configuration_dir }}/smb.conf" +samba_username_map_file: "{{ samba_configuration_dir }}/smbusers" samba_services: - smbd diff --git a/vars/os_Debian.yml b/vars/os_Debian.yml index 198ab3d..c0def0d 100644 --- a/vars/os_Debian.yml +++ b/vars/os_Debian.yml @@ -12,8 +12,9 @@ samba_vfs_packages: samba_selinux_packages: [] samba_selinux_booleans: [] -samba_configuration: /etc/samba/smb.conf -samba_username_map_file: /etc/samba/smbusers +samba_configuration_dir: /etc/samba +samba_configuration: "{{ samba_configuration_dir }}/smb.conf" +samba_username_map_file: "{{ samba_configuration_dir }}/smbusers" # The name of the Samba service in older releases (Ubuntu 14.04, # Debian <8) is "samba". diff --git a/vars/os_RedHat.yml b/vars/os_RedHat.yml index 41c03c9..372446f 100644 --- a/vars/os_RedHat.yml +++ b/vars/os_RedHat.yml @@ -15,8 +15,9 @@ samba_selinux_booleans: - samba_enable_home_dirs - samba_export_all_rw -samba_configuration: /etc/samba/smb.conf -samba_username_map_file: /etc/samba/smbusers +samba_configuration_dir: /etc/samba +samba_configuration: "{{ samba_configuration_dir }}/smb.conf" +samba_username_map_file: "{{ samba_configuration_dir }}/smbusers" samba_services: - smb