ansible-edda/playbooks/roles/music/rip/tasks/include/samba.yml

121 lines
3.5 KiB
YAML
Raw Normal View History

2023-02-19 21:12:16 +01:00
---
- name: "samba : install samba"
ansible.builtin.apt:
name:
- "samba"
- "samba-client"
2023-05-15 21:51:27 +02:00
- name: "samba : configure \"music-download\" samba share"
ansible.builtin.blockinfile:
path: "/etc/samba/smb.conf"
mode: 0644
insertafter: "EOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK MUSIC:DOWNLOAD"
block: |
[music-download]
comment = Music drive
path = {{ music_user_home_directory }}/download
browseable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
register: music_rip_samba_download_config
2023-02-26 00:21:00 +01:00
- name: "samba : configure \"music-rip\" samba share"
2023-02-19 21:12:16 +01:00
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
2023-02-26 00:21:00 +01:00
register: music_rip_samba_rip_config
2023-04-06 14:07:13 +02:00
- name: "samba : configure \"music-dvd\" samba share"
ansible.builtin.blockinfile:
path: "/etc/samba/smb.conf"
mode: 0644
insertafter: "EOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK MUSIC:DVD"
block: |
[music-dvd]
comment = DVD drive
path = {{ music_user_home_directory }}/dvd
browseable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
register: music_rip_samba_dvd_config
2023-03-01 20:14:12 +01:00
- name: "samba : configure \"music-collection\" samba share"
ansible.builtin.blockinfile:
path: "/etc/samba/smb.conf"
mode: 0644
insertafter: "EOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK MUSIC:COLLECTION"
block: |
[music-collection]
comment = Music archive
path = {{ music_user_data_collection_directory }}
browseable = yes
read only = yes
register: music_rip_samba_collection_config
2023-02-26 00:21:00 +01:00
- 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
2023-03-01 20:14:12 +01:00
path = {{ music_user_data_archive_directory }}
2023-02-26 00:21:00 +01:00
browseable = yes
read only = yes
register: music_rip_samba_archive_config
2023-02-19 21:12:16 +01:00
- 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:
2023-05-15 21:51:27 +02:00
(music_rip_samba_download_config.changed or
music_rip_samba_rip_config.changed or
2023-04-06 14:07:13 +02:00
music_rip_samba_dvd_config.changed or
2023-03-01 20:14:12 +01:00
music_rip_samba_collection_config.changed or
2023-02-26 00:21:00 +01:00
music_rip_samba_archive_config.changed) and
2023-02-19 21:12:16 +01:00
not music_rip_samba_start.changed