diff options
author | clarkzjw <[email protected]> | 2023-01-13 16:53:03 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-01-13 16:53:03 -0800 |
commit | a077d65e5f7f415cc17abeee2264e24957ef97cd (patch) | |
tree | d392e85446a7eb680a8178588f39517c84577825 /clarkzjw.cc/config/atlas/ansible/roles/samba/tasks | |
parent | 945aa9e6f634a078937fdf21d09f32e77f4c1a7b (diff) | |
download | homelab-a077d65e5f7f415cc17abeee2264e24957ef97cd.tar.gz |
change domain to clarkzjw.cc
Diffstat (limited to 'clarkzjw.cc/config/atlas/ansible/roles/samba/tasks')
-rw-r--r-- | clarkzjw.cc/config/atlas/ansible/roles/samba/tasks/main.yaml | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/clarkzjw.cc/config/atlas/ansible/roles/samba/tasks/main.yaml b/clarkzjw.cc/config/atlas/ansible/roles/samba/tasks/main.yaml new file mode 100644 index 0000000..80950dc --- /dev/null +++ b/clarkzjw.cc/config/atlas/ansible/roles/samba/tasks/main.yaml | |||
@@ -0,0 +1,53 @@ | |||
1 | - name: Install Samba | ||
2 | apt: | ||
3 | name: | ||
4 | - samba | ||
5 | - smbclient | ||
6 | - cifs-utils | ||
7 | update_cache: true | ||
8 | |||
9 | - name: Disable Samba NetBIOS server nmbd | ||
10 | systemd: | ||
11 | name: nmbd | ||
12 | state: stopped | ||
13 | enabled: false | ||
14 | |||
15 | - name: render samba config file | ||
16 | template: | ||
17 | src: smb.conf.j2 | ||
18 | dest: "/etc/samba/smb.conf" | ||
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 | ||