trombik.opensearch
trombik.opensearch
opensearch
を管理するためのansible
ロールです。
このロールはベータ版です。
FreeBSDユーザー向け
この例は、FreeBSD用の独自のopensearch-dashboards
ポートを必要とします。このポートはtrombik/freebsd-ports-opensearchで見つけることができます。例ではtrombik.opensearch_dashboards
を使用しています。ただし、ポートとロールはEoLedで非推奨のwww/node10
に依存しています。
アップグレード計画についてはIssue 835を参照してください。
Debian系およびCentOSユーザー向け
このロールは公式のtarアーカイブからopensearch
をインストールします。これは、Amazonやディストリビューションがパッケージをリリースするまでの巨大なハックです。
ソースインストールに関するロール変数opensearch_src_*
は意図的に文書化されていません。
このロールはJDKパッケージをインストールしません。代わりにバンドルされたJDKが使用されます。
このロールは、tarファイルを検証するために上流プロジェクトからroot
のキーチェーンにPGPキーをインポートします。PGPキーをインポートせずに署名ファイルを検証する方法を知っていれば教えてください。
いくつかのプラグインはまだ動作しません。
デフォルトからの変更点は以下の通りです:
- ログファイルは
/var/log/opensearch
にあります。 - アプリケーションは
opensearch_root_dir
にインストールされます。デフォルトは/usr/local/opensearch-dashboards
です。 - アプリケーションを実行するユーザーは
opensearch
です。
変更は公式のパッケージが利用可能になり次第更新されます。
このロールはopensearch_src_dir
の下に公式のtarアーカイブをダウンロードします。デフォルトは/var/dist
です。このディレクトリは単なるキャッシュディレクトリではなく、tarファイルに加え、PGPキー、署名ファイル、およびansible
タスクを制御するためのファイルがあります。
このロールはopensearch
用のsystemd
単位ファイルをインストールします。著者はsystemd
の専門家ではありません。
要件
デフォルトでは、このロールはtrombik.x509_certificate
を使ってX509証明書を管理します。このロールはTLS
が必須でないため、trombik.x509_certificate
を依存関係としてリストしていません。
ロール変数
変数 | 説明 | デフォルト |
---|---|---|
opensearch_user |
opensearch のユーザー名 |
{{ __opensearch_user }} |
opensearch_group |
opensearch のグループ名 |
{{ __opensearch_group }} |
opensearch_log_dir |
ログディレクトリのパス | {{ __opensearch_log_dir }} |
opensearch_db_dir |
データディレクトリのパス | {{ __opensearch_db_dir }} |
opensearch_scripts_dir |
スクリプトディレクトリのパス | {{ __opensearch_scripts_dir }} |
opensearch_plugins_dir |
プラグインディレクトリのパス | {{ __opensearch_plugins_dir }} |
opensearch_plugin_command |
opensearch-plugin コマンドのパス |
{{ __opensearch_plugin_command }} |
opensearch_plugins |
プラグインのリスト(以下を参照) | [] |
opensearch_service |
opensearch のサービス名 |
{{ __opensearch_service }} |
opensearch_package |
opensearch のパッケージ名 |
{{ __opensearch_package }} |
opensearch_conf_dir |
設定ディレクトリのパス | {{ __opensearch_conf_dir }} |
opensearch_jvm_options |
JVMオプション(例のプレイブックを参照) | "" |
opensearch_conf_file |
opensearch.yml のパス |
{{ opensearch_conf_dir }}/opensearch.yml |
opensearch_flags |
スタートアップスクリプトのための追加フラグ | "" |
opensearch_config |
opensearch.yml の内容 |
"" |
opensearch_config_log4j2_properties |
log4j2.properties の内容 |
"" |
opensearch_http_host |
opensearch のアドレスまたはhostname です。このアドレスはansible コントローラーからアクセスできなければなりません(ansible が動作しているホスト)。この値はAPIアクセスに使用されるため、TLSが使用され、リモートホストの検証が有効な場合、値は証明書のcommon name と一致する必要があります。そうでない場合、このロールのAPI呼び出しは失敗します。 |
localhost |
opensearch_http_port |
opensearch のリスンポート。このポートはansible コントローラーからアクセスできなければなりません |
9200 |
opensearch_http_url |
HTTPインターフェイスのURL。このURLはansible コントローラーからアクセスできなければなりません |
https://{{ opensearch_http_host }}:{{ opensearch_http_port }} |
opensearch_http_auth |
APIアクセスのための認証詳細 | {} |
opensearch_java_home |
JAVA_HOME 環境変数 |
{{ __opensearch_java_home }} |
opensearch_extra_plugin_files |
プラグイン用の追加ファイルのリスト | [] |
opensearch_include_role_x509_certificate |
trueの場合、プレイ中にtrombik.x509_certificate を含めます(trombik.x509_certificate はrequirements.yml にリストする必要があります) |
yes |
opensearch_x509_certificate_vars |
trombik.x509_certificate に渡す変数 |
{} |
opensearch_wait_for_cluster_status |
サービスを開始した後、クラスタのステータスがこの値になるのを待ちます。有効な値にはred 、yellow 、green 、およびfalse が含まれます。false の値を設定すると無効になります。 |
no |
opensearch_wait_for_cluster_status_timeout |
opensearch_wait_for_cluster_status が待っているときのタイムアウト |
10s |
opensearch_wait_for_cluster_status_retry |
opensearch_wait_for_cluster_status を待つときのリトライ回数 |
3 |
opensearch_plugins
これはプラグインのリストです。リストの要素は辞書です。
キー | 説明 | 必須ですか? |
---|---|---|
name |
プラグインの名前 | はい |
src |
プラグインのソース。通常はURLです | いいえ |
opensearch_extra_plugin_files
この変数はプラグイン用のファイルのリストです。リストの要素は辞書です。
キー | 説明 | 必須ですか? |
---|---|---|
path |
opensearch_plugins_dir からの相対パス |
はい |
type |
yaml またはraw 。型がyaml の場合、content の値はYAMLとしてレンダリングされます。型がraw の場合、値はそのままレンダリングされます。state が省略されるか、present の場合、type は指定する必要があります。 |
いいえ |
mode |
ファイルのモード | いいえ |
owner |
ファイルのオーナー | いいえ |
group |
ファイルのグループ | いいえ |
state |
present またはabsent 。present はファイルを作成します。absent はファイルを削除します。デフォルトはpresent です。 |
いいえ |
content |
ファイルの内容(上記のtype も参照) |
いいえ |
post_command |
ansible.builtin.command 用の辞書 |
いいえ |
post_command
は、アイテムのステータスが変更された後にコマンドを実行するための辞書です。この変数はansible.builtin.command
(ansible.builtin.shell
ではない)に渡されます。
以下のキーを受け付けます:
キー | 説明 | 必須ですか? |
---|---|---|
cmd |
実行するコマンド | はい |
args |
args 用の辞書。現在はchdir 、creates 、およびremoves がサポートされています。 |
いいえ |
enabled |
yes かno のいずれか。yes の場合、コマンドが実行され、no の場合は実行されません |
はい |
post_command
は主にsecurityadmin.sh
用に設計されています。
詳細についてはApply changes using securityadmin.shを参照してください。enabled
を使用して特定のノードでsecurityadmin.sh
を実行します。
opensearch_http_auth
この変数は辞書であり、opensearch_http_url
のAPIエンドポイントにアクセスする際のユーザー資格情報として使用されます。
キー | 説明 | 必須ですか? |
---|---|---|
client_cert |
PEM 形式のクライアント公開鍵のパス。相対パスの場合、パスはansible コントローラーの現在の作業ディレクトリに対して相対的であり、ターゲットマシンではありません。 |
いいえ |
client_key |
PEM 形式のクライアント秘密鍵のパス。相対パスの場合、パスはansible コントローラーの現在の作業ディレクトリに対して相対的であり、ターゲットマシンではありません。 |
いいえ |
ca_path |
PEM 形式のCAの公開鍵のパス。相対パスの場合、パスはansible コントローラーの現在の作業ディレクトリに対して相対的であり、ターゲットマシンではありません。 |
いいえ |
url_username |
ベーシック認証のためのユーザー名 | いいえ |
url_password |
ベーシック認証のためのパスワード | いいえ |
validate_certs |
リモート証明書を検証するかどうか | いいえ |
このロールは、変数をuri
モジュールに渡します。
ca_path
はansible
のバージョン2.11で追加されました。client_cert
とclient_key
はansible
のバージョン2.4で追加されました。お使いのansible
のバージョンがこれらのキーをサポートしていることを確認してください。このため、ansible
のバージョンが2.11よりも古く、証明書がデフォルトのCAバンドルにより署名されていない場合(ほとんどの場合、コストのために自分のCAを持っている必要があります)、validate_certs: yes
を使用することはできません。
API呼び出しはansible
コントローラーから行われます。opensearch_http_url
はansible
コントローラーからアクセスできなければなりません。
client_cert
、client_key
、およびca_path
が指すファイルはansible
コントローラー上に存在する必要があります。
opensearch_http_auth
とTLSの既知の問題
opensearch
はベーシック認証とTLSクライアント証明書認証をTLS経由でサポートしています。ただし、一部の構成ではAPI呼び出しが失敗します。
簡単に言えば、ca_path
を使用してTLS経由でベーシック認証を行ってください。これが、期待通りに安全に動作する唯一の構成です。
ユーザー名とパスワードなしでTLSクライアント認証を使用する場合は、validate_certs
をno
に設定する必要があります。以下はテストマトリックスと結果です。
認証方法 | validate_certs の値 |
ca_path あり? |
結果 |
---|---|---|---|
TLSクライアント証明書 | no |
はい | 成功 |
TLSクライアント証明書 | no |
いいえ | 成功 |
TLSクライアント証明書 | yes |
はい | 失敗 |
TLSクライアント証明書 | yes |
いいえ | 失敗(これは期待される結果です。なぜなら、クライアントはCA証明書無しでは検証できないから) |
ベーシック | no |
はい | 成功 |
ベーシック | no |
いいえ | 成功 |
ベーシック | yes |
はい | 成功 |
ベーシック | yes |
いいえ | 失敗(これは期待される結果です。なぜなら、クライアントはCA証明書無しでは検証できないから) |
これは、ansible
のuri
モジュールにバグがある可能性があります。なぜなら、curl
はTLSクライアント証明書とTLS経由のベーシック認証の両方で正常に動作します。記録のために以下のコマンドが使用されました。
curl -vv --cacert /usr/local/etc/opensearch/root-ca.pem \
--cert /usr/local/etc/opensearch/admin.pem \
--key /usr/local/etc/opensearch/admin-key.pem \
https://localhost:9200
curl -vv --user admin:admin \
--cacert /usr/local/etc/opensearch/root-ca.pem \
https://localhost:9200
Debian
変数 | デフォルト |
---|---|
__opensearch_user |
opensearch |
__opensearch_group |
opensearch |
__opensearch_log_dir |
/var/log/opensearch |
__opensearch_db_dir |
/var/lib/opensearch |
__opensearch_package |
opensearch |
__opensearch_conf_dir |
/usr/local/opensearch/config |
__opensearch_root_dir |
/usr/local/opensearch |
__opensearch_scripts_dir |
"" |
__opensearch_plugins_dir |
/usr/local/opensearch/plugins |
__opensearch_plugin_command |
/usr/local/opensearch/bin/opensearch-plugin |
__opensearch_service |
opensearch |
__opensearch_java_home |
/usr/local/opensearch/jdk |
FreeBSD
変数 | デフォルト |
---|---|
__opensearch_user |
opensearch |
__opensearch_group |
opensearch |
__opensearch_log_dir |
/var/log/opensearch |
__opensearch_db_dir |
/var/db/opensearch |
__opensearch_package |
textproc/opensearch |
__opensearch_conf_dir |
/usr/local/etc/opensearch |
__opensearch_scripts_dir |
"" |
__opensearch_plugins_dir |
/usr/local/lib/opensearch/plugins |
__opensearch_plugin_command |
/usr/local/lib/opensearch/bin/opensearch-plugin |
__opensearch_service |
opensearch |
__opensearch_java_home |
/usr/local |
RedHat
変数 | デフォルト |
---|---|
__opensearch_user |
opensearch |
__opensearch_group |
opensearch |
__opensearch_log_dir |
/var/log/opensearch |
__opensearch_db_dir |
/var/lib/opensearch |
__opensearch_package |
opensearch |
__opensearch_conf_dir |
/usr/local/opensearch/config |
__opensearch_root_dir |
/usr/local/opensearch |
__opensearch_scripts_dir |
"" |
__opensearch_plugins_dir |
/usr/local/opensearch/plugins |
__opensearch_plugin_command |
/usr/local/opensearch/bin/opensearch-plugin |
__opensearch_service |
opensearch |
__opensearch_java_home |
/usr/local/opensearch/jdk |
依存関係
opensearch_include_role_x509_certificate
がtrueの場合、trombik.x509_certificate
例プレイブック
opensearch
、opensearch-dashboards
、haproxy
、fluentd
をインストールする例です。
haproxy
はopensearch-dashboards
用のリバースプロキシです。haproxy
とsyslog
デーモンからのログは、ローカルなfluentd
のsyslog
リスナーに送信されます。その後、fluentd
がログを処理し、それをopensearch
に送信します。インデックスパターンはlogstash-*
です。
fluentd
のelasticsearch
出力プラグインはopensearch
をサポートしていないことに注意してください。例は以下の方法で問題を回避します:
fluentd-elasticsearch-plugin
とelasticsearch
関連のgemの特定のバージョンをインストールするfluentd.conf
でverify_es_version_at_startup
とdefault_elasticsearch_version
を設定する
詳細についてはIssue 915を参照してください。
ダッシュボードにログインするには、ユーザー名admin
とパスワードadmin
を使用してください。
クラスターの例についてはtests/serverspec/cluster.ymlをご覧ください。
---
- hosts: localhost
pre_tasks:
- name: HTTPポートを許可
ansible.builtin.iptables:
chain: INPUT
destination_port: 80
protocol: tcp
jump: ACCEPT
when: ansible_os_family == 'RedHat'
- name: rsyslogからfluentdへのsyslog転送を有効にする
ansible.builtin.copy:
dest: /etc/rsyslog.d/fluentd.conf
content: |
*.*;syslog;auth,authpriv.none action(
Target="127.0.0.1"
type="omfwd"
Port="1514"
Protocol="udp"
template="RSYSLOG_SyslogProtocol23Format"
)
mode: "0644"
when:
- ansible_os_family == 'Debian' or ansible_os_family == 'RedHat'
register: __register_project_rsyslog_config
- name: rsyslogを再起動
ansible.builtin.service:
name: rsyslog
state: restarted
when:
- ansible_os_family == 'Debian' or ansible_os_family == 'RedHat'
- __register_project_rsyslog_config['changed']
- name: syslogdからfluentdへのsyslog転送を有効にする
ansible.builtin.copy:
dest: /etc/syslog.d/fluentd.conf
content: |
*.* @127.0.0.1:1514
mode: "0644"
when: ansible_os_family == 'FreeBSD'
register: __register_project_syslog_config
- name: syslog rfc5424を有効にする
ansible.builtin.copy:
dest: /etc/rc.conf.d/syslogd
content: |
syslogd_flags="-s -O rfc5424"
mode: "0644"
when: ansible_os_family == 'FreeBSD'
register: __register_project_syslog_flags
- name: syslogdを再起動
ansible.builtin.service:
name: syslogd
state: restarted
when:
- ansible_os_family == 'FreeBSD'
- __register_project_syslog_config['changed'] or __register_project_syslog_flags['changed']
roles:
- role: trombik.freebsd_pkg_repo
when: ansible_os_family == "FreeBSD"
- name: trombik.apt_repo
when: ansible_os_family == 'Debian'
- name: trombik.redhat_repo
when: ansible_os_family == 'RedHat'
- role: trombik.java
# XXX バンドルされたjdkがUbuntuとCentOSで使用されます
when: ansible_os_family == "FreeBSD"
- role: trombik.sysctl
- ansible-role-opensearch
- role: trombik.opensearch_dashboards
- role: trombik.fluentd
- role: trombik.haproxy
vars:
# XXX 私の独自のパッケージを使用します。公式パッケージツリーのパッケージは壊れています。なお、このパッケージはEoLedかつ脆弱性があります。
freebsd_pkg_repo:
local:
enabled: "true"
url: "http://pkg.i.trombik.org/{{ ansible_distribution_version | regex_replace('\\.') }}{{ ansible_architecture }}-default-default"
mirror_type: none
priority: 100
state: present
os_opensearch_extra_packages:
FreeBSD: []
Debian:
- unzip
RedHat: []
opensearch_extra_packages: "{{ os_opensearch_extra_packages[ansible_os_family] }}"
os_java_packages:
FreeBSD:
- openjdk11
- jq
- vim
- tmux
- p5-ack
Debian:
- openjdk-11-jdk
RedHat:
- java-11-openjdk-devel
java_packages: "{{ os_java_packages[ansible_os_family] }}"
os_sysctl:
FreeBSD:
kern.maxfilesperproc: 65536
security.bsd.unprivileged_mlock: 1
Debian:
# https://opensearch.org/docs/latest/opensearch/install/important-settings/
vm.max_map_count: 262144
RedHat:
vm.max_map_count: 262144
sysctl: "{{ os_sysctl[ansible_os_family] }}"
opensearch_wait_for_cluster_status: yellow
os_opensearch_package:
FreeBSD: "{{ __opensearch_package }}"
Debian: "{{ __opensearch_package }}"
RedHat: opensearch-1.13.2
opensearch_package: "{{ os_opensearch_package[ansible_os_family] }}"
os_opensearch_flags:
FreeBSD: ""
Debian: |
ES_PATH_CONF={{ opensearch_conf_dir }}
ES_STARTUP_SLEEP_TIME=5
RedHat: |
ES_PATH_CONF={{ opensearch_conf_dir }}
ES_STARTUP_SLEEP_TIME=5
opensearch_flags: "{{ os_opensearch_flags[ansible_os_family] }}"
os_opensearch_jvm_options:
FreeBSD: ""
Debian: |
# opensearch-tar-install.shを参照
# /usr/bin/getconf CLK_TCK`
-Dclk.tck=100
-Djdk.attach.allowAttachSelf=true
-Djava.security.policy={{ opensearch_root_dir }}/plugins/opensearch-performance-analyzer/pa_config/opensearch_security.policy
RedHat: |
# /usr/bin/getconf CLK_TCK`
-Dclk.tck=100
-Djdk.attach.allowAttachSelf=true
-Djava.security.policy={{ opensearch_root_dir }}/plugins/opensearch-performance-analyzer/pa_config/opensearch_security.policy
os_opensearch_http_auth:
FreeBSD:
url_username: admin
url_password: admin
ca_path: "{{ role_path }}/files/test/certs/root-ca.pem"
validate_certs: yes
Debian:
client_cert: "{{ role_path }}/files/test/certs/admin.pem"
client_key: "{{ role_path }}/files/test/certs/admin-key.pem"
# XXX Ubuntuのansibleのバージョンは2.9.6です。このため、ca_pathを使用することはできません。
validate_certs: no
RedHat:
client_cert: "{{ role_path }}/files/test/certs/admin.pem"
client_key: "{{ role_path }}/files/test/certs/admin-key.pem"
validate_certs: no
opensearch_http_auth: "{{ os_opensearch_http_auth[ansible_os_family] }}"
opensearch_jvm_options: "{{ lookup('file', 'test/jvm_options') + os_opensearch_jvm_options[ansible_os_family] }}"
opensearch_config:
discovery.type: single-node
network.publish_host: ["10.0.2.15"]
path.data: "{{ opensearch_db_dir }}"
http.port: "{{ opensearch_http_port }}"
path.logs: "{{ opensearch_log_dir }}"
node.data: "true"
http.compression: "true"
network.host:
- "{{ opensearch_http_host }}"
- _site_
cluster.name: testcluster
node.name: testnode
http.cors.enabled: "true"
http.cors.allow-origin: "*"
http.cors.max-age: 86400
http.cors.allow-methods: "OPTIONS, HEAD, GET, POST, PUT, DELETE"
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length"
http.cors.allow-credentials: "true"
# _________________________TLS
plugins.security.ssl.transport.pemcert_filepath: node.pem
plugins.security.ssl.transport.pemkey_filepath: node-key.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem
plugins.security.ssl.transport.enforce_hostname_verification: false
plugins.security.ssl.http.enabled: true
plugins.security.ssl.http.pemcert_filepath: node.pem
plugins.security.ssl.http.pemkey_filepath: node-key.pem
plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem
plugins.security.allow_unsafe_democertificates: true
plugins.security.allow_default_init_securityindex: true
plugins.security.authcz.admin_dn:
# XXX admin_dnとnodes_dnには異なるCNを使用します。admin_dn == nodes_dnの場合はエラーとなります。
- CN=Admin,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU
plugins.security.nodes_dn:
- CN=localhost,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU
plugins.security.advanced_modules_enabled: false
plugins.security.audit.type: internal_opensearch
plugins.security.enable_snapshot_restore_privilege: true
plugins.security.check_snapshot_restore_write_privileges: true
plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"]
plugins.security.system_indices.enabled: true
plugins.security.system_indices.indices: [".opendistro-alerting-config", ".opendistro-alerting-alert*", ".opendistro-anomaly-results*", ".opendistro-anomaly-detector*", ".opendistro-anomaly-checkpoints", ".opendistro-anomaly-detection-state", ".opendistro-reports-*", ".opendistro-notifications-*", ".opendistro-notebooks", ".opendistro-asynchronous-search-response*"]
plugins.security.disabled: false
cluster.routing.allocation.disk.threshold_enabled: false
project_security_plugin_dir: "{{ opensearch_plugins_dir }}/opensearch-security"
project_securityadmin_bin: "{{ project_security_plugin_dir }}/tools/securityadmin.sh"
project_security_plugin_post_command:
cmd: "{{ project_securityadmin_bin }} -icl -nhnv -cacert {{ opensearch_conf_dir }}/root-ca.pem -cert {{ opensearch_conf_dir }}/admin.pem -key {{ opensearch_conf_dir }}/admin-key.pem"
args:
chdir: "{{ project_security_plugin_dir }}/securityconfig"
enabled: "{% if 1 == 1 %}yes{% else %}no{% endif %}"
opensearch_plugins: []
opensearch_extra_plugin_files:
- path: opensearch-security/securityconfig/action_groups.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/action_groups.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
- path: opensearch-security/securityconfig/audit.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/audit.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
- path: opensearch-security/securityconfig/config.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/config.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
- path: opensearch-security/securityconfig/internal_users.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/internal_users.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
- path: opensearch-security/securityconfig/nodes_dn.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/nodes_dn.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
- path: opensearch-security/securityconfig/roles.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/roles.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
- path: opensearch-security/securityconfig/roles_mapping.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/roles_mapping.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
- path: opensearch-security/securityconfig/tenants.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/tenants.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
- path: opensearch-security/securityconfig/whitelist.yml
type: yaml
mode: "0640"
group: "{{ opensearch_user }}"
content: "{{ lookup('file', 'test/securityconfig/whitelist.yml') | from_yaml }}"
post_command: "{{ project_security_plugin_post_command }}"
opensearch_config_log4j2_properties: "{{ lookup('file', 'test/log4j2_properties') }}"
x509_certificate_debug_log: yes
# XXX これらのキーは以下のステップに従って作成されました:
# https://opensearch.org/docs/latest/security-plugin/configuration/generate-certificates/
#
# ステップのコピー:
#
# ルートCA
# openssl genrsa -out root-ca-key.pem 2048
# openssl req -new -x509 -sha256 -key root-ca-key.pem -out root-ca.pem
#
# 管理者証明書
# openssl genrsa -out admin-key-temp.pem 2048
# openssl pkcs8 -inform PEM -outform PEM -in admin-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out admin-key.pem
# openssl req -new -key admin-key.pem -out admin.csr
# openssl x509 -req -in admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out admin.pem
#
# ノード証明書
# openssl genrsa -out node-key-temp.pem 2048
# openssl pkcs8 -inform PEM -outform PEM -in node-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out node-key.pem
# openssl req -new -key node-key.pem -out node.csr
# openssl x509 -req -in node.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out node.pem
#
# クリーンアップ
# rm admin-key-temp.pem admin.csr node-key-temp.pem node.csr
#
# これらのステップを自動化するには、files/test/certs/Makefileを参照してください。
x509_certificate:
- name: node
state: present
public:
path: "{{ opensearch_conf_dir }}/node.pem"
mode: "0444"
key: "{{ lookup('file', 'test/certs/node.pem') }}"
secret:
path: "{{ opensearch_conf_dir }}/node-key.pem"
owner: "{{ opensearch_user }}"
group: "{{ opensearch_group }}"
mode: "0600"
key: "{{ lookup('file', 'test/certs/node-key.pem') }}"
- name: root-ca
state: present
public:
path: "{{ opensearch_conf_dir }}/root-ca.pem"
key: "{{ lookup('file', 'test/certs/root-ca.pem') }}"
secret:
path: "{{ opensearch_conf_dir }}/root-ca-key.pem"
owner: "{{ opensearch_user }}"
group: "{{ opensearch_group }}"
key: "{{ lookup('file', 'test/certs/root-ca-key.pem') }}"
- name: admin
state: present
public:
path: "{{ opensearch_conf_dir }}/admin.pem"
key: "{{ lookup('file', 'test/certs/admin.pem') }}"
secret:
path: "{{ opensearch_conf_dir }}/admin-key.pem"
owner: "{{ opensearch_user }}"
group: "{{ opensearch_group }}"
key: "{{ lookup('file', 'test/certs/admin-key.pem') }}"
# _____________________________________________opensearch-dashboards
opensearch_dashboards_config:
server.host: "{{ opensearch_dashboards_bind_address }}"
server.port: "{{ opensearch_dashboards_bind_port }}"
server.name: "OpenSearch Dashboards"
# XXX FreeBSDパッケージのログパスを修正
logging.dest: "{% if ansible_os_family == 'FreeBSD' %}/var/log/opensearch_dashboards.log{% else %}{{ opensearch_dashboards_log_file }}{% endif %}"
logging.verbose: true
opensearch.hosts: ["https://localhost:9200"]
path.data: "{{ opensearch_dashboards_data_dir }}"
opensearch.ssl.verificationMode: none
opensearch.username: "kibanaserver"
opensearch.password: "kibanaserver"
opensearch_security.multitenancy.enabled: true
opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"]
opensearch_security.readonly_mode.roles: ["kibana_read_only"]
# HTTPSなしでKibanaを実行している場合はこの設定を使用します
opensearch_security.cookie.secure: false
# _____________________________________________haproxy
project_backend_host: 127.0.0.1
project_backend_port: 5601
os_haproxy_selinux_seport:
FreeBSD: {}
Debian: {}
RedHat:
ports:
- 80
- 5601
proto: tcp
setype: http_port_t
haproxy_selinux_seport: "{{ os_haproxy_selinux_seport[ansible_os_family] }}"
haproxy_config: |
global
daemon
{% if ansible_os_family != 'RedHat' %}
# デフォルトの1024の最大行長を65535に増やします。これを超えるとログが切り詰められます。
log 127.0.0.1:5140 len 65535 format rfc3164 local0 info
{% else %}
# XXX haproxy 1.xは`format`を理解していません。
log 127.0.0.1:5140 len 65535 local2
log-send-hostname
{% endif %}
{% if ansible_os_family == 'FreeBSD' %}
# FreeBSDパッケージはデフォルトを提供していません
maxconn 4096
user {{ haproxy_user }}
group {{ haproxy_group }}
{% elif ansible_os_family == 'Debian' %}
chroot {{ haproxy_chroot_dir }}
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user {{ haproxy_user }}
group {{ haproxy_group }}
# デフォルトのSSLマテリアルの場所
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# 参照:https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
{% elif ansible_os_family == 'OpenBSD' %}
maxconn 1024
chroot {{ haproxy_chroot_dir }}
uid 604
gid 604
pidfile /var/run/haproxy.pid
{% elif ansible_os_family == 'RedHat' %}
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
{% endif %}
defaults
log global
mode http
timeout connect 5s
timeout client 10s
timeout server 10s
retries 3
maxconn 2000
{% if ansible_os_family == 'Debian' %}
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
{% elif ansible_os_family == 'OpenBSD' %}
option redispatch
{% endif %}
frontend http-in
bind *:80
default_backend servers
unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
{% if ansible_os_family != 'RedHat' %}
http-request capture req.fhdr(Host) len 128
http-request capture req.fhdr(Referer) len 1024
http-request capture req.fhdr(User-Agent) len 1024
http-request capture req.fhdr(Accept) len 1024
{% else %}
capture request header Host len 128
capture request header Referer len 1024
capture request header User-Agent len 1024
capture request header Accept len 1024
{% endif %}
# JSONでのカスタムログフォーマット
# 自分のJSON構造を作成するには:
#
# cd files/test/haproxy
# ruby ./yaml2logformat.rb log.yml
#
# 出力には単一引用符のログフォーマットが含まれます。ただし、
# haproxyのバージョンが1.xの場合は単一引用符を削除する必要があります。
# 例えば、出力が次のようになる場合:
#
# log-format '{"bytes_read":%B}'
#
# これを使用します:
# log-format {"bytes_read":%B}
#
# 使用可能な変数は以下を参照:
# 8.2.4. カスタムログフォーマット
# https://www.haproxy.com/documentation/hapee/latest/onepage/#8.2.4
#
{% if ansible_os_family != 'RedHat' %}
log-format '{"bytes_read":%B,"hostname":"%H","http":{"method":"%HM","uri":"%HP","query":"%HQ","version":"%HV"},"unique-id":"%ID","status_code":%ST,"gmt_date_time":"%T","timestamp":%Ts,"bytes_uploaded":%U,"backend_name":"%b","beconn":%bc,"backend_queue":%bq,"client_ip":"%ci","client_port":%cp,"frontend_name":"%f","frontend_ip":"%fi","frontend_port":%fp,"ssl":{"ciphers":"%sslc","version":"%sslv"},"request":{"headers":{"host":"%[capture.req.hdr(0),json(utf8ps)]","referer":"%[capture.req.hdr(1),json(utf8ps)]","ua":"%[capture.req.hdr(2),json(utf8ps)]","accept":"%[capture.req.hdr(3),json(utf8ps)]"}}}'
{% else %}
# XXX CentOSのhaproxyは1.xです。そのバージョンは
# HM、`http-request capture`などを理解しません。JSONログの簡素化した
# バージョンを使用します。1.xのlog-formatは単一引用符を理解しません。
# スペースはエスケープする必要があります。
log-format {"bytes_read":%B,"hostname":"%H","unique-id":"%ID","status_code":%ST,"gmt_date_time":"%T","timestamp":%Ts,"bytes_uploaded":%U,"backend_name":"%b","beconn":%bc,"backend_queue":%bq,"client_ip":"%ci","client_port":%cp,"frontend_name":"%f","frontend_ip":"%fi","frontend_port":%fp,"ssl":{"ciphers":"%sslc","version":"%sslv"},"request":{"headers":"%hr"}}
{% endif %}
backend servers
option forwardfor
server server1 {{ project_backend_host }}:{{ project_backend_port }} maxconn 32 check
os_haproxy_flags:
FreeBSD: |
haproxy_flags="-p {{ fluentd_plugin_dir }} --log {{ fluentd_log_file }}"
Debian: |
TD_AGENT_LOG_FILE="{{ fluentd_log_file }}"
TD_AGENT_OPTIONS="-p {{ fluentd_plugin_dir }}"
STOPTIMEOUT=180
RedHat: |
TD_AGENT_LOG_FILE="{{ fluentd_log_file }}"
TD_AGENT_OPTIONS=""
OpenBSD: "--daemon /var/run/fluentd/fluentd.pid --config {{ fluentd_config_file }} -p {{ fluentd_plugin_dir }} --log {{ fluentd_log_file }}"
fluentd_flags: "{{ os_fluentd_flags[ansible_os_family] }}"
# _____________________________________________apt
apt_repo_keys_to_add:
- https://packages.treasuredata.com/GPG-KEY-td-agent
apt_repo_to_add:
- "deb http://packages.treasuredata.com/4/ubuntu/{{ ansible_distribution_release }}/ {{ ansible_distribution_release }} contrib"
# _____________________________________________redhat_repo
redhat_repo:
treasuredata:
baseurl: http://packages.treasuredata.com/4/redhat/$releasever/$basearch
gpgkey: https://packages.treasuredata.com/GPG-KEY-td-agent
ライセンス
Copyright (c) 2019 Tomoyuki Sakurai <y@trombik.org>
このソフトウェアを使用、コピー、改変、配布する権利を無償で付与します。ただし、
上記の著作権表示とこの許可の表示はすべてのコピーに含まれるものとします。
このソフトウェアは「現状のまま」提供され、著者はこのソフトウェアに関して
一切の保証を否認します。著者はいかなる特別、直接、間接、または結果的な損害についても
責任を負いません。また、使用、データまたは利益の損失に起因する損害についても
一切責任を負いません。ただし、契約、過失またはその他の不法行為に関係なく、使用や
このソフトウェアのパフォーマンスに関連して生じた損害については責任を負いません。
著者情報
Tomoyuki Sakurai y@trombik.org
このREADMEはqansibleによって作成されました。
ansible-galaxy install trombik.opensearch