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

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

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

``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``
オプション（デフォルトで含まれています）を常に含めることをお勧めします。

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

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

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