simplification du fichier de provisioning

This commit is contained in:
Emmanuel Garette 2020-09-02 09:03:34 +02:00
parent ee37254fa6
commit fe0e160940
1 changed files with 83 additions and 136 deletions

View File

@ -1,174 +1,121 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -xe
# Configuration #=======================================================================================================
# -> base (cadoles' servermodel) # Import Cadoles seed
# |-> cluster (servermodel) #=======================================================================================================
# | '-> node1.cadoles.com (server)
# |
# |-> aca (servermodel) + unbound (AS) + openssh (AS)
# | '-> etab1 (servermodel) -------------------,
# | |
# '-> fedora-32 (cadoles' servermodel) |
# '-> unbound (servermodel) + unbound (AS) --|
# '-> unbound_etab1 (servermodel)
# '-> dns.cadoles.com (server)
# Site and zone cucchiaiata-cli v1.setting.source.create --source_name cadoles --source_directory /srv/risotto/seed/cadoles
#=======================================================================================================
# Infrastructure
#=======================================================================================================
# Create a new user and set role 'server_rw' for the server dns.cadoles.com
cucchiaiata-cli v1.user.user.create --user_login gnunux --user_name gnunux --user_surname gnunux
cucchiaiata-cli v1.user.role.create --user_login gnunux --role_name 'server_rw' --role_attribute 'Server.ServerName' --role_attribute_value dns.cadoles.com
# Sites and zone
# + = = = = = = = = = = = = = = = = = = = = = = = + # + = = = = = = = = = = = = = = = = = = = = = = = +
# " SITE cluster " # " SITE site_cluster "
# " "
# " +-------------------+ " # " +-------------------+ "
# " | node1.cadoles.com | "-----------+ # " | node1.cadoles.com | "-----------+
# " | | " | # " +-------------------+ " +~~~~~~~~+
# " +-------------------+ " |
# " " +~~~~~~~~+
# + = = = = = = = = = = = = = = = = = = = = = = = + ! ZONE ! # + = = = = = = = = = = = = = = = = = = = = = = = + ! ZONE !
# ! pedago ! # ! pedago !
# + = = = = = = = = = = = = = = = = = = = = = = = + +~~~~~~~~+ # + = = = = = = = = = = = = = = = = = = = = = = = + +~~~~~~~~+
# " SITE etab1 " | # " SITE etab1 " |
# " +-----------------+ " | # " +-----------------+ "-----------+
# " | dns.cadoles.com | "-----------+ # " | dns.cadoles.com | "
# " | | "
# " +-----------------+ " # " +-----------------+ "
# " "
# + = = = = = = = = = = = = = = = = = = = = = = = + # + = = = = = = = = = = = = = = = = = = = = = = = +
# cucchiaiata-cli v1.infra.site.create --site_name site_cluster
cucchiaiata-cli v1.infra.site.create --site_name etab1
# Zone
cucchiaiata-cli v1.infra.zone.create --zone_name pedago --sites_name etab1 site_cluster --network "192.168.1.0/24" --host_start "192.168.1.10" --host_end "192.168.1.100" --dns 192.168.1.1 --gateway 192.168.1.254
# Servermodels
# -> base (cadoles' servermodel)
# |-> sm_cluster (servermodel)
# | '-> node1.cadoles.com (server)
# |
# |-> aca (servermodel) + unbound (AS) + openssh (AS)
# | '-> etab1 (servermodel) -------------------,
# | |--> unbound_etab1 (servermodel)
# '-> fedora-32 (cadoles' servermodel) | '-> dns.cadoles.com (server)
# '-> unbound (servermodel) + unbound (AS) --'
## sm_cluster
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name sm_cluster --applicationservices base
## ACA
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name aca --applicationservices unbound openssh
## etab1
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name etab1 --parents_name aca
## unbound
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name unbound --applicationservices base-fedora-32 unbound
## unbound_etab1
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name unbound_etab1 --parents_name etab1 unbound
# Servers
cucchiaiata-cli v1.infra.server.create --server_name node1.cadoles.com --servermodel_name sm_cluster --site_name site_cluster --zones_name pedago
cucchiaiata-cli v1.infra.server.create --server_name dns.cadoles.com --servermodel_name unbound_etab1 --site_name etab1 --zones_name pedago
# Create a cluster
cucchiaiata-cli v1.provider.factory.cluster.create --cluster_name cluster.cadoles.com --virtual_ip 192.168.1.1 --zone_name pedago
# Cluster description: # Cluster description:
# +-----------------------------+ # +-----------------------------+
# + cluster.cadoles.com + # + cluster.cadoles.com +
# + +
# + +--------------------+ + # + +--------------------+ +
# + + node1.cadoles.com + + # + + node1.cadoles.com + +
# + + + +
# + + + +
# + +--------------------+ + # + +--------------------+ +
# + +
# +-----------------------------+ # +-----------------------------+
cucchiaiata-cli v1.provider.factory.cluster.join --cluster_name cluster.cadoles.com --node_name node1.cadoles.com
# Cluster execution: # Cluster execution:
# +-----------------------------+ # +-----------------------------+
# + cluster.cadoles.com + # + cluster.cadoles.com +
# + +
# + +--------------------+ + # + +--------------------+ +
# + + dns.cadoles.com + + # + + dns.cadoles.com + +
# + + + +
# + + + +
# + +--------------------+ + # + +--------------------+ +
# + +
# +-----------------------------+ # +-----------------------------+
cucchiaiata-cli v1.provider.factory.server.add --server dns.cadoles.com --cluster_name cluster.cadoles.com --cpu 0.2 --vcpu 2 --memory 2
set -xe #=======================================================================================================
# Configuration
#=======================================================================================================
verif() { # Servermodel ACA
i=0 S=$(cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name aca| jq -r .session_id)
argv=("$@") cucchiaiata-cli v1.setting.session.servermodel.configure --session_id "$S" --configuration.reseau.unbound_route_address 192.168.1.2 \
for V in configuration.reseau.unbound_route_address configuration.reseau.unbound_domain_name configuration.serveur_dns.unbound_local_zones configuration.reseau.unbound_ip_address_cidr; do --configuration.serveur_dns.unbound_allowed_client_cidr 192.168.1.0/24 \
i=$((i+1)) --configuration.serveur_ssh.ssh_allow_networks admin.cadoles.com
R=$(cucchiaiata-cli "setting.session.$1.get" -s "$S" -n "$V" | jq -Mcr .content[]) cucchiaiata-cli v1.setting.session.servermodel.stop --session_id "$S" --save
[ "$R" = "${argv[i]}" ]
done
}
# Import Cadoles seed # Servermodel etab1
cucchiaiata-cli setting.source.create -o cadoles -d /srv/risotto/seed/cadoles S=$(cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name etab1 | jq -r .session_id)
cucchiaiata-cli v1.setting.session.servermodel.configure --session_id "$S" --configuration.reseau.unbound_domain_name dns.cadoles.com
cucchiaiata-cli v1.setting.session.servermodel.stop --session_id "$S" --save
# Create a new user and set role 'server_rw' for the server dns.cadoles.com # Servermodel unbound
cucchiaiata-cli user.user.create -u gnunux -n gnunux -s gnunux S=$(cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound| jq -r .session_id)
cucchiaiata-cli user.role.create -u gnunux -o 'server_rw' -a 'Server.ServerName' -v dns.cadoles.com cucchiaiata-cli v1.setting.session.servermodel.configure --session_id "$S" --configuration.serveur_dns.unbound_local_zones cadoles.com
cucchiaiata-cli v1.setting.session.servermodel.filter --session_id "$S" --namespace unbound
cucchiaiata-cli v1.setting.session.servermodel.configure --session_id "$S" --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.hostname_cadoles_com toto titi \
--unbound.unbound_zone_cadoles_com.hostname_cadoles_com.ip_cadoles_com 0 192.168.1.25 \
--unbound.unbound_zone_cadoles_com.hostname_cadoles_com.type_cadoles_com 1 CNAME \
--unbound.unbound_zone_cadoles_com.hostname_cadoles_com.cname_cadoles_com 1 toto.cadoles.com
cucchiaiata-cli v1.setting.session.servermodel.stop --session_id "$S" --save
# Heritage # Server dns.cadoles.com
## ACA S=$(cucchiaiata-cli v1.setting.session.server.start --server dns.cadoles.com | jq -r .session_id)
cucchiaiata-cli setting.servermodel.create -m aca -d Aca -p base -o cadoles -e last cucchiaiata-cli v1.setting.session.server.configure --session_id "$S" --configuration.reseau.unbound_ip_address_cidr 192.168.1.1/24
cucchiaiata-cli setting.servermodel.dependency.add -m aca -a unbound -o cadoles -e last cucchiaiata-cli v1.setting.session.server.validate --session_id $S
cucchiaiata-cli v1.setting.session.server.stop --session_id "$S" --save
S=$(cucchiaiata-cli setting.session.servermodel.start -m aca -e last| jq -r .session_id)
verif servermodel null null [] null
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --configuration.reseau.unbound_route_address 192.168.1.2
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --configuration.serveur_dns.unbound_allowed_client_cidr 192.168.1.0/24
verif servermodel 192.168.1.2 null [] null
cucchiaiata-cli setting.session.servermodel.stop -s "$S" -a
## etab1
cucchiaiata-cli setting.servermodel.create -m etab1 -d "Etab 1" -p aca -o internal -e last
S=$(cucchiaiata-cli setting.session.servermodel.start -m etab1 -e last| jq -r .session_id)
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --configuration.reseau.unbound_domain_name dns.cadoles.com
verif servermodel 192.168.1.2 dns.cadoles.com [] null
cucchiaiata-cli setting.session.servermodel.stop -s "$S" -a
## unbound
cucchiaiata-cli setting.servermodel.create -m unbound -d "generic unbound configuration" -p fedora-32 -o cadoles -e last
cucchiaiata-cli setting.servermodel.dependency.add -m unbound -a unbound -o cadoles -e last
S=$(cucchiaiata-cli setting.session.servermodel.start -m unbound -e last| jq -r .session_id)
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --configuration.serveur_dns.unbound_local_zones cadoles.com
cucchiaiata-cli setting.session.servermodel.filter -s "$S" -n unbound
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.hostname_cadoles_com toto titi
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.ip_cadoles_com 0 192.168.1.25
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.type_cadoles_com 1 CNAME
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.cname_cadoles_com 1 toto.cadoles.com
cucchiaiata-cli setting.session.servermodel.filter -s "$S" -n configuration
verif servermodel null null '["cadoles.com"]' null
cucchiaiata-cli setting.session.servermodel.stop -s "$S" -a
## unbound_etab1
cucchiaiata-cli setting.servermodel.create -m unbound_etab1 -d "unbound configuration for etab1" -p etab1 unbound -o internal -e last
S=$(cucchiaiata-cli setting.session.servermodel.start -m unbound_etab1 -e last | jq -r .session_id)
verif servermodel 192.168.1.2 dns.cadoles.com '["cadoles.com"]' null
cucchiaiata-cli setting.session.servermodel.stop -s "$S" -a
# Create sites and zone
cucchiaiata-cli infra.site.create -i cluster -d "Cluster"
cucchiaiata-cli infra.site.create -i etab1 -d "Etab 1"
cucchiaiata-cli infra.zone.create -z pedago -d "Pedago" -s etab1 cluster -n "192.168.1.0/24" -t "192.168.1.10" -e "192.168.1.100" -q 192.168.1.1 -g 192.168.1.254
# Create a servermodel for node in cluster and a server "node1"
cucchiaiata-cli setting.servermodel.create -m cluster -d "Node in the cluster" -p base -o cadoles -e last
cucchiaiata-cli infra.server.create -s node1.cadoles.com -d node1 -m cluster -e last -i cluster -z pedago
# Create a new server "dns"
cucchiaiata-cli infra.server.create -s dns.cadoles.com -d description -m unbound_etab1 -e last -i etab1 -z pedago
# Create a cluster with one node and one VM
cucchiaiata-cli provider.factory.cluster.create -c cluster.cadoles.com -d toto -v 192.168.1.1 -z pedago
cucchiaiata-cli provider.factory.cluster.join -c cluster.cadoles.com -n node1.cadoles.com
cucchiaiata-cli provider.factory.server.add -s dns.cadoles.com -c cluster.cadoles.com -p 0.2 -v 2 -m 2
# Configure server
S=$(cucchiaiata-cli setting.session.server.start -s dns.cadoles.com | jq -r .session_id)
cucchiaiata-cli setting.session.server.configure -s "$S" --configuration.reseau.unbound_ip_address_cidr 192.168.1.1/24
cucchiaiata-cli setting.session.server.validate -s $S
verif server 192.168.1.2 dns.cadoles.com '["cadoles.com"]' 192.168.1.1/24
cucchiaiata-cli setting.session.server.stop -s "$S" -a
# Generate configuration # Generate configuration
cucchiaiata-cli setting.config.configuration.server.deploy -s dns.cadoles.com cucchiaiata-cli v1.setting.config.configuration.server.deploy --server dns.cadoles.com
cucchiaiata-cli setting.template.generate -s dns.cadoles.com cucchiaiata-cli v1.setting.template.generate --server dns.cadoles.com
# Add OpenSSH dependency
cucchiaiata-cli setting.servermodel.dependency.add -m aca -a openssh -o cadoles -e last
S=$(cucchiaiata-cli setting.session.server.start -s dns.cadoles.com | jq -r .session_id)
R=$(cucchiaiata-cli setting.session.server.get -s "$S" -n configuration.serveur_ssh.ssh_allow_networks | jq -Mcr .content[])
[ "$R" = "[]" ]
cucchiaiata-cli setting.session.server.stop -s "$S"
S=$(cucchiaiata-cli setting.session.servermodel.start -m aca -e last| jq -r .session_id)
cucchiaiata-cli setting.session.servermodel.configure -s "$S" --configuration.serveur_ssh.ssh_allow_networks admin.cadoles.com
cucchiaiata-cli setting.session.servermodel.stop -s "$S" -a
S=$(cucchiaiata-cli setting.session.server.start -s dns.cadoles.com | jq -r .session_id)
R=$(cucchiaiata-cli setting.session.server.get -s "$S" -n configuration.serveur_ssh.ssh_allow_networks | jq -Mcr .content[])
[ "$R" = '["admin.cadoles.com"]' ]
cucchiaiata-cli setting.session.server.stop -s "$S"
# Regenerate configuration
cucchiaiata-cli setting.config.configuration.server.deploy -s dns.cadoles.com
cucchiaiata-cli setting.template.generate -s dns.cadoles.com
# Generate cluster's configurtion # Generate cluster's configurtion
cucchiaiata-cli provider.factory.configure -c cluster.cadoles.com #cucchiaiata-cli v1.provider.factory.configure -c cluster.cadoles.com
#cucchiaiata-cli v1.provider.factory.deploy --server dns.cadoles.com
echo "fin" echo "fin"