mirror of
https://github.com/xcat2/confluent.git
synced 2025-03-03 17:51:00 +00:00
Add scripts to adopt a node to confluent SSH
This commit is contained in:
parent
fb8675ddc5
commit
24f0ff5221
23
misc/adoptnode.sh
Executable file
23
misc/adoptnode.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
TARGNODE=$1
|
||||
TARGPROF=$2
|
||||
if [ -z "$TARGNODE" ] ; then
|
||||
echo "Target node must be specified"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$TARGPROF" ]; then
|
||||
echo "Target profile must be specified"
|
||||
exit 1
|
||||
fi
|
||||
nodedefine $TARGNODE deployment.apiarmed=once deployment.profile=$TARGPROF deployment.useinsecureprotocols= deployment.pendingprofile=$TARGPROF
|
||||
cat /var/lib/confluent/public/site/ssh/*pubkey | ssh $TARGNODE "mkdir -p /root/.ssh/; cat - >> /root/.ssh/authorized_keys"
|
||||
ssh $TARGNODE mkdir -p /etc/confluent /opt/confluent/bin
|
||||
cat /var/lib/confluent/public/site/tls/*.pem | ssh $TARGNODE "cat - >> /etc/confluent/ca.pem"
|
||||
cat /var/lib/confluent/public/site/tls/*.pem | ssh $TARGNODE "cat - >> /etc/pki/ca-trust/source/anchors/confluent.pem"
|
||||
nodeattrib $TARGNODE id.uuid=$(ssh $TARGNODE cat /sys/devices/virtual/dmi/id/product_uuid)
|
||||
scp prepadopt.sh $TARGNODE:/tmp/
|
||||
scp finalizeadopt.sh $TARGNODE:/tmp/
|
||||
ssh $TARGNODE bash /tmp/prepadopt.sh $TARGNODE $TARGPROF
|
||||
nodeattrib $TARGNODE deployment.pendingprofile=
|
||||
nodeapply $TARGNODE -k
|
||||
ssh $TARGNODE sh /tmp/finalizeadopt.sh
|
32
misc/finalizeadopt.sh
Normal file
32
misc/finalizeadopt.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
if ! grep ^HostbasedAuthentication /etc/ssh/sshd_config > /dev/null; then
|
||||
echo HostbasedAuthentication yes >> /etc/ssh/sshd_config
|
||||
echo HostbasedUsesNameFromPacketOnly yes >> /etc/ssh/sshd_config
|
||||
echo IgnoreRhosts no >> /etc/ssh/sshd_config
|
||||
fi
|
||||
for certfile in /etc/ssh/*cert*; do
|
||||
if ! grep $certfile /etc/ssh/sshd_config > /dev/null; then
|
||||
echo HostCertificate $certfile >> /etc/ssh/sshd_config
|
||||
fi
|
||||
done
|
||||
if [ -d /etc/ssh/ssh_config.d/ ]; then
|
||||
cat > /etc/ssh/ssh_config.d/01-confluent.conf << EOF
|
||||
Host *
|
||||
HostbasedAuthentication yes
|
||||
EnableSSHKeysign yes
|
||||
HostbasedKeyTypes *ed25519*
|
||||
EOF
|
||||
else
|
||||
if ! grep EnableSSHKeysign /etc/ssh/ssh_config > /dev/null; then
|
||||
cat >> /etc/ssh/ssh_config << EOF
|
||||
Host *
|
||||
HostbasedAuthentication yes
|
||||
EnableSSHKeysign yes
|
||||
HostbasedKeyTypes *ed25519*
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
restorecon -r /etc/ssh
|
||||
restorecon /root/.shosts
|
||||
|
||||
systemctl restart sshd
|
25
misc/prepadopt.sh
Normal file
25
misc/prepadopt.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
TARGNODE=$1
|
||||
TARGPROF=$2
|
||||
TMPDIR=$(mktemp -d)
|
||||
cd $TMPDIR
|
||||
DEPLOYSRV=$(echo $SSH_CLIENT|awk '{print $1}')
|
||||
UDEPLOYSRV=$DEPLOYSRV
|
||||
if [[ "$DEPLOYSRV" = *":"* ]]; then
|
||||
UDEPLOYSRV="[$DEPLOYSRV]"
|
||||
fi
|
||||
update-ca-trust
|
||||
mkdir -p /etc/confluent
|
||||
curl -sg https://$UDEPLOYSRV/confluent-public/os/$TARGPROF/boot/initramfs/addons.cpio > addons.cpio
|
||||
curl -sg https://$UDEPLOYSRV/confluent-public/os/$TARGPROF/scripts/functions > /etc/confluent/functions
|
||||
cpio -dumi < addons.cpio
|
||||
systemctl status firewalld >& /dev/null && FWACTIVE=1
|
||||
if [ "$FWACTIVE" == 1 ]; then systemctl stop firewalld; fi
|
||||
opt/confluent/bin/copernicus > /etc/confluent/confluent.info
|
||||
opt/confluent/bin/clortho $TARGNODE $DEPLOYSRV > /etc/confluent/confluent.apikey
|
||||
if [ "$FWACTIVE" == 1 ]; then systemctl start firewalld; fi
|
||||
cp opt/confluent/bin/apiclient /opt/confluent/bin
|
||||
curl -sg -H "CONFLUENT_APIKEY: $(cat /etc/confluent/confluent.apikey)" -H "CONFLUENT_NODENAME: $TARGNODE" https://$UDEPLOYSRV/confluent-api/self/deploycfg2 > /etc/confluent/confluent.deploycfg
|
||||
# python3 /opt/confluent/bin/apiclient /confluent-api/self/deploycfg2 > /etc/confluent/confluent.deploycfg
|
||||
cd -
|
||||
echo rm -rf $TMPDIR
|
Loading…
x
Reference in New Issue
Block a user