Browse Source

new: dev: [apache] use only ``init-config-add``.

framadate
Valentin Lab 5 years ago
parent
commit
b17b4db0c7
  1. 42
      apache/lib/common
  2. 28
      apache/test/vhost_cert_provider
  3. 26
      apache/test/vhost_files

42
apache/lib/common

@ -323,15 +323,14 @@ ssl_fallback_prepare() {
echo "$content" | file_put "$dst$location"
config_hash=$(printf "%s\0" "$config_hash" "$label" "$content" | md5_compat)
volumes="$volumes
- $dst$location:$location:ro"
- $dst$location:$location:ro"
fi
done
if [ "$volumes" ]; then
config-add "\
services:
$MASTER_TARGET_SERVICE_NAME:
volumes:
init-config-add "\
$MASTER_TARGET_SERVICE_NAME:
volumes:
$volumes
"
fi
@ -365,11 +364,10 @@ ssl_plugin_cert-provider_prepare() {
err "Failed to launch letsencrypt for certificate creation."
return 1
}
config-add "\
services:
$MASTER_TARGET_SERVICE_NAME:
volumes:
- $DATASTORE/$service/etc/letsencrypt:/etc/letsencrypt:ro
init-config-add "\
$SERVICE_NAME:
volumes:
- $DATASTORE/$service/etc/letsencrypt:/etc/letsencrypt:ro
" || return 1
}
@ -437,8 +435,8 @@ apache_code_dir() {
setfacl -R -m g:"$www_data_gid":rx "$host_path"
info "Set permission for read and traversal on '$host_path'."
config-add "
$MASTER_BASE_SERVICE_NAME:
init-config-add "
$SERVICE_NAME:
volumes:
- $host_path:$local_path
"
@ -475,8 +473,8 @@ apache_data_dirs() {
setfacl -R -m g:"$www_data_gid":rwx "${dirs[@]}"
setfacl -R -d -m g:"$www_data_gid":rwx "${dirs[@]}"
config-add "
$MASTER_BASE_SERVICE_NAME:
init-config-add "
$SERVICE_NAME:
volumes:
$(
for d in "${data[@]}"; do
@ -502,14 +500,14 @@ export -f deploy_files
apache_core_rules_add() {
local conf="$1" dst="/etc/apache2/conf-enabled/$BASE_SERVICE_NAME.conf"
local conf="$1" dst="/etc/apache2/conf-enabled/$SERVICE_NAME.conf"
debug "Adding core rule."
echo "$conf" | file_put "$CONFIGSTORE/$BASE_SERVICE_NAME$dst"
echo "$conf" | file_put "$CONFIGSTORE/$SERVICE_NAME$dst"
config_hash=$(printf "%s\0" "$config_hash" "$conf" | md5_compat)
config-add "
$MASTER_BASE_SERVICE_NAME:
init-config-add "
$SERVICE_NAME:
volumes:
- $CONFIGSTORE/$BASE_SERVICE_NAME$dst:$dst:ro
- $CONFIGSTORE/$SERVICE_NAME$dst:$dst:ro
"
}
@ -851,8 +849,10 @@ apache_config_hash() {
-name \*.conf -exec md5sum {} \;
} | md5_compat) || exit 1
init-config-add "
$MASTER_BASE_SERVICE_NAME:
$SERVICE_NAME:
labels:
- compose.config_hash=$config_hash
- compose.config_hash=$config_hash
"
}

28
apache/test/vhost_cert_provider

@ -104,6 +104,12 @@ config-add() {
}
export -f config-add
init-config-add() {
echo "config-add"
echo "$1" | prefix " | "
}
export -f init-config-add
mkdir() {
echo "called: $FUNCNAME $@" >&2
}
@ -165,6 +171,7 @@ try "
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
export CONFIGSTORE='\$CONFIGSTORE'
export DATASTORE='\$DATASTORE'
export SERVICE_NAME='\$SERVICE_NAME'
export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
CFG='
@ -198,10 +205,9 @@ relation-set apache-custom-rules:
|"
is out reg 'Calling: compose .*foo: options: <merge_yaml_str\(.a., .12., )>.*run --rm --service-ports foo.*'
is out part 'config-add
| services:
| $MASTER_TARGET_SERVICE_NAME:
| volumes:
| - $DATASTORE/foo/etc/letsencrypt:/etc/letsencrypt:ro'
| $SERVICE_NAME:
| volumes:
| - $DATASTORE/foo/etc/letsencrypt:/etc/letsencrypt:ro'
is out part '
| ## Auto-redirection from http to https
| RewriteEngine On
@ -251,10 +257,9 @@ relation-set apache-custom-rules:
is out reg 'Calling: compose .*foo: options: <merge_yaml_str\(.a., .12., )>.*run --rm --service-ports foo crt create www.example.com\s*
' RTRIM
is out part 'config-add
| services:
| $MASTER_TARGET_SERVICE_NAME:
| volumes:
| - $DATASTORE/foo/etc/letsencrypt:/etc/letsencrypt:ro'
| $SERVICE_NAME:
| volumes:
| - $DATASTORE/foo/etc/letsencrypt:/etc/letsencrypt:ro'
is out part 'file_put $SERVICE_CONFIGSTORE/etc/apache2/sites-enabled/www.example.com.conf
| <VirtualHost *:80>
|
@ -313,10 +318,9 @@ relation-set apache-custom-rules:
is out reg 'Calling: compose .*foo: options: <merge_yaml_str\(.a., .12., )>.*run --rm --service-ports foo crt create www.example.com example.fr example.de\s+
'
is out part 'config-add
| services:
| $MASTER_TARGET_SERVICE_NAME:
| volumes:
| - $DATASTORE/foo/etc/letsencrypt:/etc/letsencrypt:ro'
| $SERVICE_NAME:
| volumes:
| - $DATASTORE/foo/etc/letsencrypt:/etc/letsencrypt:ro'
is out part 'file_put $SERVICE_CONFIGSTORE/etc/apache2/sites-enabled/www.example.com.conf
| <VirtualHost *:80>
|

26
apache/test/vhost_files

@ -60,6 +60,12 @@ config-add() {
}
export -f config-add
init-config-add() {
echo "init-config-add"
echo "$1" | prefix " | "
}
export -f init-config-add
mkdir() {
echo "called: $FUNCNAME $@" >&2
}
@ -208,7 +214,7 @@ is out part 'file_put $CONFIGSTORE/$BASE_SERVICE_NAME/etc/ssl/certs/www.example.
is out part 'file_put $CONFIGSTORE/$BASE_SERVICE_NAME/etc/ssl/private/www.example.com.key
| a
| b'
is out reg 'config-add'
is out reg 'init-config-add'
is out reg ' - \$CONFIGSTORE/\$BASE_SERVICE_NAME/etc/ssl/certs/www.example.com.pem:/etc/ssl/certs/www.example.com.pem:ro'
is out reg ' - \$CONFIGSTORE/\$BASE_SERVICE_NAME/etc/ssl/private/www.example.com.key:/etc/ssl/private/www.example.com.key:ro'
@ -233,6 +239,16 @@ relation-set protocol:
is out reg "htpasswd -bc '/etc/apache2/sites-enabled/www.example.com.passwd' 'toto' 'xxx'"
is out reg 'docker run -i --entrypoint /bin/bash .* docker/apache'
try "
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
apache_vhost_create publish_dir '' ',http,' '000-default'"
is errlvl 0
is err part "\
relation-set protocol:
| http"
is out reg '^file_put \$SERVICE_CONFIGSTORE/.*/000-default.conf'
##
## apache_publish_dir
@ -296,6 +312,7 @@ export DATASTORE='\$DATASTORE'
export DOCKER_BASE_IMAGE=docker/apache
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
export CONFIGSTORE='\$CONFIGSTORE'
export SERVICE_NAME='\$SERVICE_NAME'
export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
export MASTER_BASE_SERVICE_NAME='\$MASTER_BASE_SERVICE_NAME'
export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
@ -313,9 +330,12 @@ data-dirs:
is errlvl 0
is err reg 'mkdir -p /opt/apps/newlocation'
is err reg 'setfacl -R -m g:<GID>:rx /opt/apps/newlocation'
is out part ' | $MASTER_BASE_SERVICE_NAME:
is out part '
init-config-add
|
| $SERVICE_NAME:
| volumes:
| - /opt/apps/newlocation:/var/www/www.example.com'
| - /opt/apps/newlocation:/var/www/www.example.com' RTRIM

Loading…
Cancel
Save