[buildout]

extends =
  ${template-apache-php:output}

parts =
  request-mariadb
  request-mariadb-pseudo-replicating
  request-pull-backup-server
  request-pull-backup-server-mariadb
  request-pull-backup-server-mariadb-backup
  url
  apache-php
  stunnel
  certificate-authority
  ca-stunnel
  logrotate
  logrotate-entry-apache
  logrotate-entry-stunnel
  cron
  cron-entry-logrotate

[request-pull-backup-server]
<= slap-connection
recipe = slapos.cookbook:request
name = PBS (Pull Backup Server)
software-url = $${slap-connection:software-release-url}
software-type = pull-backup
return = ssh-key notification-url feeds-url
slave = false

[request-mariadb]
software-type = mariadb-pbsready-export
id = $${slap-parameter:mariadb-id}
config = authorized-key notify
config-authorized-key = $${request-pull-backup-server:connection-ssh-key}
config-notify = $${request-pull-backup-server:connection-notification-url}
return = url ssh-public-key ssh-url notification-id

[request-mariadb-pseudo-replicating]
<= slap-connection
recipe = slapos.cookbook:request
name = $${request-mariadb:name}
id = $${request-mariadb:id}
id-increment = 1
software-url = $${slap-connection:software-release-url}
software-type = mariadb-pbsready-import
return = url ssh-public-key ssh-url notification-url
config = authorized-key on-notification
config-authorized-key = $${request-pull-backup-server:connection-ssh-key}
pbs-notification-id = $${slap-connection:computer-id}-$${slap-connection:partition-id}-mariadb-push
config-on-notification = $${request-pull-backup-server:connection-feeds-url}$${:pbs-notification-id}

[request-pull-backup-server-mariadb]
<= request-pull-backup-server
   slap-connection
name = PBS pulling from MariaDB (backuped)
config = url name type server-key on-notification notify notification-id title
config-url = $${request-mariadb:connection-ssh-url}
config-name = $${slap-connection:computer-id}-$${slap-connection:partition-id}-mariadb
config-type = pull
config-server-key = $${request-mariadb:connection-ssh-public-key}
config-on-notification = $${request-mariadb:connection-notification-id}
config-notify = $${request-pull-backup-server:connection-notification-url}
config-notification-id = $${slap-connection:computer-id}-$${slap-connection:partition-id}-mariadb-pull
config-title = Pulling from MariaDB
slave = true

[request-pull-backup-server-mariadb-backup]
<= request-pull-backup-server
   slap-connection
name = PBS pushing on MariaDB (ready to use backup)
config = url name type server-key on-notification notify notification-id title
config-url = $${request-mariadb-pseudo-replicating:connection-ssh-url}
config-name = $${slap-connection:computer-id}-$${slap-connection:partition-id}-mariadb
config-type = push
config-server-key = $${request-mariadb-pseudo-replicating:connection-ssh-public-key}
config-on-notification = $${request-pull-backup-server:connection-feeds-url}$${request-pull-backup-server-mariadb:config-notification-id}
config-notify = $${request-mariadb-pseudo-replicating:connection-notification-url}
config-notification-id = $${request-mariadb-pseudo-replicating:pbs-notification-id}
config-title = Pushing to MariaDB backup
slave = true