diff options
Diffstat (limited to 'clarkzjw.ca/config/atlas/roles/samba/tasks')
-rw-r--r-- | clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml b/clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml index 7c1edec..0ada38a 100644 --- a/clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml +++ b/clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml | |||
@@ -6,9 +6,48 @@ | |||
6 | - cifs-utils | 6 | - cifs-utils |
7 | update_cache: true | 7 | update_cache: true |
8 | 8 | ||
9 | - name: Disable Samba NetBIOS server nmbd | ||
10 | systemd: | ||
11 | name: nmbd | ||
12 | state: stopped | ||
13 | enabled: false | ||
9 | 14 | ||
10 | - name: render samba config file | 15 | - name: render samba config file |
11 | template: | 16 | template: |
12 | src: smb.conf.j2 | 17 | src: smb.conf.j2 |
13 | dest: "/etc/samba/smb.conf" | 18 | dest: "/etc/samba/smb.conf" |
14 | mode: 0644 \ No newline at end of file | 19 | mode: 0644 |
20 | |||
21 | # https://stackoverflow.com/questions/44762488/non-interactive-samba-user-creation-via-ansible | ||
22 | - name: shell - create samba users | ||
23 | shell: > | ||
24 | set -e -o pipefail | ||
25 | && (pdbedit --user={{ item.username }} 2>&1 > /dev/null) | ||
26 | || (echo '{{ item.password }}'; echo '{{ item.password }}') | ||
27 | | smbpasswd -s -a {{ item.username }} | ||
28 | args: | ||
29 | executable: /bin/bash | ||
30 | register: samba_create_users | ||
31 | changed_when: "'Added user' in samba_create_users.stdout" | ||
32 | loop: "{{ samba_users }}" | ||
33 | # no_log: true | ||
34 | |||
35 | - name: shell - set samba passwords correctly | ||
36 | shell: > | ||
37 | set -e -o pipefail | ||
38 | && (smbclient -U {{ item.username }}%{{ item.password }} -L 127.0.0.1 2>&1 > /dev/null) | ||
39 | || (echo '{{ item.password }}'; echo '{{ item.password }}') | ||
40 | | smbpasswd {{ item.username }} | ||
41 | args: | ||
42 | executable: /bin/bash | ||
43 | register: samba_verify_users | ||
44 | changed_when: "'New SMB password' in samba_verify_users.stdout" | ||
45 | loop: "{{ samba_users }}" | ||
46 | # no_log: true | ||
47 | |||
48 | - name: Restart SMB service | ||
49 | systemd: | ||
50 | name: smbd | ||
51 | state: restarted | ||
52 | enabled: true | ||
53 | daemon_reload: true | ||