-
Notifications
You must be signed in to change notification settings - Fork 5
/
rundeck_create_host.sh
40 lines (32 loc) · 995 Bytes
/
rundeck_create_host.sh
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
#!/bin/bash
echo "Valores informados:"
echo "Host:" @option.host@
echo "Ambiente:" @option.ambiente@
echo "Descricao:" @option.descricao@
echo "Tag:" @option.tags@
echo "osName:" @option.osName@
echo "OsVersion:" @option.osversion@
#Functions
cadastroHostProd() {
echo "Cadastrando Hosts em ambiente de producao..."
sleep 2
sed -i "/\/project\>/d" /var/lib/rundeck/nodes/nodes.xml
cat <<EOF >> /var/lib/rundeck/nodes/nodes.xml
<node name="@option.host@" description="@option.descricao@" tags="@option.tags@" hostname="@option.host@" osArch="amd64" osFamily="unix" osName="@option.osName@" osVersion="@option.osversion@" username="root"/>
</project>
EOF
#Condicional de validacao
if [ $? -eq 0 ]; then
echo "Cadastro realizado com sucesso."
else
echo "Cadastro falhou."
fi
}
#Condicional para execucao das funcoes
case @option.ambiente@ in
PROD) cadastroHostProd ;;
HMG) cadastroHostHmg ;;
DEV) cadastroHostDev ;;
QA) cadastroHostQA ;;
*) exit ;;
esac