main.yml 1.9 KB
Newer Older
EKbfh's avatar
EKbfh committed
1
2
3
4
5
6
7
8
9
10
11
---
# File: main.yml - Main tasks for NATS-Server

# Add user
- name: Add Nats user
  user:
    name: "{{ nats_user }}"
    comment: "Nats user"
    group: "{{ nats_group }}"
    system: "True"
    home: "{{ nats_home }}"
EKbfh's avatar
EKbfh committed
12
    shell: "/bin/false"
EKbfh's avatar
EKbfh committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  tags:
    - config

- name: "Include OS-specific tasks"
  include_tasks: "os/{{ ansible_distribution }}/main.yml"
  tags:
    - requirements
    - config

- name: Include dir settings
  import_tasks: dirs.yml
  tags:
    - config

- name: Install OS packages and Nats
  import_tasks: install.yml
  tags:
    - requirements

- name: Nats config
  import_tasks: config.yml
  tags:
    - config

- name: Start Nats
  service:
    name: nats-server
    state: started
    enabled: "True"

- name: place Nats consul check
  import_role:
    name: consul
    tasks_from: service
  vars:
    consul_service_name: nats
    consul_service_tags: ""
    consul_service_port: "{{ nats_client_port }}"
EKbfh's avatar
EKbfh committed
51
52
    consul_service_check_type: "tcp"
    consul_service_check_value: "{{ ansible_host }}:{{ nats_client_port }}"
EKbfh's avatar
EKbfh committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    consul_service_check_interval: "10s"
    consul_service_check_http_skip_verify: "False"

- name: Install Nats monitoring
  include_role:
    name: monitoring
    tasks_from: monitor
  vars:
    monitoring_service_name: nats
    monitoring_service_tags: ""
    monitoring_service_port: "{{ nats_client_port }}"
    monitoring_service_address: "{{ ansible_host }}"
    monitoring_service_check_interval: "10s"
    monitoring_service_procstat_check: "True"
    monitoring_service_procstat_type: pattern
    monitoring_service_procstat_value: nats-server
    monitoring_service_tagexclude: ["client_deflate", "client_address", "client_hostname", "client_name", "client_snappy", "client_tls", "client_user_agent", "client_version", "server_version"]  # noqa 204
    monitoring_config:
      server: "http://{{ ansible_nodename }}:4300"
  when: has_svc_monitoring is defined
  tags:
    - monitoring