You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.2 KiB
YAML
58 lines
1.2 KiB
YAML
---
|
|
- name: Install samba packages using apt.
|
|
ansible.builtin.apt:
|
|
name:
|
|
- samba
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Ensure samba group exists.
|
|
ansible.builtin.group:
|
|
name: '{{ samba_group }}'
|
|
state: present
|
|
system: true
|
|
notify:
|
|
- reload-samba
|
|
|
|
- name: Ensure samba user.
|
|
ansible.builtin.user:
|
|
name: '{{ samba_user }}'
|
|
comment: Samba user
|
|
group: '{{ samba_group }}'
|
|
shell: /bin/false
|
|
create_home: false
|
|
notify:
|
|
- reload-samba
|
|
|
|
- name: Add the User(s) to Samba group.
|
|
ansible.builtin.user:
|
|
name: '{{ item.name }}'
|
|
groups: '{{ samba_group }}'
|
|
append: true
|
|
with_items: '{{ users }}'
|
|
|
|
- name: Ensure Share directories.
|
|
ansible.builtin.file:
|
|
path: '{{ item }}'
|
|
recurse: true
|
|
state: directory
|
|
owner: '{{ samba_user }}'
|
|
group: '{{ samba_group }}'
|
|
mode: u+rw,g+rw
|
|
with_items: '{{ shares }}'
|
|
notify:
|
|
- reload-samba
|
|
|
|
- name: Copy smb conf files.
|
|
ansible.builtin.copy:
|
|
src: '{{ item }}'
|
|
dest: "/etc/samba/{{ item }}"
|
|
mode: 0644
|
|
owner: "{{ samba_user }}"
|
|
group: "{{ samba_group }}"
|
|
with_items:
|
|
- smb.conf
|
|
- shares.conf
|
|
notify:
|
|
- reload-samba
|