AD-Verknüpfung > Paketgruppen

Fragen zu WAPT-Paketen / Anfragen und Hilfe bezüglich WAPT-Paketen.
Forumregeln
Community-Forumregeln
* Englischer Support auf www.reddit.com/r/wapt
* Französischer Community-Support ist in diesem Forum verfügbar.
* Bitte kennzeichnen Sie gelöste Themen mit [GELÖST].
* Bitte bearbeiten Sie keine Themen, die mit [GELÖST] markiert sind. Erstellen Sie stattdessen ein neues Thema und verweisen Sie auf das alte.
* Geben Sie die installierte WAPT-Version, die vollständige Versionsnummer und die Build-Nummer (2.2.1.11957 / 2.2.2.12337 / usw.) sowie die Enterprise-/Discovery-Edition an.
* Versionen 1.8.2 und älter werden nicht mehr unterstützt. Fragen zu Version 1.8.2 werden nur beantwortet, wenn sie sich auf ein Upgrade auf eine unterstützte Version (2.1, 2.2 usw.) beziehen.
* Geben Sie das Server-Betriebssystem (Linux/Windows) und die Version (Debian Buster/Bullseye – CentOS 7 – Windows Server 2012/2016/2019) an.
* Geben Sie gegebenenfalls das Betriebssystem des Administrations-/Paketerstellungsrechners und des Rechners mit dem problematischen Agenten an (Windows 7/10/11/Debian 11/etc.).
* Vermeiden Sie es, mehrere Fragen in einem Thema zu stellen, da diese sonst möglicherweise ignoriert werden. Falls mehrere Themen relevant sind, erstellen Sie bitte separate Themen, vorzugsweise nacheinander und nicht gleichzeitig (d. h. vermeiden Sie Spam im Forum).
* Fügen Sie Code-Snippets, Screenshots und andere Bilder direkt in Ihren Beitrag ein. Links zu Pastebin, Bitly und anderen Drittanbieterseiten werden systematisch entfernt.
* Wie in jedem Community-Forum erfolgt die Unterstützung freiwillig durch die Mitglieder. Für kommerziellen Support kontaktieren Sie bitte den Vertrieb von Tranquil IT unter +44 2 40 97 57 55.
Benutzeravatar
fbetil
Nachrichten: 11
Anmeldung: 16. März 2017 – 15:45 Uhr

17. März 2017 - 16:07 Uhr

Hallo,
ich bin in einem anderen Forum auf dieses Problem gestoßen. Es ist nun behoben und funktioniert.
Gibt es eine Möglichkeit, die Suche nach Active Directory-Gruppen auf den Arbeitsstationen automatisch (z. B. per Cronjob) durchzuführen, sodass ich nicht mehr per Rechtsklick suchen muss?
Vielen Dank im Voraus,
Florian
Benutzeravatar
htouvet
WAPT-Experte
Nachrichten: 436
Anmeldung: 16. März 2015 - 10:48 Uhr
Kontakt:

17. März 2017 – 17:21 Uhr

Ja, dafür gibt es ein Skript:
https://github.com/tranquilit/WAPT/blob ... l_hosts.py

Kopieren Sie diese Datei in das Wapt-Verzeichnis Ihres Verwaltungsrechners.
und das Skript ausführen

Code: Alle auswählen

c:\wapt\waptpython c:\wapt\update_all_hosts.py -c %LOCALAPPDATA%\waptconsole\waptconsole.ini
Sie können mit der gleichen Methode auch ein "Basis"-Paket zu allen Ihren Maschinen hinzufügen.
Ruhige IT
Benutzeravatar
fbetil
Nachrichten: 11
Anmeldung: 16. März 2017 – 15:45 Uhr

20. März 2017 - 10:03 Uhr

