Deploy NXLog Agent with Puppet Bolt
Puppet Bolt is an agentless and masterless remote task runner that you can utilize with your existing server administration scripts. It connects with Windows nodes using WinRM and Linux nodes using SSH, eliminating the need to install agents on remote hosts.
To install Puppet Bolt, refer to the Puppet Bolt installation guide, where you can find platform-specific instructions for Windows and Linux systems.
To install NXLog Agent using Puppet Bolt, follow the instructions below:
-
First, create a project directory by issuing the following command:
$ mkdir -p nxlog_bolt; cd nxlog_bolt; bolt project initIt should result in the creation of three new files:
-
bolt-project.yaml -
inventory.yaml -
.gitignore(a hidden file)
-
-
Next, create a
modulecontaining the NXLog Agent directory and two subdirectories,plansandfiles.Execute the following command to create the directories needed:
$ mkdir -p modules/nxlog/{files,plans} -
Edit the
bolt-project.yamlfile:Example 1. Puppet Bolt project filebolt-project.yamlis created when you execute thebolt project initcommand. Edit the file as follows to declare the plan definition, in this case,nxlog::nxlog_install.bolt-project.yaml--- name: nxlog_bolt modules: [] color: true plans: - nxlog::nxlog_install -
Update the
inventory.yamlfile:Example 2. Puppet Bolt inventory filePuppet Bolt uses this file to connect to the remote host and execute the specified plan.
inventory.yamlgroups: - name: linux targets: - uri: 192.168.1.10 name: ubuntu config: transport: ssh ssh: user: root password: your_root_password host-key-check: false -
NXLog Agent configuration
Example 3. NXLog Agent Puppet Bolt configuration exampleThis 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 COMPANY ADDRESS>define.managed.confdefine HOST <YOUR COMPANY 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> </Route>managed.conf has to exist inside the filesdirectory. The same applies to the downloaded NXLog Agent installation file. It is Puppet Bolt’s default technique for uploading files to remote hosts. -
Next, log in to your NXLog account, click on Your Account > Downloads, and from the Version drop-down menu select NXLog Agent v6, then download
nxlog-6.10.10368_debian10_amd64.tar.bz2.Place the NXLog Agent tar archive in the
modules/nxlog/filesdirectory you created in step 2. Puppet Bolt will upload the tar archive, unpack it, and install the Debian packages when the plan is executed.The Plan below executes four tasks:
-
Upload the compressed archive.
-
Unpack and install the NXLog Agent and various additional
.debfiles. -
Upload the NXLog Agent configuration file to
/opt/nxlog/etc/nxlog.d. -
Restart NXLog Agent for the new changes to take effect.
Example 4. nxlog_install.yaml--- parameters: targets: type: TargetSpec steps: - name: upload_ubuntu_nxlog_executable upload: nxlog/files/nxlog-5.4.7313_ubuntu20_amd64.tar.bz2 destination: /root/ targets: ubuntu description: Uploaded NXLog Archive - name: nxlog_ubuntu_install command: apt install -y libapr1 libdbi1 curl openjdk-8-jdk; mkdir -p nxlog; tar -xvf nxlog-5.4.7313_ubuntu20_amd64.tar.bz2 -C nxlog; dpkg -i nxlog/nxlog-5.4.7313_ubuntu20_amd64.deb; dpkg -i nxlog/*.deb; apt install -y -f; catch_errors: true targets: ubuntu description: "Install NXLog On Ubuntu using the .deb package" - name: nxlog_ubuntu_configure upload: nxlog/files/managed.conf destination: /opt/nxlog/etc/nxlog.d/managed.conf targets: ubuntu description: Uploaded Ubuntu Configuration File - name: restart_nxlog_ubuntu command: systemctl restart nxlog targets: ubuntu description: Restarting NXLog Service
-
Plan execution
To execute the plan, run the following command:
$ bolt plan run nxlog::nxlog_install -t all
- bolt
-
The executable located in
/usr/local/bin - plan
-
Instructs Puppet Bolt to execute a plan
- nxlog::nxlog_install
-
The plan reference definition consists of two parts,
nxlogis the module name and corresponds to the name of the directory we created earlier, andnxlog_installis the file’s name in theplansdirectory. - -t
-
The target servers. We used the
alloption, but you can specifylinuxto target only Linux hosts orwindowsto target only Windows hosts.