nahsi.consul
Consul
Consulをインストール、設定、管理します。これはHashiCorpのサービスメッシュです。
役割の哲学
すべての設定オプションをAnsible変数として重複させるのではなく、Consulの設定はAnsibleインベントリにyaml
形式で保存されます:
consul_config:
data_dir: "/var/lib/consul/"
enable_syslog: true
# "trace", "debug", "info", "warn", "err"
log_level: "info"
syslog_facility: "LOCAL5"
rejoin_after_leave: true
bind_addr: !unsafe '{{ GetInterfaceIP "eth0" }}'
telemetry:
disable_hostname: true
prometheus_retention_time: "30s"
server: false
この設定は no_nice_json
フィルターを使用してホストにコピーされます:
- name: copy consul config
copy:
content: "{{ consul_config | to_nice_json }}"
dest: "/opt/consul/consul.json"
validate: "consul validate -config-format=json %s"
変数がマップ(例えばconsul_services
)の場合、マップの各キーは値をコンテンツとして持つファイルとしてコピーされます。
次のマップ
consul_services:
consul:
service:
id: "consul-api"
name: "consul-api"
port: 8500
tags:
- "traefik.enable=true"
- "traefik.http.routers.consul.entrypoints=https"
- "traefik.http.routers.consul.rule=Host(`consul.example.com`)"
meta:
external-source: "consul"
check:
id: "consul-api-health"
name: "consul-api-health"
http: "http://localhost:8500/v1/agent/self"
interval: "20s"
timeout: "2s"
telegraf:
service:
id: "telegraf-exporter"
name: "telegraf-exporter"
port: 9271
meta:
external-source: "consul"
check:
id: "telegraf-exporter-health"
name: "telegraf-exporter-health"
http: "http://localhost:9270"
interval: "20s"
timeout: "2s"
は/opt/consul/service.d/
にconsul.json
とtelegraf.json
というファイルを生成します。
マップに存在しないファイルは削除され、Ansibleインベントリで状態を維持することができます。
役割の変数
詳細や例については、defaults/を参照してください。
consul_version
- 使用するバージョン
consul_dirs
- 作成するディレクトリのマップ
- デフォルト:
consul_dir: "/opt/consul"
consul_dirs:
main:
path: "{{ consul_dir }}"
configs:
path: "{{ consul_dir }}/config.d"
services:
path: "{{ consul_dir }}/service.d"
certs:
path: "{{ consul_dir }}/certs"
mode: "u=rwX,g=rX,o="
scripts:
path: "{{ consul_dir }}/script.d"
logs:
path: "/var/log/consul"
data:
path: "/var/lib/consul"
mode: "u=rwX,g=rX,o="
consul_config
- メインの設定ファイル
- 例:詳細は defaults/example.ymlを参照してください。
consul_configs
config.d
ディレクトリに作成する設定ファイルのマップ。変更時に再起動します。
consul_services
service.d
ディレクトリに作成するサービスファイルのマップ。変更時にリロードします。
consul_scripts
scripts.d
ディレクトリに作成するスクリプトのマップ
consul_user
- Consulプロセスとファイルの所有者
- デフォルト:
consul
consul_group
consul_user
のグループ- デフォルト:
consul
consul_download_url
- Consulアーカイブを取得するためのURL
- デフォルト:
https://releases.hashicorp.com
consul_service
- openrcサービスファイル
- デフォルト:詳細は defaults/main.ymlを参照してください。
consul_unitfile
- systemdユニットファイル
- デフォルト:詳細は defaults/main.ymlを参照してください。
skip_handlers
- Consulの再起動/リロードをスキップする - Packerでイメージをビルドする際に便利
- デフォルト:
false
タグ
config
- Consulのユニット/サービスファイルを更新し、設定ファイルを同期しますservices
- Consulサービスを同期しますscripts
- Consulスクリプトを同期します
作者
- Anatoly Laskaris - nahsi
プロジェクトについて
Manage HashiCorp Consul
インストール
ansible-galaxy install nahsi.consul
ライセンス
mit
ダウンロード
1.8k