Project

General

Profile

Distributed Icinga2 » History » Version 11

Jon Goldberg, 07/18/2018 04:08 AM
Update docs to reflect full Ansible automation

1 3 Jon Goldberg
{{last_updated_at}} by {{last_updated_by}}
2 1 Jon Goldberg
# Distributed Icinga2
3
4
### Overview
5
6
With a single instance of Icinga2, we can check the status of remote services that are publicly accessible.  For instance, we can check if SSH responds on a remote host.  However, we can NOT check information that is not publicly accessible - for instance, whether the remote server has low disk space.
7
8
To handle this, we use a distributed Icinga2 infrastructure.  Our original Icinga instance becomes a **master** instance.  We also install a minimal version of Icinga on remote servers, known as **satellite** instances.  Icinga2 has a wizard that establishes encrypted communication links between servers.  We use a [top-down configuration](https://docs.icinga.com/icinga2/latest/doc/module/icinga2/chapter/distributed-monitoring#distributed-monitoring-top-down), which means that all checks are initiated from the master instance - but some service checks are configured to run on a different endpoint.
9
10
In our instance, that means that some checks run entirely on the master - e.g. an SSH check - but a "low disk space" check is scheduled on the master instance, which contacts the satellite, instructs it to run the plugin, and return the result.
11
### Installing Icinga2 as a Satellite
12
13
Source: https://www.olindata.com/blog/2015/03/monitoring-remote-systems-icinga-2
14
15 9 Jon Goldberg
#### Ansible
16
Run the Ansible playbook. E.g.:
17
18
```bash
19 11 Jon Goldberg
ansible-playbook --tags icinga2 main-playbook.yml
20 9 Jon Goldberg
```
21
22
The manual commands are here:
23
24
{{collapse(Show manual instructions,Hide manual instructions)
25 1 Jon Goldberg
Run these commands on the satellite (assumes the satellite OS is Ubuntu)
26
27
```bash
28
apt install software-properties-common
29
add-apt-repository ppa:formorer/icinga
30
apt update
31
apt install icinga2
32
systemctl enable icinga2.service
33
systemctl start icinga2.service
34
```
35
Alternate instructions for Debian Jessie:
36 2 Jon Goldberg
37 4 Jon Goldberg
```bash
38 1 Jon Goldberg
# Note: Ensure you have jessie-backports enabled: https://backports.debian.org/Instructions/
39
apt install software-properties-common
40
apt-get -t jessie-backports install icinga2
41
# Debian installs some some host definitions that interfere with being a satellite; delete them
42
rm /etc/icinga2/conf.d/hosts.conf
43 5 Joseph Lacey
systemctl enable icinga2.service
44 1 Jon Goldberg
systemctl start icinga2.service
45 9 Jon Goldberg
```
46 1 Jon Goldberg
47 9 Jon Goldberg
#### Temporary: Add the updated check_apt
48
Until monitoring-plugins 2.3 comes out, copy the `check_apt` file from an existing server to the new satellite so that "only notify on security updates" is available as an option.  See #478.
49
50
#### Node Wizard
51
Then run the node wizard:
52
53
```bash
54 1 Jon Goldberg
# Get the salt from the master node in /etc/icinga2/constants.conf
55
icinga2 pki ticket --cn 'orange.megaphonetech.com' --salt <salt goes here>
56
icinga2 node wizard
57
```
58
Here's an example of the node wizard setup for a red.megaphonetech.com:
59 2 Jon Goldberg
60 1 Jon Goldberg
```
61
Please specify if this is a satellite setup ('n' installs a master setup) [Y/n]: 
62
Starting the Node setup routine...
63 8 Jon Goldberg
Please specify the common name (CN) [www.nwu.org]: 
64 1 Jon Goldberg
Please specify the master endpoint(s) this node should connect to:
65 8 Jon Goldberg
Master Common Name (CN from your master setup): orange.megaphonetech.com
66 1 Jon Goldberg
Do you want to establish a connection to the master from this node? [Y/n]: 
67
Please fill out the master connection information:
68 8 Jon Goldberg
Master endpoint host (Your master's IP address or FQDN): orange.megaphonetech.com
69 1 Jon Goldberg
Master endpoint port [5665]: 
70
Add more master endpoints? [y/N]: 
71
Please specify the master connection for CSR auto-signing (defaults to master endpoint host):
72 8 Jon Goldberg
Host [orange.megaphonetech.com]: 
73 1 Jon Goldberg
Port [5665]: 
74 10 Jon Goldberg
information/base: Writing private key to '/etc/icinga2/pki/nembhard.glocal.coop.key'.
75
information/base: Writing X509 certificate to '/etc/icinga2/pki/nembhard.glocal.coop.crt'.
76
information/cli: Fetching public certificate from master (orange.megaphonetech.com, 5665):
77 1 Jon Goldberg
78
Certificate information:
79
80 10 Jon Goldberg
 Subject:     CN = orange.megaphonetech.com
81 1 Jon Goldberg
 Issuer:      CN = Icinga CA
82 10 Jon Goldberg
 Valid From:  Jun  9 03:57:34 2017 GMT
83
 Valid Until: Jun  5 03:57:34 2032 GMT
84
 Fingerprint: C8 46 A0 A9 2A 47 AE 0D 51 BD 88 82 E8 CC BA 65 28 FD D7 EB 
85 1 Jon Goldberg
Is this information correct? [y/N]: Y
86
information/cli: Received trusted master certificate.
87
88
Please specify the request ticket generated on your Icinga 2 master.
89
 (Hint: # icinga2 pki ticket --cn 'rh6.jmaconsulting.biz'): #Run this command on the master to generate a ticket number
90
information/cli: Requesting certificate with ticket '00a2aff74b3b3145630504276912a9addd714810'.
91
92
information/cli: Created backup file '/etc/icinga2/pki/rh6.jmaconsulting.biz.crt.orig'.
93
information/cli: Writing signed certificate to file '/etc/icinga2/pki/rh6.jmaconsulting.biz.crt'.
94
information/cli: Writing CA certificate to file '/etc/icinga2/pki/ca.crt'.
95
Please specify the API bind host/port (optional):
96
Bind Host []: 
97
Bind Port []: 
98
Accept config from master? [y/N]: Y
99
Accept commands from master? [y/N]: Y
100
information/cli: Disabling the Notification feature.
101
Disabling feature notification. Make sure to restart Icinga 2 for these changes to take effect.
102
information/cli: Enabling the Apilistener feature.
103
Enabling feature api. Make sure to restart Icinga 2 for these changes to take effect.
104
information/cli: Created backup file '/etc/icinga2/features-available/api.conf.orig'.
105
information/cli: Generating local zones.conf.
106
information/cli: Dumping config items to file '/etc/icinga2/zones.conf'.
107
information/cli: Created backup file '/etc/icinga2/zones.conf.orig'.
108
information/cli: Updating constants.conf.
109
information/cli: Created backup file '/etc/icinga2/constants.conf.orig'.
110
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
111
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
112
Done.
113
```
114
Now run `service icinga2 checkconfig && service icinga2 restart` to finish the installation on the satellite.
115
### Create Zones and Endpoints
116
117
You must also set up the `Zone` and `Endpoint` objects, stored in `/etc/icinga2/zones.conf`. In our model, each zone contains one and only one endpoint.
118
#### Zones and Endpoints on the Satellite
119
120
The node wizard mostly handles this for you on the satellite, it will generate a file with these constants.  Note that NodeName and ZoneName are defined in /etc/icinga2/constants.conf, and should both be the name of the host.
121 2 Jon Goldberg
122 1 Jon Goldberg
```
123
object Endpoint "orange.megaphonetech.com" {
124
        host = "orange.megaphonetech.com"
125
        port = "5665"
126
}
127
128
object Zone "master" {
129
        endpoints = [ "orange.megaphonetech.com" ]
130
}
131
132
object Endpoint NodeName {
133
}
134
135
object Zone ZoneName {
136
        endpoints = [ NodeName ]
137
        parent = "master"
138
}
139
```
140
Add the following Zone object on your satellite.  Files in this zone are synced to all Icinga2 instances, so you can distribute many configuration files this way:
141 2 Jon Goldberg
142 1 Jon Goldberg
```
143
/* sync global commands */
144
object Zone "global-templates" {
145
        global = true
146
}
147
```
148
#### Zones and Endpoints on the Master
149
150
Edit `/etc/icinga2/zones.conf`.  Add the Zone and Endpoint of the new satellite.  For instance, if the satellite has a ZoneName and NodeName of database.lavabrooklyn.org defined in its constants /etc/icinga2/constants.conf then you should add these objects on the master:
151 2 Jon Goldberg
152 1 Jon Goldberg
```
153
object Endpoint "database.lavabrooklyn.org" {
154
}
155
156
object Zone "database.lavabrooklyn.org" {
157
        endpoints = [ "database.lavabrooklyn.org" ]
158
        parent = "master"
159
}
160
```
161 6 Jon Goldberg
#### Harden the TLS connection
162 1 Jon Goldberg
Add this line to the bottom of the "api" object in `/etc/icinga2/features-available/api.conf`:
163 6 Jon Goldberg
```tls_protocolmin = "TLSv1.2"```
164 1 Jon Goldberg
165 11 Jon Goldberg
#### How to change a satellite's hostname
166 6 Jon Goldberg
167 11 Jon Goldberg
Re-run `icinga2 node wizard` on the satellite.  This will fix the satellite's "constants.conf" and "zones.conf".
168
Edit `/etc/icinga2/zones.conf` Zone and Endpoint on the master to change the name.
169
}}
170 1 Jon Goldberg
171 11 Jon Goldberg
#### Testing the Zones/Endpoints
172
173
After reloading Icinga2 on both satellite and master (happens automatically with Ansible), you should be able to see the new checks reflected in Icingaweb2 immediately, though they might be listed as "Pending".  Click "Check now" to ensure they're working as expected.