簡略化のため、これは =domain= という名前のメインサイトと、2つの追加サイト =two=.=domain= および =three=.=domain= のためのものです。好きな名前を使用できますが、このテンプレートの目的では、異なる short name (データベース名とサブフォーラムのタイトル用) と full hostname を持たない方が少し簡単です。
app.yml または web_only.yml のプラグインの後に hooks に追加
before_bundle_exec:
- file:
path: $home/config/multisite.yml
contents: |
=two=:
adapter: postgresql
database: =two=
pool: 25
timeout: 5000
host: data
password: NThmZTNjZjZhOTczNmVj
host_names:
- =two=.=domain=
=three=:
adapter: postgresql
database: =three=
pool: 25
timeout: 5000
host: data
password: NThmZTNjZjZhOTczNmVj
host_names:
- =three=.=domain=
after_db_migrate:
- exec: cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate
after_ssl:
# tell letsencrypt what additional certs to get
- replace:
filename: "/etc/runit/1.d/letsencrypt"
from: /-d =domain= /
to: "-d =domain= -d =two=.=domain= -d =three=.=domain="
global: true
# do not redirect all hosts back to the main domain name
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /if \(\$http_host[^\\}]*\)/m
to: ""
app.yml または data.yml の after_postgres セクションに追加
- exec: sudo -u postgres createdb =two= || exit 0
- exec:
stdin: |
grant all privileges on database =two= to discourse;
cmd: sudo -u postgres psql =two=
raise_on_fail: false
- exec: /bin/bash -c 'sudo -u postgres psql =two= <<< "alter schema public owner to discourse;"'
- exec: /bin/bash -c 'sudo -u postgres psql =two= <<< "create extension if not exists hstore;"'
- exec: /bin/bash -c 'sudo -u postgres psql =two= <<< "create extension if not exists pg_trgm;"'
- exec: sudo -u postgres createdb =three= || exit 0
- exec:
stdin: |
grant all privileges on database =three= to discourse;
cmd: sudo -u postgres psql =three=
raise_on_fail: false
- exec: /bin/bash -c 'sudo -u postgres psql =three= <<< "alter schema public owner to discourse;"'
- exec: /bin/bash -c 'sudo -u postgres psql =three= <<< "create extension if not exists hstore;"'
- exec: /bin/bash -c 'sudo -u postgres psql =three= <<< "create extension if not exists pg_trgm;"'
その後、
./launcher rebuild app
または
./launcher rebuild data
./launcher rebuild web_only
http://www.yamllint.com/ で YAML ファイルの構文を確認すると、after_postgres セクションを hooks セクションの下に配置した行で (\u003cunknown\u003e): did not find expected key while parsing a block mapping というエラーが表示されます。