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
|
|
|
|
2021-03-27 22:17:39 +01:00
|
|
|
function get_id() {
|
|
|
|
S=$($1)
|
|
|
|
V=$(echo $S|jq -r .session_id)
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo $V
|
|
|
|
else
|
|
|
|
echo $S
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
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
|
2020-11-14 08:18:24 +01:00
|
|
|
cucchiaiata-cli v1.user.user.create --login gnunux \
|
|
|
|
--name gnunux \
|
|
|
|
--surname gnunux \
|
|
|
|
--email egarette@cadoles.com
|
|
|
|
cucchiaiata-cli v1.user.role.create --user_login gnunux \
|
|
|
|
--role_name 'server_rw' \
|
|
|
|
--role_attribute 'Server.ServerName' \
|
|
|
|
--role_attribute_value dns.cadoles.com
|
|
|
|
|
2020-09-02 09:03:34 +02:00
|
|
|
# Zone
|
2020-11-14 08:18:24 +01:00
|
|
|
# +~~~~~~~~~~+
|
|
|
|
# ! ZONE !
|
|
|
|
# ! internet !
|
|
|
|
# +~~~~~~~~~~+
|
|
|
|
cucchiaiata-cli v1.infra.zone.create --zone_name internet
|
|
|
|
# zone configuration
|
2021-03-27 22:17:39 +01:00
|
|
|
S=$(get_id "cucchiaiata-cli v1.setting.session.zone.start --zone_name internet")
|
2021-05-18 19:04:24 +02:00
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.network "192.168.0.0/24" \
|
|
|
|
--configuration.host.start "192.168.0.150" \
|
|
|
|
--configuration.host.stop "192.168.0.200" \
|
|
|
|
--configuration.dns 192.168.0.1 \
|
|
|
|
--configuration.vlan_id 0 \
|
|
|
|
--configuration.gateway 192.168.0.1
|
2020-11-14 08:18:24 +01:00
|
|
|
cucchiaiata-cli v1.setting.session.validate --session_id $S
|
|
|
|
cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save
|
|
|
|
|
|
|
|
|
2021-04-24 10:21:31 +02:00
|
|
|
# Create the cluster hapy.ac-test.fr
|
2020-11-14 08:18:24 +01:00
|
|
|
# +---------------------------+
|
2021-04-24 10:21:31 +02:00
|
|
|
# | hapy.ac-test.fr | +~~~~~~~~~~+
|
2020-11-14 08:18:24 +01:00
|
|
|
# | +--------------------+ |-------! ZONE !
|
|
|
|
# | | node1.cadoles.com |---|-------! internet !
|
|
|
|
# | +--------------------+ | +~~~~~~~~~~+
|
|
|
|
# +---------------------------+
|
2021-04-24 10:21:31 +02:00
|
|
|
cucchiaiata-cli v1.infra.cluster.create --cluster_name hapy.ac-test.fr \
|
|
|
|
--zone_name internet \
|
|
|
|
--zones_name internet
|
2020-11-16 08:12:02 +01:00
|
|
|
cucchiaiata-cli v1.infra.cluster.node.create --node_name node1.cadoles.com \
|
2021-04-24 10:21:31 +02:00
|
|
|
--cluster_name hapy.ac-test.fr
|
2020-11-14 08:18:24 +01:00
|
|
|
|
|
|
|
# configuration
|
2021-04-24 10:21:31 +02:00
|
|
|
S=$(get_id "cucchiaiata-cli v1.setting.session.cluster.start --cluster_name hapy.ac-test.fr")
|
2021-05-18 19:04:24 +02:00
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.virtual_ip "192.168.0.115"
|
2021-04-24 10:21:31 +02:00
|
|
|
# FIXME endpoint == https://<cluster_name>/RPC2
|
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.opennebula.one_user "eoleone"
|
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.opennebula.one_password "eole"
|
2020-11-14 08:18:24 +01:00
|
|
|
cucchiaiata-cli v1.setting.session.validate --session_id $S
|
|
|
|
cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save
|
|
|
|
|
|
|
|
# Organization, sites and zone
|
|
|
|
# + = = = = = = = = = = = = = = = = = = = = +
|
|
|
|
# " ORGANISATION cadoles.com "
|
|
|
|
# " + = = = = = = = = = = = + "
|
|
|
|
# " " SITE etab1 "----"----+ +~~~~~~~~~~+
|
|
|
|
# " + = = = = = = = = = = = + " |___! ZONE !
|
|
|
|
# " + = = = = = = = = = = = + " | ! internet !
|
|
|
|
# " " SITE etab2 "----"----+ +~~~~~~~~~~+
|
|
|
|
# " + = = = = = = = = = = = + "
|
|
|
|
# + = = = = = = = = = = = = = = = = = = = = +
|
|
|
|
cucchiaiata-cli v1.infra.organization.create --organization_name cadoles.com
|
|
|
|
cucchiaiata-cli v1.infra.site.create --site_name etab1 \
|
|
|
|
--organization_name cadoles.com \
|
|
|
|
--zones_name internet
|
|
|
|
cucchiaiata-cli v1.infra.site.create --site_name etab2 \
|
|
|
|
--organization_name cadoles.com \
|
|
|
|
--zones_name internet
|
2020-09-02 09:03:34 +02:00
|
|
|
|
|
|
|
# Servermodels
|
2020-09-20 21:10:18 +02:00
|
|
|
# -> base-fedora-32 (Cadoles)
|
|
|
|
# '-> unbound (Cadoles)
|
|
|
|
# '-> unbound (servermodel) ----,
|
|
|
|
# |
|
2020-11-14 08:18:24 +01:00
|
|
|
# -> openssh-server (Cadoles) |--> unbound_etab1 (servermodel)
|
2020-09-20 21:10:18 +02:00
|
|
|
# '-> aca (servermodel) |
|
|
|
|
# '-> etab1 (servermodel) ------'
|
2021-04-02 09:16:53 +02:00
|
|
|
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name unbound --applicationservices_name unbound
|
|
|
|
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name aca --applicationservices_name openssh-server
|
2020-09-20 21:10:18 +02:00
|
|
|
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name etab1 --parents_name aca
|
2020-09-02 09:03:34 +02:00
|
|
|
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name unbound_etab1 --parents_name etab1 unbound
|
2021-05-23 21:39:44 +02:00
|
|
|
cucchiaiata-cli v1.setting.servermodel.create --servermodel_name nsd_etab1 --parents_name etab1 --applicationservices_name nsd
|
2020-09-02 09:03:34 +02:00
|
|
|
|
2020-11-14 08:18:24 +01:00
|
|
|
# configuration
|
2020-09-02 09:03:34 +02:00
|
|
|
|
|
|
|
# Servermodel ACA
|
2021-03-27 22:17:39 +01:00
|
|
|
S=$(get_id "cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name aca")
|
2021-05-18 19:04:24 +02:00
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.ssh_server.ssh_allow_cidr 192.168.0.0/24
|
2020-11-14 08:18:24 +01:00
|
|
|
cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save
|
2020-09-02 09:03:34 +02:00
|
|
|
|
|
|
|
# Servermodel unbound
|
2021-03-27 22:17:39 +01:00
|
|
|
S=$(get_id "cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound")
|
2021-05-23 21:39:44 +02:00
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.dns_resolver.unbound_allowed_client_cidr 192.168.0.0/24
|
2020-11-14 08:18:24 +01:00
|
|
|
cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save
|
|
|
|
|
2020-09-20 21:10:18 +02:00
|
|
|
# Servermodel unbound_etab1
|
2021-03-27 22:17:39 +01:00
|
|
|
S=$(get_id "cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound_etab1")
|
2021-05-23 21:39:44 +02:00
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.dns_resolver.unbound_forward_zones.unbound_forward_zones cadoles.com \
|
|
|
|
--configuration.dns_resolver.unbound_forward_zones.unbound_forward_addresses 0 192.168.0.151
|
2020-11-14 08:18:24 +01:00
|
|
|
cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save
|
2020-09-02 09:03:34 +02:00
|
|
|
|
2020-11-14 08:18:24 +01:00
|
|
|
# Server
|
|
|
|
# + = = = = = = = = = = = = = = = = = = = = = = = +
|
|
|
|
# " SITE etab1 +-------------------+ " +~~~~~~~~~~+
|
|
|
|
# " | dns.cadoles.com |----"------! ZONE !
|
|
|
|
# " +-------------------+ " ! internet !
|
|
|
|
# " " +~~~~~~~~~~+
|
|
|
|
# + = = = = = = = = = = = = = = = = = = = = = = = +
|
|
|
|
# -> unbound_etab1
|
|
|
|
# '-> dns.cadoles.com (server)
|
|
|
|
cucchiaiata-cli v1.infra.server.create --server_name dns.cadoles.com \
|
|
|
|
--site_name etab1 \
|
2021-04-24 10:21:31 +02:00
|
|
|
--cluster_name hapy.ac-test.fr \
|
2020-11-14 08:18:24 +01:00
|
|
|
--zones_name internet \
|
|
|
|
--servermodel_name unbound_etab1
|
2021-05-23 21:39:44 +02:00
|
|
|
cucchiaiata-cli v1.infra.server.create --server_name nsd.cadoles.com \
|
|
|
|
--site_name etab1 \
|
|
|
|
--cluster_name hapy.ac-test.fr \
|
|
|
|
--zones_name internet \
|
|
|
|
--servermodel_name nsd_etab1
|
2020-11-14 08:18:24 +01:00
|
|
|
# configuration
|
2020-11-16 08:12:02 +01:00
|
|
|
sleep 1
|
2021-05-23 21:39:44 +02:00
|
|
|
S=$(get_id "cucchiaiata-cli v1.setting.session.server.start --server nsd.cadoles.com")
|
|
|
|
#FIXME IP en dure ?
|
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.dns_server.nsd_allowed_client_cidr 192.168.0.150/32 \
|
|
|
|
--configuration.dns_zone.nsd_zones cadoles.com
|
|
|
|
cucchiaiata-cli v1.setting.session.filter --session_id "$S" --namespace nsd
|
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --nsd.nsd_zone_cadoles_com.hostname_cadoles_com.hostname_cadoles_com toto titi \
|
|
|
|
--nsd.nsd_zone_cadoles_com.hostname_cadoles_com.ip_cadoles_com 0 192.168.0.25 \
|
|
|
|
--nsd.nsd_zone_cadoles_com.hostname_cadoles_com.type_cadoles_com 1 CNAME \
|
|
|
|
--nsd.nsd_zone_cadoles_com.hostname_cadoles_com.cname_cadoles_com 1 toto.cadoles.com
|
|
|
|
cucchiaiata-cli v1.setting.session.validate --session_id $S
|
|
|
|
cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save
|
|
|
|
|
2021-03-27 22:17:39 +01:00
|
|
|
S=$(get_id "cucchiaiata-cli v1.setting.session.server.start --server dns.cadoles.com")
|
2021-05-23 21:39:44 +02:00
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.dns_resolver.unbound_default_forwards 192.168.0.1
|
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.dns_resolver.unbound_local_authority "nsd.cadoles.com"
|
2020-11-14 08:18:24 +01:00
|
|
|
cucchiaiata-cli v1.setting.session.filter --session_id "$S" --namespace opennebula
|
2021-03-27 22:17:39 +01:00
|
|
|
cucchiaiata-cli v1.setting.session.configure --session_id "$S" --opennebula.cpu 0.2 \
|
2021-05-23 21:39:44 +02:00
|
|
|
--opennebula.vcpu 2
|
2020-11-14 08:18:24 +01:00
|
|
|
cucchiaiata-cli v1.setting.session.validate --session_id $S
|
|
|
|
cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save
|
2020-03-16 10:44:22 +01:00
|
|
|
|
2020-09-20 21:10:18 +02:00
|
|
|
#=======================================================================================================
|
|
|
|
# Deploy
|
|
|
|
#=======================================================================================================
|
|
|
|
|
2020-03-16 10:44:22 +01:00
|
|
|
# Generate configuration
|
2021-04-24 10:21:31 +02:00
|
|
|
cucchiaiata-cli v1.infra.cluster.deploy --cluster_name hapy.ac-test.fr
|
|
|
|
cucchiaiata-cli v1.infra.zone.deploy --zone_name internet
|
2021-05-23 21:39:44 +02:00
|
|
|
cucchiaiata-cli v1.infra.server.deploy --server_name nsd.cadoles.com
|
2021-04-24 10:21:31 +02:00
|
|
|
cucchiaiata-cli v1.infra.server.deploy --server_name dns.cadoles.com
|
2020-03-16 10:44:22 +01:00
|
|
|
echo "fin"
|