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:

  1. First, create a project directory by issuing the following command:

    $ mkdir -p nxlog_bolt; cd nxlog_bolt; bolt project init

    It should result in the creation of three new files:

    • bolt-project.yaml

    • inventory.yaml

    • .gitignore (a hidden file)

  2. Next, create a module containing the NXLog Agent directory and two subdirectories, plans and files.

    Execute the following command to create the directories needed:

    $ mkdir -p modules/nxlog/{files,plans}
  3. Edit the bolt-project.yaml file:

    Example 1. Puppet Bolt project file

    bolt-project.yaml is created when you execute the bolt project init command. 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
  4. Update the inventory.yaml file:

    Example 2. Puppet Bolt inventory file

    Puppet Bolt uses this file to connect to the remote host and execute the specified plan.

    inventory.yaml
    groups:
      - name: linux
        targets:
          - uri: 192.168.1.10
            name: ubuntu
        config:
          transport: ssh
          ssh:
            user: root
            password: your_root_password
            host-key-check: false
  5. NXLog Agent configuration

    Example 3. NXLog Agent Puppet Bolt configuration example

    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.

    managed.conf
    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>
    managed.conf has to exist inside the files directory. The same applies to the downloaded NXLog Agent installation file. It is Puppet Bolt’s default technique for uploading files to remote hosts.
  6. 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.5.9781_debian10_amd64.tar.bz2.

    Place the NXLog Agent tar archive in the modules/nxlog/files directory 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 .deb files.

    • 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
Description of each component that comprises the command above
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, nxlog is the module name and corresponds to the name of the directory we created earlier, and nxlog_install is the file’s name in the plans directory.

-t

The target servers. We used the all option, but you can specify linux to target only Linux hosts or windows to target only Windows hosts.