timorunge.pmm_client
pmm_client
この役割は、Percona PMMクライアントをインストールして設定します。
必要条件
この役割は Ansible 2.5.0 以上が必要です。
安定したバージョンを簡単にインストール(および指定)するには、pipを使用します:
pip install ansible==2.8.4
すべてのプラットフォーム要件はメタデータファイルに記載されています。
インストール
ansible-galaxy install timorunge.pmm_client
役割の変数
この役割に渡すことができる変数とそれに関する簡単な説明は以下の通りです。(すべての変数については defaults/main.yml を参照してください)
# バージョンを定義
# タイプ: 整数
pmm_client_version: 1.17.1
# PMMサーバーのIPアドレスとポート:
# タイプ: 文字列
pmm_client_server_host: 172.20.0.10
# タイプ: 整数
pmm_client_server_port: 443
# ベーシック認証を無効にする:
# タイプ: ブール
pmm_client_server_basic_auth: false
# SSLを有効にする:
# タイプ: ブール
pmm_client_server_use_ssl: true
# 初期設定時にクライアント名を強制的に設定する
# タイプ: ブール
pmm_client_force_setup: false
# 追加または削除するサービスを定義:
# タイプ: リスト
pmm_client_add_services:
- linux:metrics
- mysql:metrics
- mongodb:metrics
- postgresql:metrics
pmm_client_remove_services:
- mysql:queries
# 開始または停止するサービスを定義:
# タイプ: リスト
pmm_client_start_services:
- linux:metrics
- mysql:metrics
- mongodb:metrics
- postgresql:metrics
pmm_client_stop_services:
- mysql:queries
# MySQL DB接続のための認証情報を定義:
# タイプ: 辞書
pmm_client_db:
mysql:
host: localhost
port: 3306
username: root
password: toor
例
1) ベーシック認証なし、SSL無効でPMMクライアントをインストール
- hosts: all
become: yes
vars:
pmm_client_server_host: 172.20.0.10
pmm_client_server_port: 443
pmm_client_server_basic_auth: false
pmm_client_server_use_ssl: false
pmm_client_add_services:
- linux:metrics
pmm_client_start_services:
- linux:metrics
roles:
- timorunge.pmm_client
2) ベーシック認証あり、SSL有効でPMMクライアントをインストール
- hosts: all
become: yes
vars:
pmm_client_server_host: 172.20.0.10
pmm_client_server_port: 443
pmm_client_server_basic_auth: true
pmm_client_server_basic_auth_username: admin
pmm_client_server_basic_auth_password: mySecurePassword
pmm_client_server_use_ssl: true
pmm_client_add_services:
- linux:metrics
pmm_client_start_services:
- linux:metrics
roles:
- timorunge.pmm_client
3) 定義したURLからPMMクライアントをインストール
- hosts: all
become: yes
vars:
pmm_client_version: 1.17.1
pmm_client_version_revision: 1
pmm_client_use_official_repo: false
pmm_client_debian_pkg: "https://www.percona.com/downloads/pmm/{{ pmm_client_version }}/binary/debian/{{ ansible_distribution_release }}/x86_64/pmm-client_{{ pmm_client_version }}-{{ pmm_client_version_revision }}.{{ ansible_distribution_release }}_amd64.deb"
roles:
- timorunge.pmm_client
4) PMMクライアントのセットアップを強制する
状況によっては、PMMクライアントのセットアップを強制する必要があります。例えば、サーバーにアクセスできない場合や、以前使用していたホスト名で新しいセットアップを行った場合です。
以下のようなメッセージが表示されます:
TASK [timorunge.pmm-client : include_tasks] ********************************************************************************************************
included: ... ansible-pmm-client/tasks/server-config.yml for proxysql-aN8thi
TASK [timorunge.pmm-client : Check if PMM Client is configured] ************************************************************************************
fatal: [proxysql-aN8thi]: FAILED! => {"changed": false, "cmd": ["pmm-admin", "list"], "delta": "0:00:00.148803", "end": "2018-09-25 09:39:46.297917", "msg": "non-zero return code", "rc": 1, "start": "2018-09-25 09:39:46.149114", "stderr": "", "stderr_lines": [], "stdout": "PMM client is not configured, missing config file. Please make sure you have run 'pmm-admin config'.", "stdout_lines": ["PMM client is not configured, missing config file. Please make sure you have run 'pmm-admin config'."]}
...ignoring
TASK [timorunge.pmm-client : Configure PMM Client - Basic mode] ************************************************************************************
fatal: [proxysql-aN8thi]: FAILED! => {"changed": true, "cmd": ["pmm-admin", "config", "--server", "172.20.0.10:80", "--client-name", "proxysql-aN8thi", "--config-file", "/usr/local/percona/pmm-client/pmm.yml"], "delta": "0:00:00.239708", "end": "2018-09-25 09:39:50.590280", "msg": "non-zero return code", "rc": 1, "start": "2018-09-25 09:39:50.350572", "stderr": "", "stderr_lines": [], "stdout": "Another client with the same name 'proxysql-aN8thi' detected, its address is 172.20.0.11.\nIt has the active services so this name is not available.\n\nSpecify the other one using --client-name flag.\n\nIn case this is the correct client node that was previously uninstalled with unreachable PMM server,\nyou can add --force flag to proceed further. Do not use this flag otherwise.\nThe orphaned remote services will be removed automatically.", "stdout_lines": ["Another client with the same name 'proxysql-aN8thi' detected, its address is 172.20.0.11.", "It has the active services so this name is not available.", "", "Specify the other one using --client-name flag.", "", "In case this is the correct client node that was previously uninstalled with unreachable PMM server,", "you can add --force flag to proceed further. Do not use this flag otherwise.", "The orphaned remote services will be removed automatically."]}
to retry, use: --limit @... main.retry
PLAY RECAP *****************************************************************************************************************************************
proxysql-aN8thi : ok=9 changed=0 unreachable=0 failed=1
基本的に、2つのオプションがあります:
1) yaml設定を使用
- hosts: all
become: yes
vars:
pmm_client_force_setup: true
roles:
- timorunge.pmm_client
2) コマンドラインを使用
これは推奨される方法です。
$ ansible-playbook main.yml -i inventory -b --limit "proxysql-aN8thi" --diff -e "{ pmm_client_force_setup: true }"
...
TASK [timorunge.pmm-client : Check if PMM Client is configured] ************************************************************************************
fatal: [proxysql-aN8thi{"changed": false, "cmd": ["pmm-admin", "list"], "delta": "0:00:00.361021", "end": "2018-09-25 09:51:30.675725", "msg": "non-zero return code", "rc": 1, "start": "2018-09-25 09:51:30.314704", "stderr": "", "stderr_lines": [], "stdout": "PMM client is not configured, missing config file. Please make sure you have run 'pmm-admin config'.", "stdout_lines": ["PMM client is not configured, missing config file. Please make sure you have run 'pmm-admin config'."]}
...ignoring
TASK [timorunge.pmm-client : Configure PMM Client - Basic mode] ************************************************************************************
changed: [proxysql-aN8thi]
...
TASK [timorunge.pmm-client : Adding Linux and ProxySQL services to monitoring] *********************************************************************
changed: [proxysql-aN8thi] => (item=linux:metrics)
changed: [proxysql-aN8thi] => (item=proxysql:metrics)
...
proxysql-aN8thi : ok=13 changed=2 unreachable=0 failed=0
5) PMMクライアントをアンインストール
- hosts: all
become: yes
vars:
pmm_client_enabled: false
roles:
- timorunge.pmm_client
テスト
テストは Docker と docker_test_runner を使用して行われ、異なる環境設定のコンテナが立ち上がります:
- CentOS 7
- Debian 9.4 (Stretch)
- Ubuntu 16.04 (Xenial Xerus)
- Ubuntu 18.04 (Bionic Beaver)
すべてのコンテナにAnsible 2.8.4がインストールされており、 test playbook が適用されます。
詳細や追加のチェックについては、 docker_test_runnerの設定 および Dockerエントリポイントを参照してください。
# ローカルでテストする:
curl https://raw.githubusercontent.com/timorunge/docker-test-runner/master/install.sh | sh
./docker_test_runner.py -f tests/docker_test_runner.yml
トラビスビルドの時間が限られているため、 自動テストは以下に制限されています:
- CentOS 7
- Debian 9.4 (Stretch)
- Ubuntu 16.04 (Xenial Xerus)
- Ubuntu 18.04 (Bionic Beaver)
依存関係
なし
ライセンス
BSD 3-Clause "New" or "Revised" License
作者情報
- Chris Sam のAnsible役割に基づいています
- Timo Rungeによって大幅に改変されました
プロジェクトについて
Percona PMM Client for Debian and RedHat based distributions
インストール
ansible-galaxy install timorunge.pmm_client
ライセンス
bsd-3-clause
ダウンロード
7.2k
所有者