Deploy NXLog Agent with Salt
Salt is a free software configuration management tool that offers fast and scalable configuration management and a remote execution software framework.
This framework runs concurrently on the minions
, permitting the instantaneous configuration of an unlimited number of remote hosts by using language-specific state files.
A basic Salt setup consists of a Salt master (your workstation) handling one or more Salt minions (the target servers).
A server running the salt-master
service is called the Salt master.
The master provides the orchestration and automation environment between managed nodes.
A system or device operated by the Salt master is called a Salt minion.
A minion can either run the salt-minion
service or be agentless utilizing salt-ssh
or salt-proxy
.
In our example, we will use the salt-ssh
service to reduce complexity.
To install Salt, refer to the Salt installation guide.
Salt Master configuration file
Before using salt-ssh
, you must configure the Salt-Master installed on your workstation.
Edit /etc/salt/master
and uncomment the following lines:
interface: 0.0.0.0
publish_port: 4505
enable_ssh_minions: True
ret_port: 4506
conf_file: /etc/salt/master
ssh_port: 22
file_roots:
base:
- /srv/salt/states
- /srv/salt/files
The most important information here is the file_roots
key that defines the respective paths to state files, images, installation files, etc.
It will fail if a task attempts to upload a file to any path not specified here.
Now restart the salt-master
service to apply the changes by executing:
$ systemctl restart salt-master
Salt configuration file
Salt SSH connects to remote nodes using a file called roster
located at /etc/salt/roster
.
The roster file contains information regarding the remote systems and their connection.
With the roster file configured, salt-ssh can execute all Salt commands.
Although the roster file does not have a file extension, it is a YAML file.
The following YAML file will be used for this example.
ubuntu:
host: 192.168.1.10
user: <username>
passwd: <password>
sudo: True
tty: True
When using sudo , ensure that tty is also enabled.
Otherwise, the connection will fail.
|
Test the connection to the remote node:
$ salt-ssh 'ubuntu*' test.ping
The command should return:
ubuntu:
True
NXLog Agent configuration file
Prior to writing the Salt state file, the NXLog Agent configuration file needs to be created and saved in /srv/salt/files/managed.conf
.
This configuration example will set up NXLog Agent with a basic connection to NXLog Platform.
The basic configuration can be downloaded by navigating to Agents > Agents in NXLog Platform and clicking on Add new Agent.
The downloaded config will include the correct YOUR_PLATFORM_ADDRESS
define.
define HOST YOUR_PLATFORM_ADDRESS:5514
LogLevel INFO
LogFile %MYLOGFILE%
<Extension admin>
Module xm_admin
Host %HOST%
SocketType SSL
AllowUntrusted True
RequireCert False
<ACL conf>
Directory %CONFDIR%
AllowRead TRUE
AllowWrite TRUE
</ACL>
<ACL cert>
Directory %CERTDIR%
AllowRead TRUE
AllowWrite TRUE
</ACL>
</Extension>
The next step is to create the state
file, which defines the steps for installing and configuring NXLog Agent.
copy_nxlog_archive:
file.managed:
- name: /srv/salt/files/nxlog-5.4.7313_ubuntu20_amd64.tar.bz2
- source: salt://nxlog-5.4.7313_ubuntu20_amd64.tar.bz2
- user: root
- group: root
- makedirs: True
nxlog_archive_extraction:
archive.extracted:
- name: /srv/salt/files/nxlog
- source: salt://nxlog-5.4.7313_ubuntu20_amd64.tar.bz2
- enforce_toplevel: False
nxlog_deps_installation:
pkg.installed:
- pkgs:
- libapr1
- libdbi1
- curl
- openjdk-8-jdk
nxlog_instalaltion:
pkg.installed:
- sources:
- nxlog: /srv/salt/files/nxlog/nxlog-5.4.7313_ubuntu20_amd64.deb
- ruby: /srv/salt/files/nxlog/nxlog-ruby_5.4.7313_ubuntu20_amd64.deb
- systemd: /srv/salt/files/nxlog/nxlog-systemd_5.4.7313_ubuntu20_amd64.deb
- java: /srv/salt/files/nxlog/nxlog-java_5.4.7313_ubuntu20_amd64.deb
- python: /srv/salt/files/nxlog/nxlog-python_5.4.7313_ubuntu20_amd64.deb
- odbc: /srv/salt/files/nxlog/nxlog-odbc_5.4.7313_ubuntu20_amd64.deb
- checkpoint: /srv/salt/files/nxlog/nxlog-checkpoint_5.4.7313_ubuntu20_amd64.deb
- pcap: /srv/salt/files/nxlog/nxlog-pcap_5.4.7313_ubuntu20_amd64.deb
- wseventing: /srv/salt/files/nxlog/nxlog-wseventing_5.4.7313_ubuntu20_amd64.deb
- dbi: /srv/salt/files/nxlog/nxlog-dbi_5.4.7313_ubuntu20_amd64.deb
- perl: /srv/salt/files/nxlog/nxlog-perl_5.4.7313_ubuntu20_amd64.deb
- zmq: /srv/salt/files/nxlog/nxlog-zmq_5.4.7313_ubuntu20_amd64.deb
- kafka: /srv/salt/files/nxlog/nxlog-kafka_5.4.7313_ubuntu20_amd64.deb
copy_nxlog_config:
file.managed:
- name: /opt/nxlog/etc/nxlog.d/managed.conf
- source: salt://managed.conf
- user: nxlog
- group: nxlog
restart_nxlog:
service.running:
- name: nxlog
- enable: True
- full_restart: True
- watch:
- file: /opt/nxlog/etc/nxlog.d/managed.conf
The state file has the .sls extension.
|
To run the tasks on the remote server, execute the command:
$ salt-ssh 'ubuntu*' state.apply nxlog