{{tag>Brouillon Déploiement Windows Bash}}
= Install de FusionInventory
Voir :
* [[Notes OCS Inventory|OCS Inventory]]
* GLPI
* https://fr.wikipedia.org/wiki/FusionInventory
* http://fusioninventory.org/
* http://mohamed.hamid.free.fr/pdf/glpi.pdf
* http://www.dsfc.net/logiciel-libre/glpi/installation-glpi-fusioninventory-debian-8-jessie/
* http://www.tecmint.com/glpi-it-asset-management-with-fusion-inventory-in-debian-linux/3/
== Install de FusionInventory-Agent
=== Notes sur l'agent
L'agent peut être en mode Daemon (via service), ou lancé par Cron
=== sur Debian/Ubuntu
apt-get install fusioninventory-agent
''/etc/default/fusioninventory-agent''
# MODE can be either "daemon" or "cron"
#MODE=cron
MODE=daemon
''/etc/fusioninventory/agent.cfg''
server = http://192.168.56.12:81/plugins/fusioninventory/
local = /tmp
httpd-trust = 127.0.0.1,192.168.56.0/24
logfile = /var/log/fusioninventory.log
#debug = 2
#tag = Debian_8
# /usr/bin/fusioninventory-agent --list-tasks
no-task = WakeOnLan,ESX
# maximum log file size, in MB
logfile-maxsize = 100
Agent en mode Cron
En root
crontab -e
#*/1 * * * * /usr/bin/fusioninventory-agent
*/1 * * * * NO_PROXY=fusion.lan /usr/bin/fusioninventory-agent
==== Agent en mode Daemon
Écoute sur le port TCP 62354 par défaut
Il est possible de se connecter à l'agent en HTTP.
http://192.168.56.12:62354
http://192.168.56.12:62354/now
''/now'' pour forcer l'inventaire.
Voir les valeurs
''/etc/fusioninventory/agent.cfg''
# network port to listen to
httpd-port = 62354
# trust requests without authentication token
httpd-trust = 127.0.0.1,192.168.56.0/24
systemctl restart fusioninventory-agent
Pour forcer l'agent à remonter l'inventaire au serveur
curl http://127.0.0.1:62354/now
==== Ménage
systemctl stop fusioninventory-agent
pkill -f fusioninventory-agent
> /var/log/fusioninventory.log
rm -rf /var/lib/fusioninventory-agent/*
rm -f $(grep '^local =' /etc/fusioninventory/agent.cfg |tail -1 |awk '{print $3}')/*.ocs
=== Install de l'agent FusionInventory sur RedHat6 et RedHat7
Ligne à ajouter
''/etc/fusioninventory/agent.cfg''
server = http://192.168.10.22/glpi-sysadmins/plugins/fusioninventory/
Ligne à ajouter
''/etc/sysconfig/fusioninventory-agent''
OCSMODE[0]=cron
Ce qui donne :
''/etc/sysconfig/fusioninventory-agent''
PATH=/sbin:/bin:/usr/sbin:/usr/bin
FUSINVOPT='--debug --rpc-trust-localhost'
OCSMODE[0]=none
OCSPAUSE[0]=120
OCSTAG[0]=
OCSMODE[0]=cron
Il faut activer le service **fusioninventory-agent**
En plus du service, il y a une crontab :
Elle vient avec le paquet, je mets le code ici car ca fait longtemps que je n'ai pas fait appel à des tableaux associatifs en bash
''/etc/cron.hourly/fusioninventory-agent''
#!/bin/bash
NAME=fusioninventory-agent
LOG=/var/log/$NAME/$NAME.log
exec >>$LOG 2>&1
[ -f /etc/sysconfig/$NAME ] || exit 0
source /etc/sysconfig/$NAME
export PATH
i=0
while [ $i -lt ${#OCSMODE[*]} ]
do
if [ ${OCSMODE[$i]:-none} == cron ]; then
OPTS=
if [ ! -z "${OCSPAUSE[$i]}" ]; then
OPTS="--wait ${OCSPAUSE[$i]}"
fi
if [ ! -z "${OCSTAG[$i]}" ]; then
OPTS="$OPTS --tag=${OCSTAG[$i]}"
fi
if [ "z${OCSSERVER[$i]}" = 'zlocal' ]; then
# Local inventory
OPTS="$OPTS --local=/var/lib/$NAME"
elif [ ! -z "${OCSSERVER[$i]}" ]; then
# Remote inventory
OPTS="$OPTS --lazy --server=${OCSSERVER[$i]}"
fi
echo "[$(date '+%c')] Running $NAME $OPTS"
/usr/bin/$NAME $FUSINVOPT --logfile=$LOG $OPTS
fi
((i++))
done
echo "[$(date '+%c')] End of cron job ($PATH)"
==== PB sous RedHat7 avec le dépôt officiel de FusionInventory
Voir http://fusioninventory.org/documentation/agent/installation/linux/rhel.html
yum install fusioninventory-agent fusioninventory-agent-task-inventory
Modules complémentaires chargés : fastestmirror, security
Configuration du processus d'installation
Loading mirror speeds from cached hostfile
* base: mirror.plusserver.com
* epel: mirror.karneval.cz
* extras: ftp.ciril.fr
* updates: miroir.univ-paris13.fr
Résolution des dépendances
--> Lancement de la transaction de test
---> Package fusioninventory-agent.noarch 0:2.1.14-2.el6 will be mis à jour
---> Package fusioninventory-agent.noarch 0:2.3.18-2.1 will be an update
--> Traitement de la dépendance : perl(File::Which) pour le paquet : fusioninventory-agent-2.3.18-2.1.noarch
--> Traitement de la dépendance : perl(Text::Template) pour le paquet : fusioninventory-agent-2.3.18-2.1.noarch
--> Traitement de la dépendance : perl(IO::Socket::SSL) pour le paquet : fusioninventory-agent-2.3.18-2.1.noarch
--> Traitement de la dépendance : perl(Data::Structure::Util) pour le paquet : fusioninventory-agent-2.3.18-2.1.noarch
--> Traitement de la dépendance : perl(XML::TreePP) pour le paquet : fusioninventory-agent-2.3.18-2.1.noarch
---> Package fusioninventory-agent-task-inventory.noarch 0:2.3.18-2.1 will be installé
--> Traitement de la dépendance : perl(Time::Piece) pour le paquet : fusioninventory-agent-task-inventory-2.3.18-2.1.noarch
--> Lancement de la transaction de test
---> Package fusioninventory-agent.noarch 0:2.3.18-2.1 will be an update
--> Traitement de la dépendance : perl(Data::Structure::Util) pour le paquet : fusioninventory-agent-2.3.18-2.1.noarch
---> Package perl-File-Which.noarch 0:1.09-2.el6 will be installé
---> Package perl-IO-Socket-SSL.noarch 0:1.31-3.el6 will be installé
--> Traitement de la dépendance : perl(Net::LibIDN) pour le paquet : perl-IO-Socket-SSL-1.31-3.el6.noarch
---> Package perl-Text-Template.noarch 0:1.45-3.el6 will be installé
---> Package perl-Time-Piece.x86_64 0:1.15-141.el6_7.1 will be installé
---> Package perl-XML-TreePP.noarch 0:0.39-3.el6 will be installé
--> Lancement de la transaction de test
---> Package fusioninventory-agent.noarch 0:2.3.18-2.1 will be an update
--> Traitement de la dépendance : perl(Data::Structure::Util) pour le paquet : fusioninventory-agent-2.3.18-2.1.noarch
---> Package perl-Net-LibIDN.x86_64 0:0.12-3.el6 will be installé
--> Résolution des dépendances terminée
Erreur : Paquet : fusioninventory-agent-2.3.18-2.1.noarch (home_guillomovitch)
Requiert : perl(Data::Structure::Util)
Vous pouvez essayer d'utiliser --skip-broken pour contourner le problème
Vous pouvez essayer d'exécuter : rpm -Va --nofiles --nodigest
''fusioninventory.repo''
[home_guillomovitch]
name=guillomovitch's Home Project (CentOS_7)
type=rpm-md
baseurl=http://download.opensuse.org/repositories/home:/guillomovitch/CentOS_7
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/home:/guillomovitch/CentOS_7/repodata/repomd.xml.key
enabled=1
===== Dans mon cas
Avec Epel
* **fusioninventory-agent** seul est suffisant, plus besoin de **fusioninventory-agent-task-inventory**
Avec le dépôt officiels
* **perl(Data::Structure::Util)** est vraiment une dépendance nécessaire.
Si la version de l'Epel n'ai pas suffisante, une autre solution est :
d'aller ici
* http://www.rpmfind.net/linux/RPM/dag/redhat/el6/x86_64/perl-Data-Structure-Util-0.15-1.el6.rf.x86_64.html
Pour télécharger :
* ftp://fr2.rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/perl-Data-Structure-Util-0.15-1.el6.rf.x86_64.rpm
===== Solution
Dans le mesure du possible privilégier l'activation seulement des dépôts (/etc/yum.repos.d/) RedHat/CentOS officiel avec EPEL seulement.
== Note install FusionInventory Serveur
CREATE DATABASE glpidb;
-- CREATE USER 'glpiusr'@'localhost' IDENTIFIED BY 'toor';
GRANT ALL PRIVILEGES ON glpidb.* TO "glpiusr"@"localhost" IDENTIFIED BY 'toor';
FLUSH PRIVILEGES;
apt-get install fusioninventory-agent-task-deploy glpi
apt-get install php-mdb2 php5-cli #php-mdb2-driver-mysql
cd /var/www/
wget https://github.com/glpi-project/glpi/releases/download/0.90.5/glpi-0.90.5.tar.gz
tar xf glpi-0.90.5.tar.gz
rm glpi-0.90.5.tar.gz
cd /var/www/glpi/plugins/
wget https://github.com/fusioninventory/fusioninventory-for-glpi/releases/download/glpi090%2B1.4/fusioninventory-for-glpi_0.90.1.4.tar.gz
tar xf fusioninventory-for-glpi_0.90.1.4.tar.gz
rm fusioninventory-for-glpi_0.90.1.4.tar.gz
chown -R www-data:www-data /var/www/glpi/
''/etc/apache2/conf-available/glpi.conf''
Alias /glpi /var/www/glpi
DirectoryIndex index.php
Options FollowSymLinks
AllowOverride Limit Options FileInfo
# some people prefer a simple URL like http://glpi.example.com
#
# DocumentRoot /usr/share/glpi
# ServerName glpi.example.com
#
a2enconf glpi
ou dans notre exemple
''/etc/apache2/sites-available/glpi.conf''
ServerName fusion.lan
Redirect permanent / https://fusion.lan/
ServerName fusion.lan
DocumentRoot /var/www/glpi
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/fusion.lan.crt
SSLCertificateKeyFile /etc/apache2/ssl/fusion.lan.key
DirectoryIndex index.php
Options FollowSymLinks
AllowOverride Limit Options FileInfo
ErrorLog ${APACHE_LOG_DIR}/error-glpi.log
CustomLog ${APACHE_LOG_DIR}/access-glpi.log combined
a2ensite glpi
http://192.168.56.12/glpi/ \\
utilisateur : glpi \\
pass : glpi \\
Default logins / passwords are:
glpi/glpi for the administrator account
tech/tech for the technician account
normal/normal for the normal account
post-only/postonly for the postonly account
Install de la crontab
su - www-data -s /bin/bash
EDITOR=vim crontab -e
* * * * * /usr/bin/php /var/www/glpi/front/cron.php &>/dev/null
=== Interface Web
Configuration
Setup - Plugins - FusionInventory
FusionInventory : Install
FusionInventory : Enable
Administration - Entities
Root entity
Fusioninventory
Service URL : http://192.168.56.12:81
Setup - Plugins - FusionInventory
FusionInventory : FusionInventory
Agents modules - Package deployment
"Activation"
update
Connaître la date du dernier contact en l'agent
Assets - Computers
(select an computer)
Computer - **Last inventory**
== Pb déploiement sous GNU/Linux
''/var/log/fusioninventory.log''
[Tue Sep 20 15:33:02 2016][debug] Run: dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
dpkg: error: 2 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
[Tue Sep 20 15:33:02 2016][debug] exitStatus: 2
[Tue Sep 20 15:33:02 2016][debug] dpkg: warning: 'ldconfig' not found in PATH or not executable
[Tue Sep 20 15:33:02 2016][debug] dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
[Tue Sep 20 15:33:02 2016][debug] dpkg: error: 2 expected programs not found in PATH or not executable
[Tue Sep 20 15:33:02 2016][debug] Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
[Tue Sep 20 15:33:02 2016][debug] --------------------------------
[Tue Sep 20 15:33:02 2016][debug] exit status: `2'
[Tue Sep 20 15:33:02 2016][debug] exitStatus: 2
[Tue Sep 20 15:33:02 2016][debug] Free space on /var/lib/fusioninventory-agent/https:__fusion.lan_plugins_fusioninventory_/deploy: 928
[Tue Sep 20 15:33:02 2016][debug] running task Inventory
Le pb dans l'exemple suivant, et que le caractère '*' n'est pas interprété (car bash n'est pas appelé)
dpkg -i /tmp/deploy/*.deb
Le pb dans l'exemple suivant, et que les variables d’environnement tel que le PATH ne sont pas chargées.
dpkg -i /tmp/deploy/atop.deb
=== Solution / Astuce
''/usr/local/bin/execw.sh''
#! /bin/bash
set -o nounset
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#export LANG=fr_FR.UTF-8
export LANG=C
export DEBIAN_FRONTEND=noninteractive
exec >> /var/log/fusioninventory-exec.log
exec 2>> /var/log/fusioninventory-exec.err
echo $(LANG=C date +%'Y-%m-%d %H:%M')
#exec "$@"
echo "$@" |bash -s --
Plus qu'à préfixer ma commande par ''/usr/local/bin/execw.sh ''
/usr/local/bin/execw.sh dpkg -i /tmp/deploy/*.deb