51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
---
|
|||
|
|
- name: create media group
|
||
|
|
ansible.builtin.group:
|
||
|
|
name: media
|
||
|
|
gid: 1000
|
||
|
|
state: present
|
||
|
|
|
||
|
|
- name: install samba
|
||
|
|
ansible.builtin.apt:
|
||
|
|
name: samba
|
||
|
|
state: latest
|
||
|
|
update_cache: true
|
||
|
|
|
||
|
|
- name: create samba users
|
||
|
|
ansible.builtin.user:
|
||
|
|
name: "{{ hostvars[item].smb_user }}"
|
||
|
|
shell: /usr/sbin/nologin
|
||
|
|
groups: media
|
||
|
|
append: true
|
||
|
|
create_home: false
|
||
|
|
state: present
|
||
|
|
loop: "{{ smb_managed_group | default([]) }}"
|
||
|
|
loop_control:
|
||
|
|
label: "{{ item }}"
|
||
|
|
when: >
|
||
|
|
hostvars[item].smb_user is defined and
|
||
|
|
hostvars[item].smb_container is defined and
|
||
|
|
inventory_hostname in hostvars[item].smb_container
|
||
|
|
|
||
|
|
- name: set samba password for users
|
||
|
|
ansible.builtin.shell: |
|
||
|
|
printf '%s\n%s\n' "{{ hostvars[item].smb_password }}" "{{ hostvars[item].smb_password }}" | smbpasswd -s -a {{ hostvars[item].smb_user }}
|
||
|
|
loop: "{{ smb_managed_group | default([]) }}"
|
||
|
|
loop_control:
|
||
|
|
label: "{{ item }}"
|
||
|
|
when: >
|
||
|
|
hostvars[item].smb_user is defined and
|
||
|
|
hostvars[item].smb_password is defined and
|
||
|
|
hostvars[item].smb_container is defined and
|
||
|
|
inventory_hostname in hostvars[item].smb_container
|
||
|
|
changed_when: false
|
||
|
|
no_log: true
|
||
|
|
|
||
|
|
- name: deploy samba config
|
||
|
|
ansible.builtin.template:
|
||
|
|
src: "{{ inventory_hostname }}/smb.conf.j2"
|
||
|
|
dest: "/etc/samba/smb.conf"
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0644'
|
||
|
|
notify: restart samba
|