项目作者: OSSHelp

项目描述 :
Ansible role for Consul
高级语言: HTML
项目地址: git://github.com/OSSHelp/ansible-consul.git
创建时间: 2021-01-21T09:40:58Z
项目社区:https://github.com/OSSHelp/ansible-consul

开源协议:GNU General Public License v3.0

下载


Consul

Build Status

Role which installs Consul and generates needed JSON-config.

Deploy example (do not copy blindly!)

  1. - role: consul
  2. consul_version: "1.11.1"
  3. consul_initial_setup: true
  4. consul_params:
  5. encrypt: "secret_key_here"
  6. datacenter: "test-datacenter"
  7. node_name: "test-node"
  8. data_dir: "/var/lib/consul"
  9. retry_join: [ "netdata-master" ]
  10. pid_file: "/var/run/consul/consul.pid"
  11. enable_local_script_checks: true
  12. consul_services:
  13. - service:
  14. id: netdata
  15. name: netdata
  16. tags: ['netdata']
  17. port: 19999
  18. checks:
  19. - id: netdata-health
  20. name: netdata-health
  21. http: http://localhost:19999/api/v1/info
  22. method: GET
  23. interval: 60s
  24. header:
  25. accept: ['application/json']
  26. - service:
  27. id: sshd
  28. name: sshd
  29. tags: ['sshd']
  30. port: 22
  31. checks:
  32. - id: sshd-health
  33. name: sshd-health
  34. interval: 60s
  35. tcp: localhost:22
  36. timeout: 1s

Secret keys must be base64, or Consul will not start.

Advertising to existing interface

Could be done with parameters:

  1. consul_advertise_iface:
  2. enabled: true
  3. iface: eth0

Where eth0 must be replaced with proper interface name.

Controling UI path

Could be made by overriding consul_ui_content_path param:

  1. consul_ui_content_path: /ui/consul

By default, the path is /ui/, for example http://localhost:8500/ui/. Only alphanumerics, -, and _ are allowed in a custom path. /v1/ is not allowed as it would overwrite the API endpoint.

About JSON generation

Configs are being generated from YML (variable consul_params). Consul has quite straight-forward configuration, so in most cases you will be able to describe with YML any parameters needed. For example, this:

  1. consul_params:
  2. enable_local_script_checks: true
  3. pid_file: "/var/run/consul/consul.pid"
  4. retry_join: [ "netdata-master" ]

will result in such JSON:

  1. {
  2. "enable_local_script_checks": true,
  3. "pid_file": "/var/run/consul/consul.pid",
  4. "retry_join": [
  5. "netdata-master"
  6. ]
  7. }

Services registration

You can describe any configuration with consul_services list (see example above), which is then converted to json configs. Keep in mind that this role can’t delete old cfgs, after removing services from the list.

Cluster initialization

Not supported by the role, and there is no assurance that it will be implemented. You need to bootstrap manually, or set consul_params.bootstrap to true.

Versions available without URLs overwriting

  • 1.14.0
  • 1.13.3
  • 1.12.6
  • 1.11.11
  • 1.11.1
  • 1.10.12
  • 1.9.17
  • 1.8.19
  • 1.7.14
  • 1.6.3

TODO

License

GPL3

Author

OSSHelp Team, see https://oss.help