2015-11-05 09:40:45 +00:00
|
|
|
# File: roles/samba/tasks/main.yml
|
2015-03-13 20:55:33 +00:00
|
|
|
---
|
|
|
|
|
2016-01-02 09:16:08 +00:00
|
|
|
- include_vars: "{{ item }}"
|
|
|
|
with_first_found:
|
|
|
|
- "os_{{ ansible_distribution }}.yml"
|
|
|
|
- "os_{{ ansible_os_family }}.yml"
|
2016-10-29 18:47:38 +00:00
|
|
|
tags: samba
|
2016-01-02 09:16:08 +00:00
|
|
|
|
2015-03-13 20:55:33 +00:00
|
|
|
- name: Install Samba packages
|
2016-05-12 07:48:59 +00:00
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items: "{{ samba_packages }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
tags: samba
|
|
|
|
|
2016-01-02 08:14:04 +00:00
|
|
|
- name: Install SELinux package
|
2016-05-12 07:48:59 +00:00
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items: "{{ samba_selinux_packages }}"
|
2017-05-09 11:46:38 +00:00
|
|
|
when: ansible_selinux is defined and ansible_selinux.status == 'enabled'
|
2016-10-29 18:47:38 +00:00
|
|
|
tags: samba
|
2016-01-02 08:14:04 +00:00
|
|
|
|
2015-03-13 20:55:33 +00:00
|
|
|
- name: Make sure SELinux boolean settings are correct
|
|
|
|
seboolean:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: yes
|
|
|
|
persistent: yes
|
2016-05-12 07:51:19 +00:00
|
|
|
with_items: "{{ samba_selinux_booleans }}"
|
2017-05-09 11:46:38 +00:00
|
|
|
when: ansible_selinux is defined and ansible_selinux.status == 'enabled'
|
2016-10-29 18:47:38 +00:00
|
|
|
tags: samba
|
2015-03-13 20:55:33 +00:00
|
|
|
|
2015-12-01 12:18:58 +00:00
|
|
|
- name: Create Samba shares root directory
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: "{{ samba_shares_root }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: '0755'
|
2016-05-12 08:01:50 +00:00
|
|
|
when: samba_shares
|
2015-12-01 13:57:56 +00:00
|
|
|
tags: samba
|
2015-12-01 12:18:58 +00:00
|
|
|
|
2015-03-13 20:55:33 +00:00
|
|
|
- name: Create share directories
|
2016-05-12 08:01:50 +00:00
|
|
|
with_items: "{{ samba_shares }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
file:
|
|
|
|
state: directory
|
2016-01-02 06:37:59 +00:00
|
|
|
path: "{{ item.path|default([samba_shares_root,item.name]|join('/')) }}"
|
2016-10-21 17:04:43 +00:00
|
|
|
owner: "{{ item.owner|default('root') }}"
|
2015-03-14 00:00:48 +00:00
|
|
|
group: "{{ item.group|default('users') }}"
|
2015-03-13 23:32:37 +00:00
|
|
|
mode: "{{ item.directory_mode|default('0775') }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
setype: "{{ item.setype|default('samba_share_t') }}"
|
|
|
|
tags: samba
|
|
|
|
|
2016-05-12 09:36:16 +00:00
|
|
|
- name: Ensure webserver document root exists
|
2016-05-12 08:19:00 +00:00
|
|
|
file:
|
|
|
|
name: "{{ samba_www_documentroot }}"
|
|
|
|
state: directory
|
2015-03-13 20:55:33 +00:00
|
|
|
tags: samba
|
|
|
|
|
2016-05-12 08:07:44 +00:00
|
|
|
- name: Create link to shares in webserver document root
|
2015-03-13 20:55:33 +00:00
|
|
|
file:
|
|
|
|
state: link
|
2016-05-12 08:07:44 +00:00
|
|
|
path: "{{ samba_www_documentroot }}/{{ item.name }}"
|
2016-01-02 06:37:59 +00:00
|
|
|
src: "{{ item.path|default([samba_shares_root,item.name]|join('/')) }}"
|
2016-05-12 08:01:50 +00:00
|
|
|
with_items: "{{ samba_shares }}"
|
2016-05-27 15:47:03 +00:00
|
|
|
when: samba_create_varwww_symlinks
|
2016-10-29 18:47:38 +00:00
|
|
|
tags: samba
|
2015-03-13 20:55:33 +00:00
|
|
|
|
2016-07-29 07:56:04 +00:00
|
|
|
- name: Samba configuration
|
|
|
|
template:
|
|
|
|
dest: "{{ samba_configuration }}"
|
|
|
|
src: smb.conf.j2
|
|
|
|
validate: 'testparm -s %s'
|
|
|
|
notify:
|
|
|
|
- Restart Samba
|
|
|
|
- Restart WinBind
|
|
|
|
tags: samba
|
|
|
|
|
2017-05-09 12:19:01 +00:00
|
|
|
- name: Start Samba service(s)
|
2015-03-13 20:55:33 +00:00
|
|
|
service:
|
2017-05-09 12:19:01 +00:00
|
|
|
name: "{{ item }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
state: started
|
|
|
|
enabled: yes
|
2017-05-09 12:19:01 +00:00
|
|
|
with_items: "{{ samba_services }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
tags: samba
|
|
|
|
|
|
|
|
- name: Create Samba users if they don't exist yet
|
|
|
|
shell: >
|
2016-12-01 20:24:21 +00:00
|
|
|
(pdbedit --user={{ item.name }} 2>&1 > /dev/null) \
|
2015-03-13 20:55:33 +00:00
|
|
|
|| (echo {{ item.password }}; echo {{ item.password }}) \
|
|
|
|
| smbpasswd -s -a {{ item.name }}
|
2016-05-12 08:01:50 +00:00
|
|
|
with_items: "{{ samba_users }}"
|
2016-05-29 07:50:49 +00:00
|
|
|
register: create_user_output
|
|
|
|
changed_when: "'Added user' in create_user_output.stdout"
|
2015-03-13 20:55:33 +00:00
|
|
|
tags: samba
|