Install Loginsight agent using Ansible
How to install Loginsight agent using a Ansible playbook onto Ubuntu or Photon OS machines.
- Create a directory called loginsight-agent
- Create a sub directory called files
- Copy the liagent install packages into the files folder
- Copy a liagent.ini into the files folder
- Copy the playbook into the loginsight-agent folder
- Adjust the playbook to reflect your host group
- Adjust the liagent.ini to match your Loginsight configuration
1root@workstation:~/ansible/loginsight-agent # ls -latr
2total 16
3drwxr-xr-x 6 root root 4096 Feb 4 10:16 ..
4drwxr-xr-x 2 root root 4096 Feb 4 11:24 files
5-rw-r--r-- 1 root root 1362 Feb 4 18:17 liagent.yml
6drwxr-xr-x 3 root root 4096 Feb 4 18:17 .
1root@workstation:~/ansible/loginsight-agent/files # ls -latr
2total 36160
3-rw-r--r-- 1 root root 9505854 Feb 4 10:18 VMware-Log-Insight-Agent-8.6.2-19075480.noarch.rpm
4-rw-r--r-- 1 root root 9587804 Feb 4 10:18 VMware-Log-Insight-Agent-8.6.2-19075480.bin
5-rw-r--r-- 1 root root 8450048 Feb 4 10:18 VMware-Log-Insight-Agent-8.6.2-19075480.msi
6-rw-r--r-- 1 root root 9467652 Feb 4 10:19 vmware-log-insight-agent_8.6.2-19075480_all.deb
7-rw-r--r-- 1 root root 2394 Feb 4 10:19 liagent.ini
8drwxr-xr-x 2 root root 4096 Feb 4 11:24 .
9drwxr-xr-x 3 root root 4096 Feb 4 18:17 ..
1vi ~/ansible/loginsight-agent/liagent.yml
1---
2- hosts: all
3
4 vars:
5 RPM: VMware-Log-Insight-Agent-8.6.2-19075480.noarch.rpm
6 DEB: vmware-log-insight-agent_8.6.2-19075480_all.deb
7 BIN: VMware-Log-Insight-Agent-8.6.2-19075480.bin
8 INI: liagent.ini
9
10 tasks:
11 - name: copy liagent rpm package
12 copy:
13 src: '/root/ansible/loginsight-agent/files/{{ RPM }}'
14 dest: /root/
15 register: copied
16 when: ansible_facts['os_family'] == "VMware Photon OS"
17
18 - name: copy liagent deb package
19 copy:
20 src: '/root/ansible/loginsight-agent/files/{{ DEB }}'
21 dest: /root/
22 register: copied
23 when:
24 - ansible_os_family == "Debian"
25 - ansible_distribution == "Ubuntu"
26
27 - name: install liagent rpm package
28 shell:
29 cmd: rpm -i /root/{{ RPM }}
30 when: ansible_facts['os_family'] == "VMware Photon OS"
31
32 - name: install liagent deb package
33 shell:
34 cmd: dpkg -i /root/{{ DEB }}
35 when:
36 - ansible_os_family == "Debian"
37 - ansible_distribution == "Ubuntu"
38
39 - name: copy ini file
40 copy:
41 src: '/root/ansible/loginsight-agent/files/{{ INI }}'
42 dest: "/etc/"
43 backup: yes
44 follow: yes
45 force: yes
46 register: copied
47
48 - name: restart liagent
49 shell:
50 cmd: systemctl restart liagentd.service
1vi ~/ansible/loginsight-agent/files/liagent.ini
1; VMware Log Insight Agent configuration. Please save as UTF-8 if you use non-ASCII names / values !
2; Actual configuration is this file joined with settings from server to form liagent-effective.ini
3; Note: Restarting the agent is not required after making a configuration change
4; Note: It may be more efficient to configure from server's Agents page !
5
6[server]
7hostname=LOGINSIGHT-FQDN
8
9; Hostname or IP address of your Log Insight server / cluster load balancer. Default:
10;hostname=LOGINSIGHT
11
12; Protocol can be cfapi (Log Insight REST API), syslog, syslog_udp. Default:
13proto=cfapi
14
15; Log Insight server port to connect to. Default ports for protocols:
16; syslog and syslog_udp: 514; syslog with ssl: 6514; cfapi: 9000; cfapi with ssl: 9543. Default:
17port=9543
18
19; SSL usage. Default:
20;ssl=no
21; Example of configuration with trusted CA:
22ssl=yes
23;ssl_ca_path=/etc/pki/tls/certs/ca.pem
24
25; Time in minutes to force reconnection to the server.
26; This option mitigates imbalances caused by long-lived TCP connections. Default:
27;reconnect=30
28
29; Allow the agent to receive central configuration from the server.
30; If disabled, only agent-side configuration will be applied. Default:
31;central_config=yes
32
33; FIPS mode.
34; Possible values are 1 or 0. Default:
35;ssl_fips_mode=1
36
37[logging]
38; Logging verbosity: 0 (no debug messages), 1 (essentials), 2 (verbose with more impact on performance).
39; This option should always be 0 under normal operating conditions. Default:
40;debug_level=0
41
42; Frequency to print agent dynamic information in minutes. Default:
43;stats_period=15
44
45; Allow the agent to automatically decrease dynamic information print period to 1 minute
46; in case if agent abnormal performance is detected.
47; If disabled, agent performance won't be monitored at all. Default:
48;smart_stats=no
49
50[storage]
51; Max local storage usage limit (data + logs) in MBs. Valid range: 100-2000 MB.
52;max_disk_buffer=200
53
54; Uncomment the appropriate section to collect system logs
55; The recommended way is to enable the Linux content pack from LI server
56;[filelog|syslog]
57;directory=/var/log
58;include=messages;messages.?;syslog;syslog.?
59
60[update]
61; Do not change this parameter
62package_type=deb
63
64
65; Enable automatic update of the agent. If enabled:
66; the agent will silently check for updates from the server and
67; if available will automatically download and apply the update.
68;auto_update=yes
In LAB environments you can add the following parameter to the liagent.ini file to accept any certificate.
1ssl_accept_any=yes
Run the playbook using the --check option
1ansible-playbook --check liagent.yml
Example Output:
1PLAY [all] *******************************************************************************************************************************************************************************************************************************************************************
2
3TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************************************************
4ok: [host01]
5ok: [host02]
6ok: [host03]
7ok: [host04]
8ok: [host05]
9
10TASK [copy liagent rpm package] **********************************************************************************************************************************************************************************************************************************************
11skipping: [host01]
12skipping: [host02]
13ok: [host03]
14ok: [host04]
15ok: [host05]
16
17TASK [copy liagent deb package] **********************************************************************************************************************************************************************************************************************************************
18ok: [host01]
19ok: [host02]
20skipping: [host03]
21skipping: [host04]
22skipping: [host05]
23
24TASK [install liagent rpm package] *******************************************************************************************************************************************************************************************************************************************
25skipping: [host01]
26skipping: [host02]
27skipping: [host03]
28skipping: [host04]
29skipping: [host05]
30
31TASK [install liagent deb package] *******************************************************************************************************************************************************************************************************************************************
32skipping: [host01]
33skipping: [host02]
34skipping: [host03]
35skipping: [host04]
36skipping: [host05]
37
38TASK [copy ini file] *********************************************************************************************************************************************************************************************************************************************************
39changed: [host01]
40changed: [host02]
41changed: [host03]
42ok: [host04]
43ok: [host05]
44
45TASK [restart liagent] *******************************************************************************************************************************************************************************************************************************************************
46skipping: [host01]
47skipping: [host02]
48skipping: [host03]
49skipping: [host04]
50skipping: [host05]
51
52PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************
53host01 : ok=3 changed=0 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0
54host02 : ok=3 changed=1 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0
55host03 : ok=3 changed=0 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0
56host04 : ok=3 changed=1 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0
57host05 : ok=3 changed=0 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0
If everything is as expected an no error occured you can run the playbook without --check to install the Loginsight agent.
1ansible-playbook liagent.yml
Afterwards verifiy in Loginsight if all new install agents are listen in Adminsitration --> Agents section.