new_host.sh 894 Bytes
Newer Older
1 2 3 4 5
#!/bin/bash

FQDN=$1

# Add the host
6
ipa-getkeytab -p host/${FQDN}@AD.LYSATOR.LIU.SE -k /tmp/${FQDN}.keytab || exit 1
Henrik Henriksson's avatar
Append  
Henrik Henriksson committed
7
/opt/puppetlabs/puppet/bin/eyaml encrypt --pkcs7-public-key=public_key.pkcs7.pem --output=block --label=ipa_client::keytab_content --file=/tmp/${FQDN}.keytab | tee -a nodes/${FQDN}.yaml
8 9 10 11
shred /tmp/${FQDN}.keytab || exit 1
rm /tmp/${FQDN}.keytab

ROOT_PASSWORD=`pwgen -s 16 -N 1`
Henrik Henriksson's avatar
Append  
Henrik Henriksson committed
12
echo ${ROOT_PASSWORD} | mkpasswd -R 5000000 -s -m sha-512 | /opt/puppetlabs/puppet/bin/eyaml encrypt --pkcs7-public-key=public_key.pkcs7.pem --output=block --label=profiles::root::password --stdin | tee -a nodes/${FQDN}.yaml
Henrik Henriksson's avatar
Henrik Henriksson committed
13 14 15 16 17
echo ""
echo "The output above has been saved to nodes/${FQDN}.yaml." 
echo "Please commit the file and push it."
echo -e "\e[32mGenerated password for the server:\e[39m ${ROOT_PASSWORD}"
echo -e "\e[35mSave the password or delete the entry from nodes/${FQDN}.yaml\e[39m"