Page 1 of 1

Deploy GLPI Agent

Published: August 4, 2023 - 09:17
by SebR
Hello,

I'm trying to deploy the GLPI agent on our network. We tried using a GPO, but it didn't work.
I tried creating a package via WAPT, but we can't seem to insert the correct arguments (`/qn /i RUNNOW=1 SERVER="htt*://server/front/inventory.php")` in the Py file.
We saw that there's a GLPI package in WAPT, but we don't see how to add the arguments (server name and installation type).
Do you have any ideas, or does anyone have an example of how to build the package?
Thanks in advance for your help.
Sebastien

Re: Deploying GLPI Agent

Published: August 4, 2023 - 1:56 PM
by jorico
Hello Seb,

I installed the GLPI agent this way on my network, but I did not use the package from the repository, nor did I manage to integrate the arguments with the package from the store.

I added audit functions to check the status of the service.

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls

uninstallkey = ['{E1BE6C18-6BF4-1014-844A-F1F114E3EA24}']

def install():
    # Declaring local variables

    # Installing the software
    print("Installing: GLPI-Agent-1.4-x64.msi")
    run(r'MsiExec.exe /i GLPI-Agent-1.4-x64.msi /quiet SERVER=https://xxxxxxxxxxx  ADD_FIREWALL_EXCEPTION=1 SCAN_PROFILES=1 RUNNOW=1')
    print("Installation de GLPI-Agent-1.4 terminée")

def audit():

   if service_is_running('glpi-agent'):
    print("Le service GLPI Agent est démarré")
    return "OK"

   else:
    print("Le service GLPI Agent n'est pas démarré !")
    return "WARNING"

Re: Deploying GLPI Agent

Published: August 16, 2023 - 10:42
by blemoigne
Good morning,
It would be in this form:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *


def install():

    install_msi_if_needed(
        glob.glob("*.msi")[0], properties ='RUNNOW=1 SERVER="htt*://serveur/front/inventory.php"'    )
Bertrand

Re: Deploying GLPI Agent

Published: August 22, 2023 - 3:51 PM
by SeiyaGame
Good morning,

I would like to propose my solution which, while incorporating your ideas, also includes some improvements :D

Code: Select all

# -*- coding: utf-8 -*-

import glob
from setuphelpers import *

# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls

# https://glpi-agent.readthedocs.io/en/latest/installation/windows-command-line.html#command-line-parameters
properties = {
    "RUNNOW": 1,
    "ADDLOCAL": "feat_NETINV,feat_DEPLOY,feat_COLLECT", # ALL Or feat_AGENT,feat_NETINV,feat_DEPLOY,feat_COLLECT,feat_WOL
    "ADD_FIREWALL_EXCEPTION": 1,
    "AGENTMONITOR": 1,
    "SERVER": "http://URL_SERVER/marketplace/glpiinventory/",
}

def install():
    # Declaring local variables
    exe_file = glob.glob("*.msi")[0]

    # Installing the software
    print(f"Installing: {exe_file}")
    install_msi_if_needed(exe_file, properties=properties)

def audit():
    if service_installed("glpi-agent") and service_is_running("glpi-agent"):
        print("Service installed and started!")
        return "OK"
    else:
        print("Service is not installed and started !")
        return "ERROR"