mirror of
https://github.com/YunoHost-Apps/nomad_ynh.git
synced 2024-09-03 19:55:53 +02:00
LXC driver
This commit is contained in:
parent
ba83dc8281
commit
700cb2ac75
7 changed files with 139 additions and 65 deletions
|
@ -6,6 +6,7 @@
|
||||||
bootstrap_expect="1"
|
bootstrap_expect="1"
|
||||||
retry_join="192.168.1.100"
|
retry_join="192.168.1.100"
|
||||||
server_ip="192.168.1.100"
|
server_ip="192.168.1.100"
|
||||||
|
driver_lxc=1
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
bootstrap_expect="1"
|
bootstrap_expect="1"
|
||||||
retry_join="192.168.1.100"
|
retry_join="192.168.1.100"
|
||||||
server_ip="none..."
|
server_ip="none..."
|
||||||
|
driver_lxc=1
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
|
|
@ -74,6 +74,26 @@
|
||||||
},
|
},
|
||||||
"example": "192.168.1.100",
|
"example": "192.168.1.100",
|
||||||
"optional": true
|
"optional": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "server_ip",
|
||||||
|
"type": "string",
|
||||||
|
"ask": {
|
||||||
|
"en": "[Client only] What is the IP of the Nomad server node ?"
|
||||||
|
},
|
||||||
|
"example": "192.168.1.100",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "driver_lxc",
|
||||||
|
"type": "boolean",
|
||||||
|
"ask": {
|
||||||
|
"en": "[Client only] Do you want to install LXC driver ?"
|
||||||
|
},
|
||||||
|
"default": true,
|
||||||
|
"help": {
|
||||||
|
"en": "It will also install lxc."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="nomad"
|
pkg_dependencies="nomad"
|
||||||
|
|
||||||
client_pkg_dependencies="pkg-config lxc-dev lxc lxc-templates"
|
server_pkg_dependencies=""
|
||||||
|
|
||||||
|
client_pkg_dependencies=""
|
||||||
|
client_lxc_pkg_dependencies="pkg-config lxc-dev lxc lxc-templates"
|
||||||
|
|
||||||
go_version=1.15
|
go_version=1.15
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ node_type=$YNH_APP_ARG_NODE_TYPE
|
||||||
bootstrap_expect=$YNH_APP_ARG_BOOTSTRAP_EXPECT
|
bootstrap_expect=$YNH_APP_ARG_BOOTSTRAP_EXPECT
|
||||||
retry_join=$YNH_APP_ARG_RETRY_JOIN
|
retry_join=$YNH_APP_ARG_RETRY_JOIN
|
||||||
server_ip=$YNH_APP_ARG_SERVER_IP
|
server_ip=$YNH_APP_ARG_SERVER_IP
|
||||||
|
driver_lxc=$YNH_APP_ARG_DRIVER_LXC
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ ynh_app_setting_set --app=$app --key=node_type --value=$node_type
|
||||||
ynh_app_setting_set --app=$app --key=bootstrap_expect --value=$bootstrap_expect
|
ynh_app_setting_set --app=$app --key=bootstrap_expect --value=$bootstrap_expect
|
||||||
ynh_app_setting_set --app=$app --key=retry_join --value=$retry_join
|
ynh_app_setting_set --app=$app --key=retry_join --value=$retry_join
|
||||||
ynh_app_setting_set --app=$app --key=server_ip --value=$server_ip
|
ynh_app_setting_set --app=$app --key=server_ip --value=$server_ip
|
||||||
|
ynh_app_setting_set --app=$app --key=driver_lxc --value=$driver_lxc
|
||||||
ynh_app_setting_set --app=$app --key=lxc_bridge --value=$lxc_bridge
|
ynh_app_setting_set --app=$app --key=lxc_bridge --value=$lxc_bridge
|
||||||
ynh_app_setting_set --app=$app --key=plage_ip --value=$plage_ip
|
ynh_app_setting_set --app=$app --key=plage_ip --value=$plage_ip
|
||||||
ynh_app_setting_set --app=$app --key=main_iface --value=$main_iface
|
ynh_app_setting_set --app=$app --key=main_iface --value=$main_iface
|
||||||
|
@ -96,10 +98,19 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
|
if [ "$node_type" == "server" ]
|
||||||
|
then
|
||||||
|
ynh_install_app_dependencies $server_pkg_dependencies
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
ynh_install_app_dependencies $client_pkg_dependencies
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
$client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies"
|
||||||
ynh_install_go --go_version=$go_version
|
ynh_install_go --go_version=$go_version
|
||||||
|
fi
|
||||||
|
ynh_install_app_dependencies $client_pkg_dependencies
|
||||||
fi
|
fi
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg"
|
ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg"
|
||||||
|
|
||||||
|
@ -137,11 +148,13 @@ chmod -R o-rwx "$datadir"
|
||||||
chown -R $app:$app "$datadir"
|
chown -R $app:$app "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD LXC DRIVER
|
# BUILD DRIVERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
ynh_script_progression --message="Building LXC driver..."
|
ynh_script_progression --message="Building LXC driver..."
|
||||||
|
|
||||||
tempdir="$(mktemp -d)"
|
tempdir="$(mktemp -d)"
|
||||||
|
@ -158,6 +171,7 @@ then
|
||||||
mv -f $tempdir/nomad-driver-lxc $datadir/plugins/nomad-driver-lxc
|
mv -f $tempdir/nomad-driver-lxc $datadir/plugins/nomad-driver-lxc
|
||||||
|
|
||||||
ynh_secure_remove --file="$tempdir"
|
ynh_secure_remove --file="$tempdir"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -190,6 +204,8 @@ then
|
||||||
chmod 400 "$config_path/client.hcl"
|
chmod 400 "$config_path/client.hcl"
|
||||||
chown $app:$app "$config_path/client.hcl"
|
chown $app:$app "$config_path/client.hcl"
|
||||||
|
|
||||||
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
ynh_add_config --template="../conf/driver-lxc.hcl" --destination="$config_path/driver-lxc.hcl"
|
ynh_add_config --template="../conf/driver-lxc.hcl" --destination="$config_path/driver-lxc.hcl"
|
||||||
chmod 400 "$config_path/driver-lxc.hcl"
|
chmod 400 "$config_path/driver-lxc.hcl"
|
||||||
chown $app:$app "$config_path/driver-lxc.hcl"
|
chown $app:$app "$config_path/driver-lxc.hcl"
|
||||||
|
@ -203,6 +219,7 @@ then
|
||||||
ynh_add_config --template="../conf/default.conf" --destination="/etc/lxc/default.conf"
|
ynh_add_config --template="../conf/default.conf" --destination="/etc/lxc/default.conf"
|
||||||
systemctl enable lxc-net --quiet
|
systemctl enable lxc-net --quiet
|
||||||
ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Started LXC network bridge" --log_path="systemd"
|
ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Started LXC network bridge" --log_path="systemd"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
node_type=$(ynh_app_setting_get --app=$app --key=node_type)
|
node_type=$(ynh_app_setting_get --app=$app --key=node_type)
|
||||||
|
driver_lxc=$(ynh_app_setting_get --app=$app --key=driver_lxc)
|
||||||
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
||||||
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
||||||
|
|
||||||
|
@ -80,6 +81,8 @@ fi
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge)
|
lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge)
|
||||||
|
|
||||||
ynh_systemd_action --service_name=lxc-net --action="stop"
|
ynh_systemd_action --service_name=lxc-net --action="stop"
|
||||||
|
@ -88,6 +91,7 @@ then
|
||||||
ynh_secure_remove --file="/etc/lxc/default.conf"
|
ynh_secure_remove --file="/etc/lxc/default.conf"
|
||||||
ynh_secure_remove --file="/etc/dnsmasq.d/lxd"
|
ynh_secure_remove --file="/etc/dnsmasq.d/lxd"
|
||||||
systemctl restart dnsmasq
|
systemctl restart dnsmasq
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -32,6 +32,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
node_type=$(ynh_app_setting_get --app=$app --key=node_type)
|
node_type=$(ynh_app_setting_get --app=$app --key=node_type)
|
||||||
|
driver_lxc=$(ynh_app_setting_get --app=$app --key=driver_lxc)
|
||||||
http_port=$(ynh_app_setting_get --app=$app --key=http_port)
|
http_port=$(ynh_app_setting_get --app=$app --key=http_port)
|
||||||
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
||||||
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
||||||
|
@ -71,8 +72,17 @@ chown -R $app:$app "$datadir"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
|
if [ "$node_type" == "server" ]
|
||||||
|
then
|
||||||
|
ynh_install_app_dependencies $server_pkg_dependencies
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
$client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies"
|
||||||
|
fi
|
||||||
ynh_install_app_dependencies $client_pkg_dependencies
|
ynh_install_app_dependencies $client_pkg_dependencies
|
||||||
fi
|
fi
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg"
|
ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg"
|
||||||
|
@ -107,7 +117,8 @@ fi
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge)
|
lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge)
|
||||||
plage_ip=$(ynh_app_setting_get --app=$app --key=plage_ip)
|
plage_ip=$(ynh_app_setting_get --app=$app --key=plage_ip)
|
||||||
main_iface=$(ip route | grep default | awk '{print $5;}')
|
main_iface=$(ip route | grep default | awk '{print $5;}')
|
||||||
|
@ -122,6 +133,7 @@ then
|
||||||
ynh_add_config --template="../conf/default.conf" --destination="/etc/lxc/default.conf"
|
ynh_add_config --template="../conf/default.conf" --destination="/etc/lxc/default.conf"
|
||||||
systemctl enable lxc-net --quiet
|
systemctl enable lxc-net --quiet
|
||||||
ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Started LXC network bridge" --log_path="systemd"
|
ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Started LXC network bridge" --log_path="systemd"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -25,6 +25,7 @@ node_type=$(ynh_app_setting_get --app=$app --key=node_type)
|
||||||
bootstrap_expect=$(ynh_app_setting_get --app=$app --key=bootstrap_expect)
|
bootstrap_expect=$(ynh_app_setting_get --app=$app --key=bootstrap_expect)
|
||||||
retry_join=$(ynh_app_setting_get --app=$app --key=retry_join)
|
retry_join=$(ynh_app_setting_get --app=$app --key=retry_join)
|
||||||
server_ip=$(ynh_app_setting_get --app=$app --key=server_ip)
|
server_ip=$(ynh_app_setting_get --app=$app --key=server_ip)
|
||||||
|
driver_lxc=$(ynh_app_setting_get --app=$app --key=driver_lxc)
|
||||||
http_port=$(ynh_app_setting_get --app=$app --key=http_port)
|
http_port=$(ynh_app_setting_get --app=$app --key=http_port)
|
||||||
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
||||||
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
||||||
|
@ -85,10 +86,19 @@ ynh_system_user_create --username=$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
|
if [ "$node_type" == "server" ]
|
||||||
|
then
|
||||||
|
ynh_install_app_dependencies $server_pkg_dependencies
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
ynh_install_app_dependencies $client_pkg_dependencies
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
$client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies"
|
||||||
ynh_install_go --go_version=$go_version
|
ynh_install_go --go_version=$go_version
|
||||||
|
fi
|
||||||
|
ynh_install_app_dependencies $client_pkg_dependencies
|
||||||
fi
|
fi
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg"
|
ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg"
|
||||||
|
|
||||||
|
@ -103,11 +113,13 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD LXC DRIVER
|
# BUILD DRIVERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
ynh_script_progression --message="Building LXC driver..."
|
ynh_script_progression --message="Building LXC driver..."
|
||||||
|
|
||||||
tempdir="$(mktemp -d)"
|
tempdir="$(mktemp -d)"
|
||||||
|
@ -124,6 +136,7 @@ then
|
||||||
mv -f $tempdir/nomad-driver-lxc $datadir/plugins/nomad-driver-lxc
|
mv -f $tempdir/nomad-driver-lxc $datadir/plugins/nomad-driver-lxc
|
||||||
|
|
||||||
ynh_secure_remove --file="$tempdir"
|
ynh_secure_remove --file="$tempdir"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -153,9 +166,12 @@ then
|
||||||
chmod 400 "$config_path/client.hcl"
|
chmod 400 "$config_path/client.hcl"
|
||||||
chown $app:$app "$config_path/client.hcl"
|
chown $app:$app "$config_path/client.hcl"
|
||||||
|
|
||||||
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
ynh_add_config --template="../conf/driver-lxc.hcl" --destination="$config_path/driver-lxc.hcl"
|
ynh_add_config --template="../conf/driver-lxc.hcl" --destination="$config_path/driver-lxc.hcl"
|
||||||
chmod 400 "$config_path/driver-lxc.hcl"
|
chmod 400 "$config_path/driver-lxc.hcl"
|
||||||
chown $app:$app "$config_path/driver-lxc.hcl"
|
chown $app:$app "$config_path/driver-lxc.hcl"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue