-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathansible-initialize.sh
More file actions
executable file
·47 lines (42 loc) · 1.17 KB
/
ansible-initialize.sh
File metadata and controls
executable file
·47 lines (42 loc) · 1.17 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
source setenv.sh
###### Variable section - START
DESTINATION=$1
SCRIPT="ansible-initialize.sh"
###### Variable section - END
#######################################################
## It copies Ansible SSH public key to a destination ##
#######################################################
sshCopy()
{
echo ${cyn}Copying Ansible SSH key to destination ...${end}
ssh-copy-id -i $HOME/.ssh/ansible_rsa.pub pi@$DESTINATION
echo ${cyn}Done${end}
}
#########################################################
## It copies Ansible hosts file to /etc/ansible folder ##
#########################################################
copyAnsibleHostsFile()
{
echo ${cyn}Copying Ansible hosts file to /etc/ansible folder ...${end}
sudo cp conf/hosts /etc/ansible/hosts
echo ${cyn}Done${end}
}
###############
## printHelp ##
###############
printHelp()
{
printf "${red}Missing IP or Hostname destination to copy SSH key${end}\n"
printf "${cyn}Usage: ./$SCRIPT <DESTINATION>${end}\n"
printf "\n"
printf "${cyn}Example: ./$SCRIPT 192.168.4.10${end}\n"
exit
}
###### Main section
if [ -z "$DESTINATION" ]; then
printHelp
else
sshCopy
copyAnsibleHostsFile
source ping.sh
fi