Browse Source

new: ``charm`` and ``service`` are now clear distinct concept

postgres
Valentin Lab 6 years ago
parent
commit
f05862af87
  1. 4
      apache/actions/load
  2. 2
      apache/actions/relations/publish-dir/load-files
  3. 6
      apache/hooks/log_rotate-relation-joined
  4. 30
      apache/lib/common
  5. 42
      apache/test/vhost_files
  6. 4
      odoo-tecnativa/hooks/postgres_database-relation-joined
  7. 2
      odoo-tecnativa/hooks/web_proxy-relation-joined
  8. 6
      odoo-tecnativa/lib/common
  9. 2
      postgres-alpine/hooks/postgres_database-relation-joined
  10. 2
      postgres/actions/relations/postgres-database/load-db
  11. 2
      postgres/hooks/postgres_database-relation-joined
  12. 6
      postgres/hooks/schedule_command-relation-joined
  13. 8
      sftp/hooks/sftp_access-relation-joined
  14. 2
      traefik/hooks/web_proxy-relation-joined

4
apache/actions/load

@ -46,8 +46,8 @@ fi
set -e
DOCKER_SITE_PATH=/var/www/$DOMAIN
if [ "$RELATION_BASE_CHARM" ]; then ## In a relation, we should use it then
DST=$DATASTORE/$RELATION_BASE_CHARM$DOCKER_SITE_PATH
if [ "$RELATION_BASE_SERVICE" ]; then ## In a relation, we should use it then
DST=$DATASTORE/$RELATION_BASE_SERVICE$DOCKER_SITE_PATH
else
DST=${SERVICE_DATASTORE}$DOCKER_SITE_PATH
fi

2
apache/actions/relations/publish-dir/load-files

@ -39,6 +39,6 @@ set -e
DOMAIN=$(relation-get domain)
run_service_action "$RELATION_TARGET_CHARM" load "$SOURCE" "$DOMAIN" "$@"
run_service_action "$RELATION_TARGET_SERVICE" load "$SOURCE" "$DOMAIN" "$@"
info "Correctly deployed '$SOURCE' towards domain '$DOMAIN'"

6
apache/hooks/log_rotate-relation-joined

@ -36,17 +36,17 @@ file_put "$DST" <<EOF
create 640 root root
sharedscripts
postrotate
docker-send-signal \$${MASTER_BASE_CHARM_NAME^^}_NAME SIGUSR1;
docker-send-signal \$${MASTER_BASE_SERVICE_NAME^^}_NAME SIGUSR1;
endscript
}
EOF
config-add "\
$MASTER_TARGET_CHARM_NAME:
$MASTER_TARGET_SERVICE_NAME:
volumes:
- $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro
- $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw
$MASTER_BASE_CHARM_NAME:
$MASTER_BASE_SERVICE_NAME:
volumes:
- $SERVICE_DATASTORE$LOGS:$LOGS:rw
"

30
apache/lib/common

