geerlingguy.postgresql

Ansibleロール: PostgreSQL

CI

RHEL/CentOSやDebian/UbuntuサーバーにPostgreSQLサーバーをインストールし、設定します。

要件

特別な要件はありません。このロールはrootアクセスが必要ですので、プレイブックでグローバルなbecome: yesを使用して実行するか、プレイブックで次のようにロールを呼び出してください:

- hosts: database
  roles:
    - role: geerlingguy.postgresql
      become: yes

ロール変数

利用可能な変数は以下にリストされており、デフォルト値も示されています(defaults/main.ymlを参照):

postgresql_enablerepo: ""

(RHEL/CentOSのみ)PostgreSQLのインストールに使用するリポジトリをここに設定できます。

postgresql_restarted_state: "restarted"

設定変更時のサービスの状態を設定します。推奨値はrestartedまたはreloadedです。

postgresql_python_library: python-psycopg2

AnsibleがPostgreSQLと通信するために使用するライブラリです。Python 3を使用している場合(例:ansible_python_interpreterで設定)、これをpython3-psycopg2に変更する必要があります。

postgresql_user: postgres
postgresql_group: postgres

PostgreSQLが実行されるユーザーおよびグループ。

postgresql_unix_socket_directories:
  - /var/run/postgresql

PostgreSQLのソケットが作成されるディレクトリ(通常は1つですが、複数にすることもできます)。

postgresql_service_state: started
postgresql_service_enabled: true

PostgreSQLのサービスの状態を制御し、起動時に自動的に開始するかどうかを設定します。

postgresql_global_config_options:
  - option: unix_socket_directories
    value: '{{ postgresql_unix_socket_directories | join(",") }}'
  - option: log_directory
    value: 'log'

postgresql.confに設定されるグローバル設定オプション。PostgreSQLのバージョンが9.3未満の場合、この変数をオーバーライドしてoptionunix_socket_directoryに設定する必要があります。option: log_directoryの値を別のパスにオーバーライドする場合、相対または絶対パスで指定してください。このロールは自動的にそのパスを作成します。

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 }

pg_hba.confに設定されるホストベースの認証エントリを構成します。エントリのオプションには次が含まれます:

  • type(必須)
  • database(必須)
  • user(必須)
  • address(これまたは以下の2つのいずれかが必須)
  • ip_address
  • ip_mask
  • auth_method(必須)
  • auth_options(オプション)

オーバーライドを行う場合、既存のエントリが必要な場合は、defaults/main.ymlからすべての既存エントリをコピーしてください。

postgresql_locales:
  - 'en_US.UTF-8'

(Debian/Ubuntuのみ)PostgreSQLデータベースで使用するロケールを生成するために使用します。

postgresql_databases:
  - name: exampledb # 必須; 残りはオプション
    lc_collate: # デフォルトは'en_US.UTF-8'
    lc_ctype: # デフォルトは'en_US.UTF-8'
    encoding: # デフォルトは'UTF-8'
    template: # デフォルトは'template0'
    login_host: # デフォルトは'localhost'
    login_password: # デフォルトは設定なし
    login_user: # デフォルトは'postgresql_user'
    login_unix_socket: # デフォルトはpostgresql_unix_socket_directoriesの1番目
    port: # デフォルトは設定なし
    owner: # デフォルトはpostgresql_user
    state: # デフォルトは'present'

サーバー上に存在することを確認するデータベースのリストです。nameのみが必須で、他のプロパティはオプションです。

postgresql_users:
  - name: jdoe #必須; 残りはオプション
    password: # デフォルトは設定なし
    encrypted: # デフォルトは設定なし
    priv: # デフォルトは設定なし
    role_attr_flags: # デフォルトは設定なし
    db: # デフォルトは設定なし
    login_host: # デフォルトは'localhost'
    login_password: # デフォルトは設定なし
    login_user: # デフォルトは'{{ postgresql_user }}'
    login_unix_socket: # デフォルトはpostgresql_unix_socket_directoriesの1番目
    port: # デフォルトは設定なし
    state: # デフォルトは'present'

サーバー上に存在することを確認するユーザーのリストです。nameのみが必須で、他のプロパティはオプションです。

postgres_users_no_log: true

ユーザー管理時にユーザーデータ(パスワードのような機密情報を含む場合があります)を出力するかどうか。

postgresql_version: [OS-specific]
postgresql_data_dir: [OS-specific]
postgresql_bin_path: [OS-specific]
postgresql_config_path: [OS-specific]
postgresql_daemon: [OS-specific]
postgresql_packages: [OS-specific]

このロールのvarsディレクトリにあるインクルードファイルで設定されるOS特有の変数です。システムパッケージを使用してインストールされていないPostgreSQLのバージョンを使用している場合を除き、これらはオーバーライドしないでください。

依存関係

なし。

使用例プレイブック

- hosts: database
  become: yes
  vars_files:
    - vars/main.yml
  roles:
    - geerlingguy.postgresql

vars/main.yml

postgresql_databases:
  - name: example_db
postgresql_users:
  - name: example_user
    password: supersecure

ライセンス

MIT / BSD

作者情報

このロールは2016年にJeff Geerlingによって作成されました。彼はAnsible for DevOpsの著者です。

プロジェクトについて

PostgreSQL server for Linux.

インストール
ansible-galaxy install geerlingguy.postgresql
ライセンス
mit
ダウンロード
3.3M
所有者
Father, author, developer, maker. Sometimes called "an inflammatory enigma". #stl #drupal #ansible #k8s #raspberrypi #crohns