2020-03-16 10:44:22 +01:00
#!/usr/bin/env bash
2020-09-02 09:03:34 +02:00
set -xe
2020-08-12 08:24:10 +02:00
2020-09-02 09:03:34 +02:00
#=======================================================================================================
# Import Cadoles seed
#=======================================================================================================
2020-09-19 10:34:36 +02:00
cucchiaiata-cli v1.setting.source.create --source_name cadoles --source_directory /usr/share/risotto/seed/cadoles
2020-09-02 09:03:34 +02:00
#=======================================================================================================
# Infrastructure
#=======================================================================================================
2020-08-12 08:24:10 +02:00
2020-09-02 09:03:34 +02:00
# 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
2020-08-12 08:24:10 +02:00
# + = = = = = = = = = = = = = = = = = = = = = = = +
2020-09-02 09:03:34 +02:00
# " SITE site_cluster "
2020-08-12 08:24:10 +02:00
# " +-------------------+ "
# " | node1.cadoles.com | "-----------+
2020-09-02 09:03:34 +02:00
# " +-------------------+ " +~~~~~~~~+
2020-08-12 08:24:10 +02:00
# + = = = = = = = = = = = = = = = = = = = = = = = + ! ZONE !
# ! pedago !
# + = = = = = = = = = = = = = = = = = = = = = = = + +~~~~~~~~+
# " SITE etab1 " |
2020-09-02 09:03:34 +02:00
# " +-----------------+ "-----------+
# " | dns.cadoles.com | "
2020-08-12 08:24:10 +02:00
# " +-----------------+ "
# + = = = = = = = = = = = = = = = = = = = = = = = +
2020-09-02 09:03:34 +02:00
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
2020-09-16 08:04:56 +02:00
# -> base-fedora-32 (cadoles' servermodel)
2020-09-02 09:03:34 +02:00
# |-> sm_cluster (servermodel)
# | '-> node1.cadoles.com (server)
# |
# |-> aca (servermodel) + unbound (AS) + openssh (AS)
2020-09-16 08:04:56 +02:00
# | '-> etab1 (servermodel) -----------------,
# | |--> unbound_etab1 (servermodel)
# '-> unbound (servermodel) + unbound (AS) --' '-> dns.cadoles.com (server)
2020-09-02 09:03:34 +02:00
## sm_cluster
2020-09-16 08:04:56 +02:00
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name sm_cluster --applicationservices base-fedora-32
2020-09-02 09:03:34 +02:00
## 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
2020-09-16 08:04:56 +02:00
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name unbound --applicationservices unbound
2020-09-02 09:03:34 +02:00
## 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
2020-08-12 08:24:10 +02:00
2020-09-02 09:03:34 +02:00
# Create a cluster
cucchiaiata-cli v1.provider.factory.cluster.create --cluster_name cluster.cadoles.com --virtual_ip 192.168.1.1 --zone_name pedago
2020-08-12 08:24:10 +02:00
# Cluster description:
# +-----------------------------+
# + cluster.cadoles.com +
# + +--------------------+ +
# + + node1.cadoles.com + +
# + +--------------------+ +
# +-----------------------------+
2020-09-02 09:03:34 +02:00
cucchiaiata-cli v1.provider.factory.cluster.join --cluster_name cluster.cadoles.com --node_name node1.cadoles.com
2020-08-12 08:24:10 +02:00
# Cluster execution:
# +-----------------------------+
# + cluster.cadoles.com +
# + +--------------------+ +
# + + dns.cadoles.com + +
# + +--------------------+ +
# +-----------------------------+
2020-09-02 09:03:34 +02:00
cucchiaiata-cli v1.provider.factory.server.add --server dns.cadoles.com --cluster_name cluster.cadoles.com --cpu 0.2 --vcpu 2 --memory 2
2020-08-12 08:24:10 +02:00
2020-09-02 09:03:34 +02:00
#=======================================================================================================
# Configuration
#=======================================================================================================
# Servermodel ACA
S = $( cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name aca| jq -r .session_id)
cucchiaiata-cli v1.setting.session.servermodel.configure --session_id " $S " --configuration.reseau.unbound_route_address 192.168.1.2 \
--configuration.serveur_dns.unbound_allowed_client_cidr 192.168.1.0/24 \
--configuration.serveur_ssh.ssh_allow_networks admin.cadoles.com
cucchiaiata-cli v1.setting.session.servermodel.stop --session_id " $S " --save
# Servermodel etab1
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
# Servermodel unbound
S = $( cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound| jq -r .session_id)
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
# Server dns.cadoles.com
S = $( cucchiaiata-cli v1.setting.session.server.start --server dns.cadoles.com | jq -r .session_id)
cucchiaiata-cli v1.setting.session.server.configure --session_id " $S " --configuration.reseau.unbound_ip_address_cidr 192.168.1.1/24
cucchiaiata-cli v1.setting.session.server.validate --session_id $S
cucchiaiata-cli v1.setting.session.server.stop --session_id " $S " --save
2020-03-16 10:44:22 +01:00
# Generate configuration
2020-09-02 09:03:34 +02:00
cucchiaiata-cli v1.setting.config.configuration.server.deploy --server dns.cadoles.com
cucchiaiata-cli v1.setting.template.generate --server dns.cadoles.com
2020-03-23 08:53:12 +01:00
# Generate cluster's configurtion
2020-09-02 09:03:34 +02:00
#cucchiaiata-cli v1.provider.factory.configure -c cluster.cadoles.com
#cucchiaiata-cli v1.provider.factory.deploy --server dns.cadoles.com
2020-03-16 10:44:22 +01:00
echo "fin"