@ -19,7 +19,7 @@ apache_publish_dir () {
}
DOCKER_SITE_PATH="/var/www/${DOMAIN}"
LOCATION=$(relation-get location 2>/dev/null) ||
LOCATION="$DATASTORE/$BASE_CHARM_NAME$DOCKER_SITE_PATH"
LOCATION="$DATASTORE/$BASE_SERVICE_NAME$DOCKER_SITE_PATH"
apache_vhost_create || return 1
info "Added $DOMAIN apache config."
@ -143,7 +143,7 @@ ssl_fallback_vars() {
ssl_fallback_prepare() {
local cfg="$1" cert key ca_cert
dst="$CONFIGSTORE/$BASE_CHARM_NAME"
dst="$CONFIGSTORE/$BASE_SERVICE_NAME"
volumes=""
for label in cert key ca_cert; do
content="$(eval echo "\"\$__vhost_cfg_ssl_$label\"")"
@ -157,7 +157,7 @@ ssl_fallback_prepare() {
if [ "$volumes" ]; then
config-add "\
$MASTER_TARGET_CHARM_NAME:
$MASTER_TARGET_SERVICE_NAME:
volumes:
$volumes
"
@ -182,7 +182,7 @@ ssl_plugin_letsencrypt-dns_prepare() {
config-add "\
services:
$MASTER_TARGET_CHARM_NAME:
$MASTER_TARGET_SERVICE_NAME:
volumes:
- $DATASTORE/${letsencrypt_charm}/etc/letsencrypt:/etc/letsencrypt:ro
" || return 1
@ -196,8 +196,8 @@ apache_passwd_file() {
## XXXvlab: called twice... no better way to do this ?
__vhost_creds_statement >/dev/null
first=
if ! [ -e "$CONFIGSTORE/$MASTER_TARGET_CHARM_NAME$password_file" ]; then
debug "No file $CONFIGSTORE/$MASTER_TARGET_CHARM_NAME$password_file, creating password file." || true
if ! [ -e "$CONFIGSTORE/$MASTER_TARGET_SERVICE_NAME$password_file" ]; then
debug "No file $CONFIGSTORE/$MASTER_TARGET_SERVICE_NAME$password_file, creating password file." || true
first=c
fi
while read-0 login password; do
@ -247,7 +247,7 @@ apache_code_dir() {
info "Set permission for read and traversal on '$LOCATION'."
config-add "
$MASTER_BASE_CHARM_NAME:
$MASTER_BASE_SERVICE_NAME:
volumes:
- $LOCATION:$DOCKER_SITE_PATH
"
@ -260,7 +260,7 @@ apache_data_dirs() {
return 0
fi
DST=$DATASTORE/$BASE_CHARM_NAME$DOCKER_SITE_PATH
DST=$DATASTORE/$BASE_SERVICE_NAME$DOCKER_SITE_PATH
DATA=()
while IFS="," read -ra ADDR; do
for dir in "${ADDR[@]}"; do
@ -284,7 +284,7 @@ apache_data_dirs() {
setfacl -R -d -m g:"$www_data_gid":rwx "${dirs[@]}"
config-add "
$MASTER_BASE_CHARM_NAME:
$MASTER_BASE_SERVICE_NAME:
volumes:
$(
for d in "${DATA[@]}"; do
@ -310,13 +310,13 @@ export -f deploy_files
apache_core_rules_add() {
local conf="$1" dst="/etc/apache2/conf-enabled/$BASE_CHARM_NAME.conf"
local conf="$1" dst="/etc/apache2/conf-enabled/$BASE_SERVICE_NAME.conf"
debug "Adding core rule."
echo "$conf" | file_put "$CONFIGSTORE/$BASE_CHARM_NAME$dst"
echo "$conf" | file_put "$CONFIGSTORE/$BASE_SERVICE_NAME$dst"
config-add "
$MASTER_BASE_CHARM_NAME:
$MASTER_BASE_SERVICE_NAME:
volumes:
- $CONFIGSTORE/$BASE_CHARM_NAME$dst:$dst:ro
- $CONFIGSTORE/$BASE_SERVICE_NAME$dst:$dst:ro
"
}
@ -422,9 +422,9 @@ __vhost_proxy_statement() {
TARGET=$(relation-get target 2>/dev/null) || true
if [ -z "$TARGET" ]; then
## First exposed port:
base_image=$(service_base_docker_image "$BASE_CHARM_NAME") || return 1
base_image=$(service_base_docker_image "$BASE_SERVICE_NAME") || return 1
first_exposed_port=$(image_exposed_ports_0 "$base_image" | tr '\0' '\n' | head -n 1 | cut -f 1 -d /) || return 1
TARGET=$MASTER_BASE_CHARM_NAME:$first_exposed_port
TARGET=$MASTER_BASE_SERVICE_NAME:$first_exposed_port
info "No target was specified, introspection found: $TARGET"
fi

42
apache/test/vhost_files

@ -102,8 +102,8 @@ is err ''
try "
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
export CONFIGSTORE='\$CONFIGSTORE'
export BASE_CHARM_NAME='\$BASE_CHARM_NAME'
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME'
export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
DOMAIN=www.example.com
DOCKER_SITE_PATH=/var/www/\$DOMAIN
CFG='
@ -115,22 +115,22 @@ ssl:
'
apache_vhost_create"
noerror
is out part 'file_put $CONFIGSTORE/$BASE_CHARM_NAME/etc/ssl/certs/www.example.com.pem
is out part 'file_put $CONFIGSTORE/$BASE_SERVICE_NAME/etc/ssl/certs/www.example.com.pem
| c'
is out part 'file_put $CONFIGSTORE/$BASE_CHARM_NAME/etc/ssl/private/www.example.com.key
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 ' - \$CONFIGSTORE/\$BASE_CHARM_NAME/etc/ssl/certs/www.example.com.pem:/etc/ssl/certs/www.example.com.pem:ro'
is out reg ' - \$CONFIGSTORE/\$BASE_CHARM_NAME/etc/ssl/private/www.example.com.key:/etc/ssl/private/www.example.com.key:ro'
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'
try "
export DOCKER_BASE_IMAGE=docker/apache
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
export CONFIGSTORE='\$CONFIGSTORE'
export BASE_CHARM_NAME='\$BASE_CHARM_NAME'
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME'
export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
DOMAIN=www.example.com
DOCKER_SITE_PATH=/var/www/\$DOMAIN
export CFG='
@ -151,8 +151,8 @@ try "
export DOCKER_BASE_IMAGE=docker/apache
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
export CONFIGSTORE='\$CONFIGSTORE'
export BASE_CHARM_NAME='\$BASE_CHARM_NAME'
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME'
export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
export CFG='
creds:
toto: xxx
@ -166,8 +166,8 @@ export DATASTORE='\$DATASTORE'
export DOCKER_BASE_IMAGE=docker/apache
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
export CONFIGSTORE='\$CONFIGSTORE'
export BASE_CHARM_NAME='\$BASE_CHARM_NAME'
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME'
export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
export CFG='
domain: www.example.com
creds:
@ -175,7 +175,7 @@ creds:
'
apache_publish_dir"
is errlvl 0
is err reg 'setfacl -R -m g:<GID>:rx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com'
is err reg 'setfacl -R -m g:<GID>:rx \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com'
is err reg 'cached_cmd_on_base_image apache id -g www-data'
@ -184,8 +184,8 @@ export DATASTORE='\$DATASTORE'
export DOCKER_BASE_IMAGE=docker/apache
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
export CONFIGSTORE='\$CONFIGSTORE'
export BASE_CHARM_NAME='\$BASE_CHARM_NAME'
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME'
export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
export CFG='
domain: www.example.com
creds:
@ -197,8 +197,8 @@ data-dirs:
'
apache_publish_dir"
is errlvl 0
is err reg 'setfacl -R -m g:<GID>:rwx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/c'
is err reg 'setfacl -R -d -m g:<GID>:rwx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/c'
is err reg 'setfacl -R -m g:<GID>:rwx \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/c'
is err reg 'setfacl -R -d -m g:<GID>:rwx \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/c'
try "
@ -206,9 +206,9 @@ export DATASTORE='\$DATASTORE'
export DOCKER_BASE_IMAGE=docker/apache
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
export CONFIGSTORE='\$CONFIGSTORE'
export BASE_CHARM_NAME='\$BASE_CHARM_NAME'
export MASTER_BASE_CHARM_NAME='\$MASTER_BASE_CHARM_NAME'
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_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'
export CFG='
domain: www.example.com
location: /opt/apps/newlocation
@ -223,7 +223,7 @@ apache_publish_dir"
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_CHARM_NAME:
is out part ' | $MASTER_BASE_SERVICE_NAME:
| volumes:
| - /opt/apps/newlocation:/var/www/www.example.com'

4
odoo-tecnativa/hooks/postgres_database-relation-joined

@ -18,12 +18,12 @@ control=$(echo -en "$USER\0$DBNAME\0$PASSWORD\0$ADMIN_PASSWORD" | md5_compat)
config-add "\
services:
$MASTER_BASE_CHARM_NAME:
$MASTER_BASE_SERVICE_NAME:
command:
- '--database=$DBNAME'
## All this is to please technativa image, but is quite redundant
environment:
PGHOST: $MASTER_TARGET_CHARM_NAME
PGHOST: $MASTER_TARGET_SERVICE_NAME
PGDATABASE: $DBNAME
PGPASSWORD: $PASSWORD
PGUSER: $USER

2
odoo-tecnativa/hooks/web_proxy-relation-joined

@ -4,7 +4,7 @@ set -e
config-add "\
services:
$MASTER_BASE_CHARM_NAME:
$MASTER_BASE_SERVICE_NAME:
environment:
PROXY_MODE: \"true\"
"

6
odoo-tecnativa/lib/common

@ -2,10 +2,10 @@
get_odoo_uid() {
uid_label="odoo"
odoo_uid=$(cached_cmd_on_base_image odoo "id -u \"$uid_label\"") || {
debug "Failed to query for '$uid_label' uid in ${DARKYELLOW}odoo${NORMAL} base image."
odoo_uid=$(cached_cmd_on_base_image "$SERVICE_NAME" "id -u \"$uid_label\"") || {
debug "Failed to query for '$uid_label' uid in ${DARKYELLOW}$SERVICE_NAME${NORMAL} base image."
return 1
}
info "openerp uid from ${DARKYELLOW}odoo${NORMAL} is '$odoo_uid'"
info "openerp uid from ${DARKYELLOW}$SERVICE_NAME${NORMAL} is '$odoo_uid'"
echo "$odoo_uid"
}

2
postgres-alpine/hooks/postgres_database-relation-joined

@ -12,7 +12,7 @@ PASSWORD="$(relation-get password 2>/dev/null)" || PASSWORD="$(gen_password)"
config-add "\
services:
$TARGET_CHARM_NAME:
$TARGET_SERVICE_NAME:
environment:
POSTGRES_USER: $USER
POSTGRES_PASSWORD: $PASSWORD

2
postgres/actions/relations/postgres-database/load-db

@ -52,4 +52,4 @@ if [ "$UNACCENT" ]; then
opts+=("--with-unaccent")
fi
run_service_action "$RELATION_TARGET_CHARM" load "$SOURCE" "$USER@$DBNAME" "${opts[@]}" "$@"
run_service_action "$RELATION_TARGET_SERVICE" load "$SOURCE" "$USER@$DBNAME" "${opts[@]}" "$@"

2
postgres/hooks/postgres_database-relation-joined

@ -35,7 +35,7 @@ fi
db_grant_rights "$DBNAME" "$USER"
pgpass_line="*:*:*:$USER:$PASSWORD"
pgpass_file="$CONFIGSTORE/$BASE_CHARM_NAME/root/.pgpass"
pgpass_file="$CONFIGSTORE/$BASE_SERVICE_NAME/root/.pgpass"
if [ -e "$pgpass_file" ]; then
sed -ri "/^.+:.+:.+:$USER:.*$/d" "$pgpass_file"

6
postgres/hooks/schedule_command-relation-joined

@ -12,7 +12,7 @@ set -e
## XXXvlab: should use container name here so that it could support
## multiple postgres
label=pg-backup-$SERVICE_NAME
DST=$CONFIGSTORE/$TARGET_CHARM_NAME/etc/cron/$label
DST=$CONFIGSTORE/$TARGET_SERVICE_NAME/etc/cron/$label
schedule=$(relation-get schedule)
if ! echo "$schedule" | egrep '^\s*(([0-9/,*-]+\s+){4,4}[0-9/,*-]+|@[a-z]+)\s*$' >/dev/null 2>&1; then
@ -43,7 +43,7 @@ EOF
chmod +x "$DST"
config-add "\
$MASTER_TARGET_CHARM_NAME:
$MASTER_TARGET_SERVICE_NAME:
links:
- $MASTER_BASE_CHARM_NAME
- $MASTER_BASE_SERVICE_NAME
"

8
sftp/hooks/sftp_access-relation-joined

@ -12,15 +12,15 @@ if test "$GROUP" && ! getent group "$GROUP" >/dev/null 2>&1; then
fi
config-add "\
$MASTER_TARGET_CHARM_NAME:
$MASTER_TARGET_SERVICE_NAME:
volumes:
$(while read-0 volume_def; do
IFS=: read src dst mode < <(echo "$volume_def:")
mode=${mode:-rw}
if [ "$mode" == "rw" -a "$GROUP" ]; then
debug setfacl -m "g:$GROUP:rwx" -R "$DATASTORE/$BASE_CHARM_NAME$src"
setfacl -m "g:$GROUP:rwx" -R "$DATASTORE/$BASE_CHARM_NAME$src"
debug setfacl -m "g:$GROUP:rwx" -R "$DATASTORE/$BASE_SERVICE_NAME$src"
setfacl -m "g:$GROUP:rwx" -R "$DATASTORE/$BASE_SERVICE_NAME$src"
fi
echo " - $DATASTORE/$BASE_CHARM_NAME$src:$dst:$mode"
echo " - $DATASTORE/$BASE_SERVICE_NAME$src:$dst:$mode"
done < <(echo "$VOLUMES" | shyaml get-values-0))"

2
traefik/hooks/web_proxy-relation-joined

@ -6,7 +6,7 @@ set -e
config-add "
services:
$MASTER_BASE_CHARM_NAME:
$MASTER_BASE_SERVICE_NAME:
labels:
- 'traefik.frontend.rule=Host:$(relation-get domain)'
"
Loading…
Cancel
Save