Outils pour utilisateurs

Outils du site


blog

Install de Python 2.7 par RPM sur RHEL6 pour Ansible

Voir : AAP managed hosts Python requirements

Voir aussi :

  • INTERPRETER_PYTHON_FALLBACK

Sources des fichiers :

$ rpm -Uvh python27-python-2.7.17-2.el6.x86_64.rpm python27-python-libs-2.7.17-2.el6.x86_64.rpm
error: Failed dependencies:
        python27-runtime is needed by python27-python-2.7.17-2.el6.x86_64
        python27-python-setuptools is needed by python27-python-2.7.17-2.el6.x86_64
        python27-python-pip is needed by python27-python-2.7.17-2.el6.x86_64
        python27-runtime is needed by python27-python-libs-2.7.17-2.el6.x86_64
sudo rpm -Uvh --nodeps python27-python-*
mkdir -p /usr/local/bin/

Wrapper vers Python

/usr/local/bin/python2.7

#! /bin/sh
 
export LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64
exec /opt/rh/python27/root/usr/bin/python2.7 "$@"
chmod -R a+rx /usr/local/bin/

Ansible

roles/install_python27_for_rhel6/tasks/main.yml

- name: copy rpm files
  stat: path=/opt/PY27/bin/python2.7
  register: stat_tep10_python27

- name: block install python27
  when:
    - ansible_distribution == "RedHat"
    - ansible_distribution_major_version == "6"
    - ansible_machine == "x86_64"
    - not stat_tep10_python27.stat.exists
  block:
    - name: copy rpm files
      get_url:
        url: "{{ item }}"
        dest: /tmp/
      with_items:
        - https://registry.acme.local:443/artifactory/plop/Linux/Python27_RHEL6/python27-python-2.7.17-2.el6.x86_64.rpm
        - https://registry.acme.local:443/artifactory/plop/Linux/Python27_RHEL6/python27-python-libs-2.7.17-2.el6.x86_64.rpm
      delegate_to: localhost

    - name: copy rpm files
      copy:
        remote_src: false
        src: "{{ item }}"
        dest: /tmp/
      with_items:
        - /tmp/python27-python-2.7.17-2.el6.x86_64.rpm
        - /tmp/python27-python-libs-2.7.17-2.el6.x86_64.rpm
 
    # - name: install rpm
    #   become: true
    #   yum:
    #     install_weak_deps: true
    #     name:
    #       - /tmp/python27-python-2.7.17-2.el6.x86_64.rpm
    #       - /tmp/python27-python-libs-2.7.17-2.el6.x86_64.rpm

    - name: install rpm packages
      become: true
      command: rpm -U --nodeps /tmp/python27-python-2.7.17-2.el6.x86_64.rpm /tmp/python27-python-libs-2.7.17-2.el6.x86_64.rpm

    - name: mkdir /opt/PY27/bin/
      become: true
      file:
        path: /opt/PY27/bin/
        owner: root
        group: root
        mode: "0755"
        state: directory

    - name: create wrapper
      become: true
      copy:
        content: |
          #! /bin/sh
 
          export LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64
          exec /opt/rh/python27/root/usr/bin/python2.7 "$@"
        dest: /opt/PY27/bin/python2.7
        mode: "0755"
        owner: root
        group: root
2025/03/24 15:06

Install de ppa launchpad sous Debian

Exemple avec indicator-stickynotes

# apt-get install python-software-properties
apt-get install software-properties-common
add-apt-repository ppa:umang/indicator-stickynotes
apt-get update

Si le update ne passe pas on jette un œil à

http://ppa.launchpad.net/umang/indicator-stickynotes/ubuntu/dists/

sed -i -e 's/jessie/wily/' /etc/apt/sources.list.d/umang-indicator-stickynotes-jessie.list
apt-get update 
apt-get install indicator-stickynotes
/etc/apt/sources.list.d/umang-indicator-stickynotes-jessie.list
#deb http://ppa.launchpad.net/umang/indicator-stickynotes/ubuntu jessie main
deb http://ppa.launchpad.net/umang/indicator-stickynotes/ubuntu wily main
# deb-src http://ppa.launchpad.net/umang/indicator-stickynotes/ubuntu jessie main

Pb

