Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung |
centos:rsynd_c8 [05.07.2020 13:28. ] – [Firewall-Daemon anpassen] django | centos:rsynd_c8 [18.11.2024 19:02. ] (aktuell) – Externe Bearbeitung 127.0.0.1 |
---|
===== Installation und Konfiguration ===== | ===== Installation und Konfiguration ===== |
==== manuelle Weg ==== | ==== manuelle Weg ==== |
=== TFTP-Server installieren === | === rsync-Daemon installieren === |
Als erstes installieren wir uns die für den rsyslog-Daemon-Server notwendigen Pakete via **''dnf''**. | Als erstes installieren wir uns die für den rsyslog-Daemon-Server notwendigen Pakete via **''dnf''**. |
# dnf install rsync-daemon rsync -y | # dnf install rsync-daemon rsync -y |
# rpm -qil rsync-daemon | # rpm -qil rsync-daemon |
# rpm -qil rsync | # rpm -qil rsync |
| |
| |
| |
| |
| |
| |
=== rsync-Daemon konfigurieren === | === rsync-Daemon konfigurieren === |
# hostname and IP address. If none of the patterns match, then the connec- | # hostname and IP address. If none of the patterns match, then the connec- |
# tion is rejected. | # tion is rejected. |
# hosts allow = *.mailserver.guru | # hosts allow = *.nausch.org |
| |
# Module examples: | # Module examples: |
# outgoing chmod = 0644 | # outgoing chmod = 0644 |
# lock file = /var/lock/object.lock | # lock file = /var/lock/object.lock |
# hosts allow = *.mailserver.guru | # hosts allow = *.nausch.org |
| |
#[REPO] | #[REPO] |
#path = /srv/public/mailserver.guru/ | #path = /srv/public/nausch.org/ |
#comment = repo.mailserver.guru | #comment = repo.nausch.org |
#allow = 88.217.171.167 | #allow = 88.217.171.167 |
| |
| |
==== automatisierter Weg mit Hilfe von Ansible ==== | ==== automatisierter Weg mit Hilfe von Ansible ==== |
Da wir aber in unserer Produktiven Umgebung alle Server, Dienste und Services mit Hilfe von **[[centos:ansible:start|Ansible]]** werden wir natürlich auch für unseren **rsync**-Daemon dies über eine entsprechende **[[centos:ansible:detail#grundlagen|Ansible-Rolle]] /* {{:centos:pxe_c8:ansible-role-tftp.tar.gz|ansible-role-tftp.tar.gz}}**((Version v1 vom 04.07.2020)) */ erledigen lassen. | Da wir aber in unserer Produktiven Umgebung alle Server, Dienste und Services mit Hilfe von **[[centos:ansible:start|Ansible]]** werden wir natürlich auch für unseren **rsync**-Daemon dies über eine entsprechende **[[centos:ansible:detail#grundlagen|Ansible-Rolle]] {{:centos:pxe_c8:ansible-role-rsync.tar.gz|ansible-role-rsync.tar.gz}}**((Version v1 vom 05.07.2020)) erledigen lassen. |
| |
/* | /* |
*/ | */ |
| |
/* | |
Wir holen uns also das Verzeichnis mit der **role** auf unseren Rechner. | Wir holen uns also das Verzeichnis mit der **role** auf unseren Rechner. |
$ wget https://dokuwiki.nausch.org/lib/exe/fetch.php/centos:pxe_c8:ansible-role-tftp.tar.gz -O ansible-role-tftp.tar.gz | $ wget https://dokuwiki.nausch.org/lib/exe/fetch.php/centos:pxe_c8:ansible-role-rsync.tar.gz -O ansible-role-rsync.tar.gz |
| |
Da wir bei der Installation und **[[centos:ansible:first#ansibledirectory_layout|Konfiguration]]** von Ansible bereits das **''Ansible Directory Layout''** erzeugt hatten, brauchen wir nur noch das heruntergeladene Archiv an Ort und Stelle entpacken. | Da wir bei der Installation und **[[centos:ansible:first#ansibledirectory_layout|Konfiguration]]** von Ansible bereits das **''Ansible Directory Layout''** erzeugt hatten, brauchen wir nur noch das heruntergeladene Archiv an Ort und Stelle entpacken. |
$ tar -xvf ansible-role-tftp.tar.gz -C ~/ansible/roles/ | $ tar -xvf ansible-role-rsync.tar.gz -C ~/ansible/roles/ |
| |
Jetzt brauchen wir nur noch die Rolle unserem Server **tftp-server** zuordnen. | Jetzt brauchen wir nur noch die Rolle unserem Server **rsync-server** zuordnen. |
$ vim ~/ansible/tftp.yml | $ vim ~/ansible/rsync.yml |
| |
<file yml ~/ansible/tftp.yml>--- # Start des Playbooks für den TFTP-Server | <file yml ~/ansible/rsync.yml>--- # Start des Playbooks für den rsyncd-Server |
- hosts: tftp-server | - hosts: rsync-server |
| |
roles: | roles: |
#- base # Basiskonfiguration (User anlegen) | #- base # Basiskonfiguration (User anlegen) |
#- chrony # Installation und Konfiguration NTP-Client | #- chrony # Installation und Konfiguration NTP-Client |
- tftp # Installation und Konfiguration TFTP-Server | - rsync # Installation und Konfiguration rsync-Daemon |
| |
... # Start des Playbooks für den TFTP-Server | ... # Ende des Playbooks für den rsyncd-Server |
</file> | </file> |
| |
| Bevor wir nun das Playbook ausführen, passen wir noch ggf. die Firewall-Einstellungen an. Beispiele dazu sind im entsprechenden **''task''** bereits vermerkt. |
| $ vim ~/ansible/roles/rsync/tasks/firewall.yml |
| <file bash ~/ansible/roles/rsync/tasks/firewall.yml>--- |
| - name: "*{{ daemon_name }}* : Firewall-Daemon für den {{ daemon_name }} anpassen" |
| firewalld: #https://docs.ansible.com/ansible/latest/modules/firewalld_module.html |
| zone: public |
| port: 873/tcp |
| permanent: yes |
| immediate: yes |
| state: enabled |
| # |
| #zone: public |
| #rich_rule: rule family="ipv4" source address="88.217.171.167/32" port protocol="tcp" port="873" destination address="10.0.0.190/32" accept |
| #permanent: yes |
| #immediate: yes |
| #state: enabled</file> |
| |
| Die Definition der Parameter für den **''rsyncd''** erfolgt über die Variablen-Datei **''~/ansible/roles/rsync/vars/main.yml''** |
| $ vim ~/ansible/roles/rsync/vars/main.yml |
| <file yml ~/ansible/roles/rsync/vars/main.yml>--- # Definition der rollenspezifische Variablen zum rsync Daemon |
| daemon_name : rsyncd |
| config_file : /etc/rsyncd.conf |
| config_backup_file : /etc/rsyncd.conf.orig |
| template_file : templates/rsyncd.conf.j2 |
| # rsyncd config-options |
| rsyncd_motd : "# motd file" |
| rsyncd_pid : "# pid file = /var/run/rsyncd.pid" |
| rsyncd_port : "# port 873" |
| rsyncd_address : "# address" |
| rsyncd_uid : "uid = nobody" |
| rsyncd_gid : "gid = nobody" |
| rsyncd_log_file : "# log file = /var/log/rsyncd.log" |
| rsyncd_syslog_tag : "# syslog tag = rsyncd" |
| rsyncd_syslog_facility : "# syslog facility = daemon" |
| rsyncd_transfer_logging : "transfer logging = yes" |
| rsyncd_max_connections : "# max connections = 0" |
| rsyncd_path : "# path = /home/ftp" |
| rsyncd_exclude : "# exclude = lost+found/" |
| rsyncd_use_chroot : "# use chroot = yes" |
| rsyncd_timeout : "timeout = 600" |
| rsyncd_ignore_nonreadable: "# ignore nonreadable = yes" |
| rsyncd_dont_compress : "dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2" |
| rsyncd_module : "[demo]\nmax connections = 2\npath = /srv/tftp/test\ncomment = Demo für rsync Daemon Artikel in Djangos WIKI\nlist = yes\nhosts allow = 10.10.10.0/26\n" |
| </file> |
| |
| <WRAP center round tip 80%> |
| Wenn man die hostspezfische Konfiguration des rsync-Daemon lieber in der Host-spezifischen Konfiguration vornehmen möchte, braucht man die **# rsyncd config-options** nur hier bei der Rolle auskommentieren bzw. löschen und in die Hostvariable im Inverntory aufnehmen. |
| <WRAP center round important 100%> |
| **WICHTIG**: Variablen in der Rollen-Konfiguration überschreiben (gleichlautende) Variablen-Definitionen aus dem Inventory! |
| </WRAP> |
| </WRAP> |
| |
Nun brauchen wir nur noch das Playbook ausführen und unser TFTP-Server steht bereit. | Nun brauchen wir nur noch das Playbook ausführen und unser TFTP-Server steht bereit. |
$ ansible-playbook -v ~/ansible/tftp.yml | $ ansible-playbook -v ~/ansible/rsync.yml |
| |
<html><pre class="code"> | <html><pre class="code"> |
<font style="color: rgb(0, 0, 0)">BECOME password: | <font style="color: rgb(0, 0, 0)">BECOME password: |
| |
PLAY [tftp-server] ************************************************************************************************************************************* | PLAY [rsync-server] ******************************************************************************************************************** |
| |
TASK [Gathering Facts] *************************************************************************************************************************************</font> | TASK [Gathering Facts] *****************************************************************************************************************</font> |
<font style="color: rgb(25, 100, 5)">ok: [tftp-server]</font><br> | <font style="color: rgb(25, 100, 5)">ok: [rsync-server]</font><br> |
<font style="color: rgb(0, 0, 0)">TASK [tftp : ***TFTP*** : Installation der TFTP-Server relevanten Pakete (in der aktuellsten Version)] ******************************</font> | <font style="color: rgb(0, 0, 0)">TASK [*rsyncd* : Installation der relevanten Pakete (in der aktuellsten Version) für den rsyncd] ***************************************</font> |
<font style="color: rgb(196, 160, 0)">changed: [tftp-server] => {"changed": true, "msg": "", "rc": 0, "results": ["Installed: xinetd-2:2.3.15-24.el8.x86_64", "Installed: mtools-4.0.18-14.el8.x86_64", "Installed: tftp-server-5.2-24.el8.x86_64", "Installed: syslinux-6.04-4.el8.x86_64", "Installed: syslinux-nonlinux-6.04-4.el8.noarch"]}</font><br> | <font style="color: rgb(196, 160, 0)">changed: [rsync-server] => {"changed": true, "msg": "", "rc": 0, "results": ["Installed: rsync-daemon-3.1.3-7.el8.noarch", "Installed: rsync-3.1.3-7.el8.x86_64"]}</font><br> |
<font style="color: rgb(0, 0, 0)">TASK [tftp : ***TFTP*** : Firewall-Daemon für den TFTP-Server anpassen] *************************************************************</font> | <font style="color: rgb(0, 0, 0)">TASK [*rsyncd* : 1) Überprüfen ob das Backup der Konfigurationsdatei '/etc/rsyncd.conf' bereits existiert] *****************************</font> |
<font style="color: rgb(196, 160, 0)">changed: [tftp-server] => {"changed": true, "msg": "Permanent operation, Changed service tftp to enabled"}</font><br> | <font style="color: rgb(25, 100, 5)">ok: [rsync-server] => {"changed": false, "stat": {"exists": false}}</font><br> |
<font style="color: rgb(0, 0, 0)">TASK [***TFTP*** : Sicherstellen dass der Daemon 'tftp.service' gestartet wird und läuft] ******************************************</font> | <font style="color: rgb(0, 0, 0)">TASK [*rsyncd* : 2) Von der bestehenden originalen Konfigurationsdatei '/etc/rsyncd.conf' ein Backup '/etc/rsyncd.conf.orig' erstellen]*</font> |
<font style="color: rgb(196, 160, 0)">changed: [tftp-server] => {"changed": true, "enabled": true, "name": "tftp.service", "state": "started", "status": {"ActiveEnterTimestampMonotonic": "0", "ActiveExitTimestampMonotonic": "0", "ActiveState": "inactive", "After": "sysinit.target basic.target tftp.socket system.slice", "AllowIsolate": "no", "AllowedCPUs": "", "AllowedMemoryNodes": "", "AmbientCapabilities": "", "AssertResult": "no", "AssertTimestampMonotonic": "0", "Before": "shutdown.target", "BlockIOAccounting": "no", "BlockIOWeight": "[not set]", "CPUAccounting": "no", "CPUAffinity": "", "CPUQuotaPerSecUSec": "infinity", "CPUSchedulingPolicy": "0", "CPUSchedulingPriority": "0", "CPUSchedulingResetOnFork": "no", "CPUShares": "[not set]", "CPUUsageNSec": "[not set]", "CPUWeight": "[not set]", "CacheDirectoryMode": "0755", "CanIsolate": "no", "CanReload": "no", "CanStart": "yes", "CanStop": "yes", "CapabilityBoundingSet": "cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config cap_mknod cap_lease cap_audit_write cap_audit_control cap_setfcap cap_mac_override cap_mac_admin cap_syslog cap_wake_alarm cap_block_suspend", "CollectMode": "inactive", "ConditionResult": "no", "ConditionTimestampMonotonic": "0", "ConfigurationDirectoryMode": "0755", "Conflicts": "shutdown.target", "ControlPID": "0", "DefaultDependencies": "yes", "Delegate": "no", "Description": "Tftp Server", "DevicePolicy": "auto", "Documentation": "man:in.tftpd", "DynamicUser": "no", "EffectiveCPUs": "", "EffectiveMemoryNodes": "", "ExecMainCode": "0", "ExecMainExitTimestampMonotonic": "0", "ExecMainPID": "0", "ExecMainStartTimestampMonotonic": "0", "ExecMainStatus": "0", "ExecStart": "{ path=/usr/sbin/in.tftpd ; argv[]=/usr/sbin/in.tftpd -s /var/lib/tftpboot ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", "FailureAction": "none", "FileDescriptorStoreMax": "0", "FragmentPath": "/usr/lib/systemd/system/tftp.service", "GID": "[not set]", "GuessMainPID": "yes", "IOAccounting": "no", "IOSchedulingClass": "0", "IOSchedulingPriority": "0", "IOWeight": "[not set]", "IPAccounting": "no", "IPEgressBytes": "18446744073709551615", "IPEgressPackets": "18446744073709551615", "IPIngressBytes": "18446744073709551615", "IPIngressPackets": "18446744073709551615", "Id": "tftp.service", " |