Hallo und vielen Dank.
Zur Information: Ich musste die Funktion get_computer_groups wie folgt modifizieren (siehe https://github.com/tranquilit/WAPT/comm...4ad1c1dcb1):

Code: Alle auswählen

def get_computer_groups(computername):
    """Try to finc the computer in the Active Directory
        and return the list of groups
    """
    groups = []
    computer = active_directory.find_computer(computername)
    if computer:
        computer_groups = computer.memberOf
        if computer_groups:
            if not isinstance(computer_groups,(tuple,list)):
                computer_groups = [computer_groups]
            for group in computer_groups:
                # extract first component of group's DN
                cn = group.split(',')[0].split('=')[1]
                groups.append(cn.lower())
    return groups
zu der ich die Umwandlung in Kleinbuchstaben hinzugefügt habe.
Guten Tag,
Benutzeravatar
htouvet
WAPT-Experte
Nachrichten: 436
Anmeldung: 16. März 2015 - 10:48 Uhr
Kontakt:

20. März 2017 - 10:08 Uhr

Danke für das Feedback :) , ich werde es auf GitHub hochladen.

Hubert
Ruhige IT
Benutzeravatar
fbetil
Nachrichten: 11
Anmeldung: 16. März 2017 – 15:45 Uhr

29. Mai 2017 - 11:38 Uhr

Hallo,
zur Information: In Version 1.3.12.13 schlägt die Funktion zum Importieren von AD-Gruppen als Abhängigkeit fehl, wenn die Groß-/Kleinschreibung nicht übereinstimmt (in WapT wird die Groß-/Kleinschreibung erzwungen, was in unserem AD nicht der Fall ist).
Könnten Sie bitte die Groß-/Kleinschreibung in der Funktion `add_ads_groups` des Pakets `waptdevutils.py` ignorieren?
Vielen Dank im Voraus
. Mit freundlichen Grüßen
Benutzeravatar
fbetil
Nachrichten: 11
Anmeldung: 16. März 2017 – 15:45 Uhr

12. März 2019 - 22:52 Uhr

htouvet schrieb: 17. März 2017 - 17:21 Uhr Ja, dafür gibt es ein Skript:
https://github.com/tranquilit/WAPT/blob ... l_hosts.py

Kopieren Sie diese Datei in das Wapt-Verzeichnis Ihres Verwaltungsrechners.
und das Skript ausführen

Code: Alle auswählen

c:\wapt\waptpython c:\wapt\update_all_hosts.py -c %LOCALAPPDATA%\waptconsole\waptconsole.ini
Sie können mit der gleichen Methode auch ein "Basis"-Paket zu allen Ihren Maschinen hinzufügen.
Guten Morgen,
Nach dem Update auf Version 1.6.2.7 funktioniert dieses Skript nicht mehr. Gibt es eine Alternative für die neueren Versionen?
Vielen Dank im Voraus
Aufrichtig,
Florian
Benutzeravatar
fbetil
Nachrichten: 11
Anmeldung: 16. März 2017 – 15:45 Uhr

15. März 2019 – 17:09 Uhr

Guten Morgen,

Schließlich funktioniert es nach einer kleinen Änderung des Codes des Skripts "update_all_hosts.py" (in Version 1.7.3.5):

Code: Alle auswählen

#!/usr/bin/python
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------
#    This file is part of WAPT
#    Copyright (C) 2013  Tranquil IT Systems http://www.tranquil.it
#    WAPT aims to help Windows systems administrators to deploy
#    setup and update applications on users PC.
#
#    WAPT is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    WAPT is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with WAPT.  If not, see <http://www.gnu.org/licenses/>.
#
# ---------------------------------------------------------------------
#
# Sample script which updates dependencies of all hosts registered on waptserver
# - append a list of basic packages that all hosts should install
# - query active directory for the groups of each host.
#     if the CN of the group match a wapt package, the package is appended as dependency
#
#  This allows to install packages based on computers active directory memberships
#------------------------------------------------
"""
    Sample script which updates dependencies of all hosts registered on waptserver
     - append a list of basic packages that all hosts should install
     - query active directory for the groups of each host.
         if the CN of the group match a wapt package, the package is appended as dependency

    This allows to install packages based on computers active directory memberships
"""

