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

FQDN=$1

# Add the host
ipa-getkeytab -p host/${FQDN} -k /tmp/${FQDN}.keytab || exit 1
Henrik Henriksson's avatar
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 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
Henrik Henriksson committed
12 13 14 15 16 17
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 nodes/${FQDN}.yaml
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"