Script: inventory2ssh hinzugefügt (#193)
Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: mg/ansible#193 Co-authored-by: mg <mg@noreply.git.mgrote.net> Co-committed-by: mg <mg@noreply.git.mgrote.net>
This commit is contained in:
parent
9861d91446
commit
3510fe0983
1 changed files with 17 additions and 0 deletions
17
inventory2sshconfig.sh
Normal file
17
inventory2sshconfig.sh
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
# pruefe ob inventory gesetzt ist
|
||||
if [ -n "$1" ]; then
|
||||
var_inv=$1
|
||||
else
|
||||
var_inv="/home/mg/ansible/inventory"
|
||||
fi
|
||||
#pruefe ob ssh-config gesetzt ist
|
||||
if [ -n "$2" ]; then
|
||||
var_conf=$2
|
||||
else
|
||||
var_conf="/home/mg/.ssh/config"
|
||||
fi
|
||||
# loesche *.grote.lan Hosts und lege ein backup der Datei an
|
||||
sed -i.bak -r '/[a-z0-9-]+.grote.lan/ d' $var_inf
|
||||
# gebe Host aus Inventorie aus, entferne die erste Zeile, schreibe "Host"
|
||||
echo "$(ansible all -i $var_inv1 --list-hosts | grep -v hosts | sed -e 's/^/Host/g' | cat - $var_conf)" > $var_conf
|
Loading…
Reference in a new issue