import sys,os
from common import *
from waptpackage import *
from tempfile import mkdtemp
from shutil import rmtree
from getpass import getpass
import active_directory

from optparse import OptionParser

def ensure_list(csv_or_list,ignore_empty_args=True):
    """if argument is not a list, return a list from a csv string"""
    if csv_or_list is None:
        return []
    if isinstance(csv_or_list,tuple):
        return list(csv_or_list)
    elif not isinstance(csv_or_list,list):
        if ignore_empty_args:
            return [s.strip() for s in csv_or_list.split(',') if s.strip() != '']
        else:
            return [s.strip() for s in csv_or_list.split(',')]
    else:
        return csv_or_list

def get_computer_groups(computername):
    """Try to finc the computer in the Active Directory
        and return the list of groups
    """
    groups = []
    computer = active_directory.find_computer(computername)
    if computer:
        computer_groups = computer.memberOf
        if computer_groups:
            if not isinstance(computer_groups,(tuple,list)):
                computer_groups = [computer_groups]
            for group in computer_groups:
                # extract first component of group's DN
                cn = group.split(',')[0].split('=')[1]
                groups.append(cn)
    return groups
	
if __name__ == '__main__':
    parser=OptionParser(usage=__doc__)
    parser.add_option("-p","--password", dest="password", default='', help="Server password")
    parser.add_option("-g","--groups", dest="groups", default='', help="List of packages to append to all hosts (default: %default)")
    parser.add_option("-c","--config", dest="config", default=os.path.join(os.path.dirname(sys.argv[0]),'wapt-get.ini') , help="Config file full path (default: %default)")
    parser.add_option("-d","--dry-run", dest="dry_run",    default=False, action='store_true', help="Dry run (default: %default)")
    (options,args) = parser.parse_args()
    
    server_password = options.password
    
    # put at least these packages to all computers
    base_packages = ensure_list(options.groups)

    # initialise wapt api with local config file
    wapt = Wapt(config_filename = options.config)
    wapt.dbpath=':memory:'

    # get current packages status from repositories
    wapt.update()

    for package in base_packages:
        if not wapt.is_available(package):
            raise Exception('Package %s is not available in your repository.'%package)

    # get the collection of hosts from waptserver inventory
    hosts =  wapt.waptserver.get('api/v1/hosts',auth=('admin',server_password))

    for h in hosts['result']:
        try:
            hostname = h['computer_fqdn']

            groups = base_packages + get_computer_groups(h['computer_name'])

            print 'Computer %s: %s ' % (hostname, groups)
            
            # try to get comp

            # now update the host package : download and append missing packages
            tmpdir = mkdtemp()
            
            try:
                package = wapt.edit_host(hostname,target_directory = tmpdir)
                control = package
                depends =  ensure_list(control.depends)
                additional = [ group for group in groups if not group in depends and wapt.is_available(group) ]

                #there ara additional packages to add as dependencies to host package
                if additional:
                    control.depends = ','.join(depends+additional)
                    control.save_control_to_wapt(package['sourcespath'])
                    # build and post the new wapt package
                    if options.dry_run:
                        result = wapt.build_package(package['sourcespath'])
                    else:
                        result = wapt.build_upload(package['sourcespath'], wapt_server_user='admin', wapt_server_passwd=server_password, private_key_passwd=server_password,inc_package_release=True)[0]
                        
                    print " done, new packages : %s" % (','.join(additional))
                    if os.path.isfile(result):
                        os.remove(result)
                else:
                    print " skipped, current packages: %s" % (','.join(depends))
            finally:
                # cleanup of temporary
                if os.path.isdir(tmpdir):
                    rmtree(tmpdir)
                    
        except Exception as e:
            print " error %s" % e
            raise

Aufrichtig,

Florian
Gesperrt