70 lines
1.9 KiB
YAML
70 lines
1.9 KiB
YAML
---
|
|
- name: "samba : install samba"
|
|
ansible.builtin.apt:
|
|
name:
|
|
- "samba"
|
|
- "samba-client"
|
|
|
|
- name: "samba : configure \"music-rip\" samba share"
|
|
ansible.builtin.blockinfile:
|
|
path: "/etc/samba/smb.conf"
|
|
mode: 0644
|
|
insertafter: "EOF"
|
|
marker: "# {mark} ANSIBLE MANAGED BLOCK MUSIC:RIP"
|
|
block: |
|
|
[music-rip]
|
|
comment = Music drive
|
|
path = {{ music_user_home_directory }}/rip
|
|
browseable = yes
|
|
read only = no
|
|
guest ok = no
|
|
create mask = 0644
|
|
directory mask = 0755
|
|
register: music_rip_samba_rip_config
|
|
|
|
- name: "samba : configure \"music-archive\" samba share"
|
|
ansible.builtin.blockinfile:
|
|
path: "/etc/samba/smb.conf"
|
|
mode: 0644
|
|
insertafter: "EOF"
|
|
marker: "# {mark} ANSIBLE MANAGED BLOCK MUSIC:ARCHIVE"
|
|
block: |
|
|
[music-archive]
|
|
comment = Music archive
|
|
path = {{ music_user_data_directory }}/flac
|
|
browseable = yes
|
|
read only = yes
|
|
register: music_rip_samba_archive_config
|
|
|
|
- name: "samba : check for \"{{ music_user_name }}\" user"
|
|
ansible.builtin.shell: "pdbedit --user={{ music_user_name }} || /usr/bin/true"
|
|
changed_when: false
|
|
register: music_rip_samba_pdb_state
|
|
|
|
- name: "samba : add \"{{ music_user_name }}\" user"
|
|
ansible.builtin.shell: |
|
|
(echo '{{ music_user_samba_password }}'; echo '{{ music_user_samba_password }}') |
|
|
smbpasswd -a {{ music_user_name }}
|
|
when:
|
|
not music_rip_samba_pdb_state.stdout is match('^' ~ music_user_name ~ ':')
|
|
|
|
- name: "samba : enable samba"
|
|
ansible.builtin.systemd:
|
|
name: "smbd"
|
|
enabled: true
|
|
|
|
- name: "samba : start samba"
|
|
ansible.builtin.systemd:
|
|
name: "smbd"
|
|
state: "started"
|
|
register: music_rip_samba_start
|
|
|
|
- name: "samba : restart samba"
|
|
ansible.builtin.systemd:
|
|
name: "smbd"
|
|
state: "restarted"
|
|
when:
|
|
(music_rip_samba_rip_config.changed or
|
|
music_rip_samba_archive_config.changed) and
|
|
not music_rip_samba_start.changed
|