Running initdb
==============

TPAは、最初に\ ``postgres_data_dir``
が存在しない場合は作成し、正しい所有権、権限、およびSELinuxコンテキストがあることを確認します。次に、ディレクトリに\ ``VERSION``
ファイルがまだ含まれていない限り、 ``initdb``
を実行して\ ``postgres_data_dir`` を初期化します。

 :ref:`pre-initdb hook <TPA hooks>` を使用できます

``postgres_data_dir`` が作成され、\ ``initdb``
が実行される前にタスクを実行します。フックが\ ``postgres_data_dir``
を初期化する場合、TPAは\ ``VERSION``
ファイルを見つけられるため、\ ``initdb`` を実行しません。

オプションで\ ``postgres_initdb_opts`` を\ ``initdb``
に渡すオプションのリストに設定できます。

.. code:: yaml

   cluster_vars:
     postgres_locale: de_DE.UTF-8
     postgres_initdb_opts:
     - --data-checksums

デフォルトで含まれる\ ``--data-checksums``
オプションを常に含めることをお勧めします。

``initdb`` を実行すると、TPAは環境に\ ``TZ=UTC`` を設定し、\ ``LC_ALL``
を指定した\ ``postgres_locale`` に設定します。

別の構成ディレクトリ
--------------------

デフォルトでは、 ``postgres_conf_dir`` は\ ``postgres_data_dir``
と等しく、 Postgres構成ファイル\ ``postgresql.conf``
、\ ``pg_ident.conf`` 、\ ``pg_hba.conf`` 、および\ ``conf.d``
のインクルードファイルはデータディレクトリに作成されます。 ``initdb``
を実行した後、\ ``postgres_conf_dir``
を変更すると、TPAは生成された構成ファイルを新しい場所に移動します。
