-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsftp-server.yml
78 lines (70 loc) · 1.78 KB
/
sftp-server.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
- name: Configure sftp server
hosts: all
become: true
vars:
sftp_host: localhost
sftp_port: 22
sftp_system_group: sftpusers
sftp_fs_root: /srv/sftp
sftp_users_expire_days: "15"
sftp_useradd_script: /usr/local/sbin/sftpuseradd
swaks_version: swaks-20201014.0
default_send_mail: "no"
mail_to: root@localhost
mail_from: root@localhost
smtp_user: nobody
smtp_passwd: nopass
smtp_server: localhost
smtp_port: 25
smtp_protocol: SMTP
# https://github.com/jetmore/swaks/blob/v20190914.0/doc/base.pod
tasks:
- name: Create SFTP users group
group:
system: yes
state: present
name: "{{ sftp_system_group }}"
- name: Create SFTP users chroot filesystem directory
file:
owner: root
group: root
mode: 0755
state: directory
path: "{{ sftp_fs_root }}"
- name: Copy sshd config
template:
src: templates/sshd_config.j2
dest: /etc/ssh/sshd_config
force: yes
owner: root
group: root
mode: 0644
notify: restart ssh
- name: Copy sftpuseradd shell script
template:
src: templates/sftpuseradd.j2
dest: "{{ sftp_useradd_script }}"
force: yes
owner: root
group: root
mode: 0750
- name: Install Net::SSLeay
apt:
name: libnet-ssleay-perl
state: present
update_cache: yes
- name: Install swaks
get_url:
url: https://www.jetmore.org/john/code/swaks/files/{{ swaks_version }}/swaks
dest: /usr/local/bin/swaks
force: yes
owner: root
group: root
mode: 0711
handlers:
- name: restart ssh
service:
name: ssh
enabled: yes
state: restarted