-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap_ssh_puppet
More file actions
executable file
·27 lines (22 loc) · 909 Bytes
/
bootstrap_ssh_puppet
File metadata and controls
executable file
·27 lines (22 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
## Example:
## bootstrap_ssh_puppet target.com puppetmasterIP
key="`cat ~/.ssh/id_rsa.pub`";
host=$1;
puppet_master=$2
host_fqdn=$3;
ssh_user=$USER;
id_cmd='';
#bootstrap script to server
echo -e "Bootstrap_ssh:\t\tcopying bootstrap_puppet to $host";
scp $id_cmd ./bootstrap_puppet $ssh_user@$host:~/bootstrap_puppet;
#run bootstrap_puppet
echo -e "Bootstrap_ssh:\t\tRemotely execing bootstrap puppet";
ssh $id_cmd $ssh_user@$host "chmod 700 bootstrap_puppet";
ssh -t $id_cmd $ssh_user@$host "sudo /bin/bash bootstrap_puppet $puppet_master";
## sign
tmp_fqdn="`ssh -t $id_cmd $ssh_user@$host 'facter fqdn'`";
host_fqdn="`echo $tmp_fqdn |tr -dc '[:print:]'`";
echo -e "Bootstrap_ssh:\t\tRemotely execing bootstrap puppet";
echo -e "Bootstrap_ssh:\t\tsigning cert for '$host_fqdn' on puppet master '$puppet_master'";
ssh -t $id_cmd $ssh_user@$puppet_master "sudo puppet cert sign $host_fqdn";