Err AttributeError: 'NoneType' object has no attribute 'people'
# add-apt-repository ppa:vincent-vandevyvre/vvv                                                                                                                                  
Traceback (most recent call last):                                                                                                      
  File "/usr/bin/add-apt-repository", line 362, in <module>         
    sys.exit(0 if addaptrepo.main() else 1)
                  ^^^^^^^^^^^^^^^^^                                 
  File "/usr/bin/add-apt-repository", line 345, in main
    shortcut = handler(source, **shortcut_params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/shortcuts.py", line 40, in shortcut_handler                                                                                         
    return handler(shortcut, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                         
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 86, in __init__                                                                                                       
    if self.lpppa.publish_debug_symbols:                                                                                                          
       ^^^^^^^^^^                                                                                                                                             
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 126, in lpppa                                                                                                         
    self._lpppa = self.lpteam.getPPAByName(name=self.ppaname)                                  
                  ^^^^^^^^^^^                                                                                                                                 
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 113, in lpteam                                                                                                        
    self._lpteam = self.lp.people(self.teamname)                                                                                                                             
                   ^^^^^^^^^^^^^^                                                                                                                                                             
AttributeError: 'NoneType' object has no attribute 'people'
Solution
apt-get install python3-launchpadlib  
2025/03/24 15:06

Install de FusionInventory

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(DataStructureUtil) est vraiment une dépendance nécessaire.

Si la version de l'Epel n'ai pas suffisante, une autre solution est : d'aller ici

Pour télécharger :

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
 
<Directory /var/www/glpi>
  DirectoryIndex index.php
  Options FollowSymLinks
  AllowOverride Limit Options FileInfo
</Directory>
 
# some people prefer a simple URL like http://glpi.example.com
#<VirtualHost 1.2.3.4>
#  DocumentRoot /usr/share/glpi
#  ServerName glpi.example.com
#</VirtualHost>
a2enconf glpi

ou dans notre exemple

/etc/apache2/sites-available/glpi.conf

<VirtualHost *:80>
    ServerName fusion.lan
    Redirect permanent / https://fusion.lan/
</VirtualHost>
 
<VirtualHost *:443>
    ServerName fusion.lan
    DocumentRoot /var/www/glpi
 
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/fusion.lan.crt
    SSLCertificateKeyFile /etc/apache2/ssl/fusion.lan.key
 
  <Directory /var/www/glpi>
    DirectoryIndex index.php
    Options FollowSymLinks
    AllowOverride Limit Options FileInfo
  </Directory>
 
    ErrorLog ${APACHE_LOG_DIR}/error-glpi.log
    CustomLog ${APACHE_LOG_DIR}/access-glpi.log combined
</VirtualHost>
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
2025/03/24 15:06

Install de clamav sur redhat7 ou centos7

Remarque avant l'install

Ne pas activer le dépôt rpmforge, au risque d'avoir des conflits de /usr/lib64/libclamav.so.6 /usr/lib64/libclamav.so.7 lors de l'install des paquets liés à clam.

/etc/yum.repos.d/rpmforge.repo

[rpmforge]
enabled = 0

Il est préférable de ne pas utiliser le vieux paquet clamd

Install

Source https://doc.owncloud.org/server/7.0/admin_manual/configuration/antivirus_configuration.html

yum install clamav clamav-scanner clamav-scanner-systemd clamav-server clamav-server-systemd clamav-update

/etc/freshclam.conf

DatabaseDirectory /var/lib/clamav
UpdateLogFile /var/log/freshclam.log
LogFileMaxSize 2M
LogSyslog yes
DNSDatabaseInfo current.cvd.clamav.net
DatabaseMirror db.fr.clamav.net
DatabaseMirror database.clamav.net

On met à jour la base de donnée antiviral

freshclam

/etc/clamd.d/scan.conf

LogFile /var/log/clamd.scan
LogSyslog yes
User clamscan
AllowSupplementaryGroups yes
LogFileMaxSize 0
LogTime yes
TemporaryDirectory /var/tmp
DatabaseDirectory /var/lib/clamav
LocalSocket /tmp/clamd.socket
TCPSocket 3310
TCPAddr 127.0.0.1
MaxThreads 50
 
#FixStaleSocket yes
#MaxConnectionQueueLength 30
#ReadTimeout 300
#ScanPE yes
#ScanELF yes
#DetectBrokenExecutables yes
#ScanOLE2 yes
#ScanMail yes
#ScanArchive yes
#ArchiveBlockEncrypted no
touch /var/log/clamd.scan
chown clamscan:clamscan /var/log/clamd.scan
systemctl enable clamd@scan.service
systemctl start clamd@scan.service

Debug en cas de pb

Pour tester, si le service ne veut pas démarrer

On s'assure que le service soit bien stoppé

systemctl stop clamd@scan.service

Comme dans notre fichier de conf on a :

/etc/clamd.d/scan.conf

User clamscan

On utilise le compte clamscan

su - clamscan -s /bin/bash

On test

/usr/sbin/clamd -c /etc/clamd.d/scan.conf --nofork=yes
2025/03/24 15:06

Inotify - Incrontab - Déclencher une action automatiquement à l'arrivé de nouveaux fichiers

Installation

apt-get install incron

Ajout de l’utilisateur jean à la liste des utilisateurs autorisé à faire des incron

echo jean >> /etc/incron.allow

Utiliser votre éditeur favori (vim, nano….)

su - jean
export EDITOR=vim
incrontab -e
/home/jean/partage/GO IN_CREATE /home/jean/partage/AUTOEXEC.sh

L'incron est enregistré dans /var/spool/incron/jean

L'ajout de n'importe quel fichier dans /home/jean/partage/GO lancera le script /home/jean/partage/AUTOEXEC.sh (le script doit être exécutable et la partition ne doit pas être en noexec)

2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki