add a provisioning example

This commit is contained in:
Emmanuel Garette 2020-03-16 10:44:22 +01:00
parent afdf049a26
commit 5b48093d4b
1 changed files with 98 additions and 0 deletions

98
provisioning_example.sh Executable file
View File

@ -0,0 +1,98 @@
#!/usr/bin/env bash
set -xe
verif() {
i=0
argv=("$@")
for V in creole.reseau.unbound_route_address creole.reseau.unbound_domain_name creole.serveur_dns.unbound_local_zones creole.reseau.unbound_ip_address_cidr; do
i=$((i+1))
R=$(./script/cucchiaiata setting.session.$1.get -s $S -n $V | jq -Mcr .content[])
[ $R = "${argv[i]}" ]
done
}
# Import EOLE
./script/cucchiaiata setting.source.create -n eole -u http://localhost
./script/cucchiaiata setting.source.release.create -s eole -n 2.7.1.1 -d last
./script/cucchiaiata setting.applicationservice.dataset.updated -s eole -r last
./script/cucchiaiata setting.servermodel.dataset.updated -s eole -r last
# Create a new user and set role 'server_rw' for this server
./script/cucchiaiata user.user.create -l gnunux -n gnunux -s gnunux
./script/cucchiaiata user.role.create -u gnunux -n 'server_rw' -a 'Server.ServerName' -v test.cadoles.com
# Heritage
## ACA
./script/cucchiaiata setting.servermodel.create -n aca -d Aca -p base -s eole -r last
./script/cucchiaiata setting.applicationservice.dependency.add -n local_aca -a unbound -s eole -r last
S=$(./script/cucchiaiata setting.session.servermodel.start -s aca | jq -r .session_id)
verif servermodel null null [] null
./script/cucchiaiata setting.session.servermodel.configure -s $S --creole.reseau.unbound_route_address 192.168.1.2
./script/cucchiaiata setting.session.servermodel.configure -s $S --creole.serveur_dns.unbound_allowed_client_cidr 192.168.1.0/24
verif servermodel 192.168.1.2 null [] null
./script/cucchiaiata setting.session.servermodel.stop -s $S -a
## etab1
./script/cucchiaiata setting.servermodel.create -n etab1 -d "Etab 1" -p aca -s internal -r last
S=$(./script/cucchiaiata setting.session.servermodel.start -s etab1 | jq -r .session_id)
./script/cucchiaiata setting.session.servermodel.configure -s $S --creole.reseau.unbound_domain_name test.cadoles.com
verif servermodel 192.168.1.2 test.cadoles.com [] null
./script/cucchiaiata setting.session.servermodel.stop -s $S -a
## unbound
./script/cucchiaiata setting.servermodel.create -n unbound -d "generic unbound configuration" -p base -s eole -r last
./script/cucchiaiata setting.applicationservice.dependency.add -n local_unbound -a unbound -s eole -r last
S=$(./script/cucchiaiata setting.session.servermodel.start -s unbound | jq -r .session_id)
./script/cucchiaiata setting.session.servermodel.configure -s $S --creole.serveur_dns.unbound_local_zones cadoles.com
./script/cucchiaiata setting.session.servermodel.filter -s $S -n unbound
./script/cucchiaiata setting.session.servermodel.configure -s $S --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.hostname_cadoles_com toto titi
./script/cucchiaiata setting.session.servermodel.configure -s $S --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.ip_cadoles_com 0 192.168.1.25
./script/cucchiaiata setting.session.servermodel.configure -s $S --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.type_cadoles_com 1 CNAME
./script/cucchiaiata setting.session.servermodel.configure -s $S --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.cname_cadoles_com 1 toto.cadoles.com
./script/cucchiaiata setting.session.servermodel.filter -s $S -n creole
verif servermodel null null '["cadoles.com"]' null
./script/cucchiaiata setting.session.servermodel.stop -s $S -a
## unbound_etab1
./script/cucchiaiata setting.servermodel.create -n unbound_etab1 -d "unbound configuration for etab1" -p etab1 unbound -s internal -r last
S=$(./script/cucchiaiata setting.session.servermodel.start -s unbound_etab1 | jq -r .session_id)
verif servermodel 192.168.1.2 test.cadoles.com '["cadoles.com"]' null
# Create a site, a zone and a server
./script/cucchiaiata infra.site.create -s etab1 -d "Etab 1"
./script/cucchiaiata infra.zone.create -z pedago -d "Pedago" -s etab1 -n "192.168.1.0/24" -t "192.168.1.10" -e "192.168.1.100"
./script/cucchiaiata infra.server.create -s test.cadoles.com -d description -m unbound_etab1 -r last -i etab1 -z pedago -p factory
# Configure server
S=$(./script/cucchiaiata setting.session.server.start -s test.cadoles.com | jq -r .session_id)
./script/cucchiaiata setting.session.server.configure -s $S --creole.reseau.unbound_ip_address_cidr 192.168.1.1/24
./script/cucchiaiata setting.session.server.validate -s $S
verif server 192.168.1.2 test.cadoles.com '["cadoles.com"]' 192.168.1.1/24
./script/cucchiaiata setting.session.server.stop -s $S -a
# Generate configuration
./script/cucchiaiata setting.config.configuration.server.deploy -s test.cadoles.com
./script/cucchiaiata setting.template.generate -s test.cadoles.com
# Add OpenSSH dependency
./script/cucchiaiata setting.applicationservice.dependency.add -n local_aca -a openssh -s eole -r last
S=$(./script/cucchiaiata setting.session.server.start -s test.cadoles.com | jq -r .session_id)
R=$(./script/cucchiaiata setting.session.server.get -s $S -n creole.serveur_ssh.ssh_allow_networks | jq -Mcr .content[])
[ $R = "[]" ]
./script/cucchiaiata setting.session.server.stop -s $S
S=$(./script/cucchiaiata setting.session.servermodel.start -s aca | jq -r .session_id)
./script/cucchiaiata setting.session.servermodel.configure -s $S --creole.serveur_ssh.ssh_allow_networks admin.cadoles.com
./script/cucchiaiata setting.session.servermodel.stop -s $S -a
S=$(./script/cucchiaiata setting.session.server.start -s test.cadoles.com | jq -r .session_id)
R=$(./script/cucchiaiata setting.session.server.get -s $S -n creole.serveur_ssh.ssh_allow_networks | jq -Mcr .content[])
[ $R = '["admin.cadoles.com"]' ]
./script/cucchiaiata setting.session.server.stop -s $S
# Regenerate configuration
./script/cucchiaiata setting.config.configuration.server.deploy -s test.cadoles.com
./script/cucchiaiata setting.template.generate -s test.cadoles.com
echo "fin"