enix.postgresql
enix.postgresql
Unixホスト上でPostgreSQLのアップストリームリリースを展開し、設定するための役割で、Ansibleを使用します。
要件
サポート対象:
- Debian 9 "Stretch"
- Debian 10 "Buster"
- Debian 11 "Bullseye"
- Ubuntu 20.04 "Focal"
- Ubuntu 22.04 "Jammy"
役割変数
この役割には、ほぼすべてのデフォルトが予め設定されています。ホストやグループの変数、インベントリ、プレイの中でそれぞれを上書きできます。設定に関するヘルプはdefaults/main.yml
の注釈付きデフォルトを参照してください。
postgresql__version
- インストールするPostgreSQLのバージョン。デフォルトは14。利用可能: 10, 11, 12, 13, 14。postgresql__extensions
- インストールするPostgreSQL拡張パッケージ。postgresql__global_config_options
- postgresql.confに設定する全体の設定オプション。一般的なオプションは以下の通り:
postgresql__global_config_options:
- option: listen_addresses
value: '*'
- option: log_min_duration_statement
value: 1000
- option: bonjour
value: off
state: absent
postgresql__includeconf
- conf.d/にテンプレートとしてプッシュする設定ファイルのリスト。postgresql__hba_entries
- 設定するホストベースの認証エントリ。PostgreSQLのデフォルトを上書きします。デフォルトは定義されていません。必須フィールドはtype, database, user, auth_method
、オプションはaddress, ip_address, ip_mask, auth_options
です。提供されたパッケージ設定を複製するには:
postgresql_hba_entries:
- {type: local, database: all, user: postgres, auth_method: peer}
- {type: local, database: all, user: all, auth_method: peer}
- {type: host, database: all, user: all, address: '127.0.0.1/32', auth_method: md5}
- {type: host, database: all, user: all, address: '::1/128', auth_method: md5}
# バージョン10からレプリケーション役割があります
- {type: local, database: replication, user: all, auth_method: peer}
- {type: host, database: replication, user: all, address: '127.0.0.1/32', auth_method: md5}
- {type: host, database: replication, user: all, address: '::1/128', auth_method: md5}
postgresql__users
- PostgreSQLサーバー上に作成されるユーザーと関連する資格情報:
postgresql__users:
- {name: "foobar",
password: "supersecure",
encrypted: yes,
expires: 'infinity',
state: 'present',
conn_limit: none,
priv: none,
role_attr_flags: none,
db: none
postgresql__databases
- サーバーにインストールされるデータベースの状態。唯一の必須パラメータは名前です:
postgresql__databases:
- {name: test,
lc_collate: 'en_US.UTF-8',
lc_ctype: 'en_US.UTF-8',
encoding: 'UTF-8',
template: 'template0',
owner: postgres,
extension: [], # 必要な拡張モジュールをインストールしていることを確認してください
state: 'present'
}
postgresql__install_pgbackrest
- pgbackrestソフトウェアをインストールします https://pgbackrest.org。postgresql__install_pg_auto_failover
- pg_auto_failoverソフトウェアをインストールします https://github.com/citusdata/pg_auto_failover。postgresql__disable_initdb
- デフォルトのメインクラスタを作成しないようにします。pg_auto_failoverクラスタの作成やパッケージのインストール時に便利です。
依存関係
- なし
使用方法
Ansible Galaxyのrequirements.ymlを使用します。
- src: enix.postgresql
そして、プレイのロールに追加します:
- hosts: all
roles:
- role enix.postgresql:
postgresql__var: true
ロールをプレイブックとしても使用できます。どのホストをプロビジョニングするかを尋ねられ、--extra-vars
を使ってプレイをさらに設定できます。
ansible-playbook -i inventory --extra-vars='{...}' main.yml
今後の作業
- レプリカ上にデプロイしているか確認します。この場合、createdbやcreateuserを行わないようにします。
- モレキュールを使用したCIテストを追加します。
変更履歴
2.1.0
pgbackrestおよびpg_auto_failoverソフトウェアのインストールを追加しました。 disable_initdbオプションを追加しました。これにより、デフォルトのメインPostgreSQLクラスタのセットアップを防ぎます。
2.0.0
PostgreSQL 13および14のサポートを追加しました。 Debian 10 BusterおよびDebian 11 Bullseyeのサポートを追加しました。 Ubuntu 20.04 FocalおよびUbuntu 22.04 Jammyのサポートを追加しました。 Debian Jessieサポートを削除しました。 モレキュールテストに切り替えました。 新しいAnsible FQDNタスクを使用します。
1.2.0
PostgreSQL 12のサポートを追加しました。
1.1.0
データベースの定義と設定に拡張リストのサポートを追加しました。
1.0.0
初版です。
ライセンス
GPLv2
著者情報
Laurent CORBES laurent.corbes@enix.fr - http://www.enix.io