extract-fw-host-vars.py: write host_vars/<host>/<short>-ipt-server.yml by default.
Without -o the script now writes the standard host_vars file (relative to the script, independent of the cwd). An existing file is only overwritten with --force; this is checked before connecting to the host. -o - prints to stdout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -56,12 +56,15 @@ mappt alle Variablen auf die `fw_*`-Ansible-Variablen und schreibt eine fertige
|
||||
cd /path/to/ansible/oopen-server
|
||||
HOSTNAME=<hostname>
|
||||
|
||||
./extract-fw-host-vars.py ${HOSTNAME} --sudo \
|
||||
-o host_vars/${HOSTNAME}/${HOSTNAME%.*.*}-ipt-server.yml
|
||||
./extract-fw-host-vars.py ${HOSTNAME} --sudo
|
||||
```
|
||||
|
||||
Das Skript fragt einmalig nach dem `sudo`-Passwort. Kann eine der Dateien nicht
|
||||
gelesen werden, bricht es ab, ohne etwas zu schreiben.
|
||||
Das Skript fragt einmalig nach dem `sudo`-Passwort und schreibt nach
|
||||
`host_vars/${HOSTNAME}/${HOSTNAME%.*.*}-ipt-server.yml`. Eine vorhandene Datei
|
||||
wird nur mit `--force` überschrieben (dabei wird `fw_manage_config` wieder
|
||||
`false`); mit `-o -` geht die Ausgabe nach stdout, mit `-o DATEI` in eine
|
||||
andere Datei. Kann eine der Conf-Dateien nicht gelesen werden, bricht das
|
||||
Skript ab, ohne etwas zu schreiben.
|
||||
|
||||
Alternativ ohne Passwortabfrage (sudo über `ansible_become_password` aus dem Vault):
|
||||
die Dateien mit Ansible holen und lokal einlesen:
|
||||
@@ -71,8 +74,7 @@ for f in interfaces_ipv4 interfaces_ipv6 main_ipv4 main_ipv6 ; do
|
||||
ansible ${HOSTNAME} -b -m fetch \
|
||||
-a "src=/etc/ipt-firewall/${f}.conf dest=/tmp/fw-${HOSTNAME}/ flat=yes"
|
||||
done
|
||||
./extract-fw-host-vars.py ${HOSTNAME} --from-dir /tmp/fw-${HOSTNAME} \
|
||||
-o host_vars/${HOSTNAME}/${HOSTNAME%.*.*}-ipt-server.yml
|
||||
./extract-fw-host-vars.py ${HOSTNAME} --from-dir /tmp/fw-${HOSTNAME}
|
||||
rm -rf /tmp/fw-${HOSTNAME}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user