initial version of rsync module which supports running rsynd server on top of tls
This commit is contained in:
parent
60406a69f9
commit
d49da2f96e
8 changed files with 128 additions and 0 deletions
3
roles/rsync/client/files/rsync-ssl
Executable file
3
roles/rsync/client/files/rsync-ssl
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
/usr/bin/rsync --rsh /usr/local/libexec/rsync-ssl-tunnel "$@"
|
35
roles/rsync/client/files/rsync-ssl-tunnel
Executable file
35
roles/rsync/client/files/rsync-ssl-tunnel
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "$@" > /tmp/foo.out
|
||||
|
||||
key="/etc/pki/tls/private/$(hostname -f).key"
|
||||
cert="/etc/pki/tls/certs/$(hostname -f).crt"
|
||||
cafile="/etc/pki/tls/certs/ca.crt"
|
||||
port=${RSYNC_SSL_PORT:-873}
|
||||
|
||||
# If the user specified USER@HOSTNAME::module, then rsync passes us
|
||||
# the -l USER option too, so we must be prepared to ignore it.
|
||||
if [ x"$1" = x"-l" ]; then
|
||||
shift 2
|
||||
fi
|
||||
|
||||
hostname=$1
|
||||
shift
|
||||
|
||||
if [ x"$hostname" = x -o x"$1" != x"rsync" -o x"$2" != x"--server" -o x"$3" != x"--daemon" ]; then
|
||||
echo "Usage: stunnel-rsync HOSTNAME rsync --server --daemon ." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# devzero@web.de came up with this no-tmpfile calling syntax:
|
||||
stunnel -fd 10 11<&0 <<EOF 10<&0 0<&11 11<&-
|
||||
foreground = yes
|
||||
debug = crit
|
||||
connect = $hostname:$port
|
||||
client = yes
|
||||
TIMEOUTclose = 0
|
||||
verify = 2
|
||||
cert = $cert
|
||||
key = $key
|
||||
CAfile = $cafile
|
||||
EOF
|
25
roles/rsync/client/tasks/main.yml
Normal file
25
roles/rsync/client/tasks/main.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
|
||||
- name: install rsync packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: installed
|
||||
with_items:
|
||||
- rsync
|
||||
- stunnel
|
||||
|
||||
- name: install rsync stunnel wrapper
|
||||
copy:
|
||||
dest: /usr/local/libexec/rsync-ssl-tunnel
|
||||
src: rsync-ssl-tunnel
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: install rsync-ssl
|
||||
copy:
|
||||
dest: /usr/local/bin/rsync-ssl
|
||||
src: rsync-ssl
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
3
roles/rsync/server/files/systemd-stunnel.conf
Normal file
3
roles/rsync/server/files/systemd-stunnel.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/stunnel /etc/stunnel/rsyncd.conf
|
3
roles/rsync/server/meta/main.yml
Normal file
3
roles/rsync/server/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- {role: rsync/client}
|
38
roles/rsync/server/tasks/main.yml
Normal file
38
roles/rsync/server/tasks/main.yml
Normal file
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
- name: create rsyncd config
|
||||
template:
|
||||
dest: /etc/rsyncd.conf
|
||||
src: rsyncd.conf.j2
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: create rsyncd config for stunnel
|
||||
template:
|
||||
dest: /etc/stunnel/rsyncd.conf
|
||||
src: rsyncd-stunnel.conf.j2
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: create override directory for rsyncd socket
|
||||
file:
|
||||
dest: /etc/systemd/system/rsyncd@.service.d
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: create override config for rsyncd socket
|
||||
copy:
|
||||
dest: /etc/systemd/system/rsyncd@.service.d/stunnel.conf
|
||||
src: systemd-stunnel.conf
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: enable rsyncd socket
|
||||
systemd:
|
||||
name: rsyncd.socket
|
||||
enabled: true
|
||||
state: started
|
10
roles/rsync/server/templates/rsyncd-stunnel.conf.j2
Normal file
10
roles/rsync/server/templates/rsyncd-stunnel.conf.j2
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
key = /etc/pki/tls/private/{{ inventory_hostname }}.key
|
||||
cert = /etc/pki/tls/certs/{{ inventory_hostname }}.crt
|
||||
client = no
|
||||
|
||||
verify = 2
|
||||
CAfile = /etc/pki/tls/certs/ca.crt
|
||||
|
||||
exec = /usr/bin/rsync
|
||||
execargs = rsync --daemon --config=/etc/rsyncd.conf
|
11
roles/rsync/server/templates/rsyncd.conf.j2
Normal file
11
roles/rsync/server/templates/rsyncd.conf.j2
Normal file
|
@ -0,0 +1,11 @@
|
|||
[global]
|
||||
user = rsyncd
|
||||
group = rsyncd
|
||||
use chroot = yes
|
||||
read only = yes
|
||||
hosts allow = *
|
||||
|
||||
[test]
|
||||
comment = test module
|
||||
path = /srv/mirrors/openbsd/
|
||||
read only = yes
|
Loading…
Add table
Reference in a new issue