mahdi22.postgresql

Ansibleロール postgresql

Ansibleロールは、RHEL/CentOS、Debian、Ubuntu、SUSE SLESディストリビューションのLinuxにPostgreSQLをインストールするためのものです。このロールの主な責任は以下の通りです。

  • PostgreSQLのインストール
  • PostgreSQLのパラメータと認証の設定
  • ユーザーの作成
  • データベースの作成

インストール

$ ansible-galaxy install mahdi22.postgresql

ロールの変数

variable/main.yml PostgreSQLの設定パラメータを設定するか、デフォルト値を使用します。

postgresql_config:
  - option: port
    value: 5432
  - option: log_destination
    value: syslog
  - option: log_directory
    value: /var/log/postgresql/

PostgreSQLの認証パラメータを設定または変更するか、デフォルト値を使用します。

postgresql_authentication:
  - {type: local, database: all, user: postgres, auth_method: peer}
  - {type: local, database: all, user: all, auth_method: md5}
  - {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}
  - {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のデータベースとユーザーを作成するために設定し、デフォルトのmain.ymlで create_users: no および create_databases: no が設定されていない場合は作成します。

複数のデータベースとユーザーを作成する例:

postgresql_databases_users: []
#postgresql_databases_users:
#  - {database: test, user: user1, userpassword: user1pass, priv: ALL}  #データベース 'test' とユーザー 'user1' をパスワード 'user1pass' で作成し、権限 'ALL' を付与
#  - {database: test1, user:'', userpassword: '', priv: ''}                  #データベース 'test1' のみを作成
#  - {database: '', user: user2, userpassword: user2pass, priv: ''}          #ユーザー 'user2' をパスワード 'user2pass' で作成
  • ユーザーなしでデータベースのみを作成するには、database: databasename, user:'' を設定します。
  • ユーザーのみを作成するには、database: '', user: username, userpassword: password を設定します。
  • ユーザー権限つきでデータベースを作成するには、database: databasename, user: username, userpassword: password, priv: privileges を設定します。

基本設定

変数 デフォルト コメント
use_proxy 'False' 管理対象ホストがウェブプロキシの背後にある場合は use_proxy を True に設定
http_proxy 'http://proxy.lab.local:8080/' プロキシサーバーとポートを設定し、proxy.lab.local:8080 を置き換えます
https_proxy 'http://proxy.lab.local:8080/' プロキシサーバーとポートを設定し、proxy.lab.local:8080 を置き換えます
postgresql_version インストールされるPostgreSQLのバージョン
listen_addresses_host_ip yes yesを設定してPostgreSQLのリスニングをネットワークIPインターフェースで有効化
create_users yes 変数ファイルに設定されたPostgreSQLユーザーを作成します
create_databases yes 変数ファイルに設定されたPostgreSQLデータベースを作成します

備考

(1) 管理対象ホストがウェブプロキシの背後にある場合は、defaults/main.ymlファイルに次の変数を設定します:

use_proxy: False
proxy_env:
  http_proxy: http://proxy.local:8080/
  https_proxy: http://proxy.local:8080/

使用例のプレイブック

- hosts: dbservers
  roles:
    - role: mahdi22.postgresql
      become: yes

テスト

このロールは以下のLinuxディストリビューションでテストされています:

  • RHEL/CentOS 8 PostgreSQL バージョン (9.5, 9.4, 10, 11, 12, 13)
  • RHEL/CentOS 7 PostgreSQL バージョン (9.5, 9.4, 10, 11, 12, 13)
  • Debian 10 PostgreSQL バージョン (9.5, 9.4, 10, 11, 12, 13)
  • Debian 9 PostgreSQL バージョン (9.5, 9.4, 10, 11, 12, 13)
  • Ubuntu 20.04 PostgreSQL バージョン (9.5, 9.4, 10, 11, 12, 13)
  • Ubuntu 18.04 PostgreSQL バージョン (9.5, 9.4, 10, 11, 12, 13)
  • Ubuntu 16.04 PostgreSQL バージョン (9.5, 9.4, 10, 11, 12, 13)
  • Suse SLES 12 PostgreSQL バージョン (9.5, 9.4, 10, 11, 12)
  • Suse SLES 15 PostgreSQL バージョン (11, 12, 13)
プロジェクトについて

Install and configure Postgresql server on Rhel/CentOS, Debian, Ubuntu and SUSE SLES ditributions

インストール
ansible-galaxy install mahdi22.postgresql
ライセンス
Unknown
ダウンロード
95
所有者