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"
|
|
|
|
|
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 }}"
|
2016-01-02 08:14:04 +00:00
|
|
|
when: ansible_selinux
|
|
|
|
|
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 }}"
|
2016-01-02 08:14:04 +00:00
|
|
|
when: ansible_selinux
|
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('/')) }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
owner: 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 08:19:00 +00:00
|
|
|
- name: Ensute webserver document root exists
|
|
|
|
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 }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
tags: samba
|
|
|
|
|
|
|
|
- name: Samba configuration
|
|
|
|
template:
|
2016-05-12 08:19:00 +00:00
|
|
|
dest: "{{ samba_configuration }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
src: smb.conf.j2
|
|
|
|
validate: 'testparm -s %s'
|
2015-11-05 09:40:45 +00:00
|
|
|
notify:
|
|
|
|
- Restart Samba
|
|
|
|
- Restart WinBind
|
2015-03-13 20:55:33 +00:00
|
|
|
tags: samba
|
|
|
|
|
|
|
|
- name: Start Samba service
|
|
|
|
service:
|
2016-01-02 09:16:08 +00:00
|
|
|
name: "{{ samba_service }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
tags: samba
|
|
|
|
|
|
|
|
- name: Start WindBind service
|
|
|
|
service:
|
2016-01-02 09:16:08 +00:00
|
|
|
name: "{{ winbind_service }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
tags: samba
|
|
|
|
|
|
|
|
- name: Create Samba users if they don't exist yet
|
|
|
|
shell: >
|
|
|
|
(pdbedit -L | grep {{ item.name }} 2>&1 > /dev/null) \
|
|
|
|
|| (echo {{ item.password }}; echo {{ item.password }}) \
|
|
|
|
| smbpasswd -s -a {{ item.name }}
|
2016-05-12 08:01:50 +00:00
|
|
|
with_items: "{{ samba_users }}"
|
2015-03-13 20:55:33 +00:00
|
|
|
tags: samba
|