# 設定の自動化方法

**URL:** https://meta.discourse.org/t/how-to-automate-configuration/177291
**Category:** Support
**Created:** [2021 年 1 月 26 日午前 10:06 UTC](https://meta.discourse.org/t/how-to-automate-configuration/177291 "2021-01-26T10:06:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tdudgeon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tdudgeon/32/204357_2.png) [@tdudgeon](https://meta.discourse.org/u/tdudgeon)
#### Post date: [2021 年 1 月 26 日午前 10:06 UTC](https://meta.discourse.org/t/how-to-automate-configuration/177291/1 "2021-01-26T10:06:45Z")

</div>

Discourse のインストール後、多くの設定（Discourse コア機能とプラグインの両方）が、設定 UI 経由で手動で行う必要があります。これには多くの入力やボタン操作が必要であり、さらに各設定の場所を覚えておく必要があります。  
これらの設定をデプロイメントの一部として定義することは可能でしょうか？例えば、初期デプロイ完了後に実行可能なパラメータ化スクリプトのように。

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [2021 年 1 月 26 日午前 10:10 UTC](https://meta.discourse.org/t/how-to-automate-configuration/177291/2 "2021-01-26T10:10:24Z")

</div>

> [@tdudgeon](#):
>
> これらの設定をデプロイの一部として定義することは可能でしょうか？例えば、初期デプロイ完了後に実行可能なパラメータ化スクリプトのようなものです。

プラグインを作成して、あらゆるサイト設定を非常に簡単に設定することができます。

参考になれば幸いです。

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2021 年 1 月 26 日午前 10:12 UTC](https://meta.discourse.org/t/how-to-automate-configuration/177291/3 "2021-01-26T10:12:45Z")

</div>

これは可能です。なぜそれが必要なのか、というご質問ですが、多くのサイトをプロビジョニングされているのでしょうか？

同一のサイトを別のサーバーで再現するには、サイトのバックアップと app.yml のコピーだけで十分です。

さらに、設定は再構築時にも保持されるため、同じサーバー上でのローカルアップグレードを気にする必要はありません。

サイトテンプレートを作成する必要がある場合は、単一のバックアップとテンプレート用の app.yml で実現できると考えられます。必要に応じて、app.yml 内でサイト設定を変更することも可能です。

---

<div class="post-metadata">

### Author: ![tdudgeon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tdudgeon/32/204357_2.png) [@tdudgeon](https://meta.discourse.org/u/tdudgeon)
#### Post date: [2021 年 1 月 26 日午前 10:45 UTC](https://meta.discourse.org/t/how-to-automate-configuration/177291/4 "2021-01-26T10:45:54Z")

</div>

複数のサイトを構築しており、それぞれが異なる設定（ブランディング、セキュリティ設定など）を必要としています。  
設定項目自体は毎回同じですが、設定値が異なります。

当社の環境は、Ansible を用いて K8S にデプロイされた Bitnami コンテナを基盤としています。

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [2021 年 1 月 26 日午前 11:01 UTC](https://meta.discourse.org/t/how-to-automate-configuration/177291/5 "2021-01-26T11:01:51Z")

</div>

> [@tdudgeon](#):
>
> 毎回設定が必要な項目は同じですが、設定する値が異なるだけです

その場合、提案されたように YAML テンプレートを作成し、カスタムサイト設定を含めたテンプレートをコンテナファイルに含めることもできます。

あるいは、プラグインで同様のことを行い、共有ディレクトリ内のファイルやリモート場所からサイト固有の設定を読み取る方法もあります。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2021 年 1 月 26 日午後 5:18 UTC](https://meta.discourse.org/t/how-to-automate-configuration/177291/6 "2021-01-26T17:18:07Z")

</div>

すべてのサイト設定は環境変数（例：`DISCOURSE_SETTING_NAME=xxx`）で設定できます。また、[API を通じてすべてを変更](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576)することも可能です。NoBugsBunny が指摘しているように、場合によってはプラグインを使うのが良い方法です。

これは、私がここで提供している無料サポートの範囲を超えています。Bitnami はお勧めしませんが、それを利用しているクライアントと協力した経験はあります。`./launcher` で構築されたサポート対象のコンテナを使用した GKE デプロイを数回行ったことがあり、Ansible を用いた Discourse のデプロイと管理についても経験があります。サポートが必要で予算がある場合は、jay@literatecomputing.com までお問い合わせください。
