Index of /staff/davidn/spacewalk-stuff

Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory - [TXT] centos-errata.cfg 28-May-2010 16:48 1.2K [TXT] centos-errata.py.txt 28-May-2010 16:48 41K [TXT] test-archive.txt 13-May-2010 12:09 110K [TXT] test-digest.txt 13-May-2010 12:09 18K
Script to import centos-announce messages into a spacewalk server

Script to import centos-announce messages into a spacewalk server

Overview

ObDisclaimer: This script is somewhat rough around the edges and may well eat your cat. Use at own risk!

This tool will take a collection of postings from the centos-announce mailing list. It can accept a digest or a decompressed pipermail archive downloaded from the list archive pages, convert them to basic errata, upload them to a spacewalk server and publish them to a named channel which contains the relevant update packages.

Installation

  1. Download the two files at the end onto a client machine with access to the spacewalk server and to an up to date local centos mirror. The machine from which you push packages should be fine
  2. Rename centos-errata.py.txt to centos_errata.py and make it executable.
  3. Customize centos-errata.cfg for your organization. See Config Options for details.
    1. Config options

      Options can be specified in a configuration file or on the command line. The basic config file looks like this:

      [centos errata]
      #Required to identify applicable messages on the centos-announce mailing list
      version=5
      #Useful for interpolation below, not used by tool itself
      release=4
      #If true the script will attempt to use the Redhat Network to populate the errata description
      scrape_rhn=False
      
      [spacewalk]
      server=spacewalk.bioss.sari.ac.uk
      login=dnutter
      #The tool will prompt you if you don't specify a password
      #password=reallysecret
      
      #Per-architecture configurations. Errata will be published for all architectures listed in sections below. 
      #See the script for list of valid arches.
      #[i386]
      #All files for packages mentioned in the centos-announce postings
      #should reside in this directory. reposyncing the "updates" repo of
      #your fave centos release should do the trick. 
      #package_dir=/usr/ghost/RH_install/CentOS/%(version)s.%(release)s/updates/i386/RPMS/
      #Errata will be published to this channel so you should push the
      #packages in the directory above to this channel BEFORE you run
      #centos-errata.py. 
      #channel=centos-i386-updates-%(version)s.%(release)s
      
      [x86_64]
      package_dir=/usr/ghost/RH_install/CentOS/%(version)s.%(release)s/updates/x86_64/RPMS/
      channel=centos-x86_64-updates-%(version)s.%(release)s
      

      The tool has command line help showing the options you can set. For the config file above, asking for help would yield the following output:

      usage: centos-errata.py [options] [filename]
      
      options:
        --version             show program's version number and exit
        -h, --help            show this help message and exit
        -s SERVER, --server=SERVER
                              RHN Satellite server hostname
        -l LOGIN, --login=LOGIN
                              RHN Login
        --password=PASSWD     RHN password (cleartext)
        --max-errata=MAX_ERRATA
                              Maximum number of errata to process at once. Only relevant to format 'mail-archive.com'
        -c CONFIG_FILE, --config=CONFIG_FILE
                              Read the specified config file instead of the default centos-errata.cfg
        -f FORMAT, --format=FORMAT
                              Select input format for tool. Default is digest. Valid options are digest, archive, mail-archive.com
        --scrape-rhn          Connect to the RedHat Network site and attempt to download errata information
        --show-config         Do not connect to the RHN server, just print configuration information
        -t, --test            Do not connect to the RHN server, just process the input file and print errata information. Will also print
                              configuration information
        --centos-version=CENTOS_VERSION
                              The centos version (e.g. '5' for Centos 5.3)
        --x86_64-channel=X86_64_CHANNEL
                              The updates channel for arch x86_64
        --x86_64-packagedir=X86_64_PACKAGEDIR
                              The package directory for arch x86_64
      
      

      How to use

      1. Push all updates from your local centos mirror to your spacewalk server
      2. Get a centos-announce digest posting or download an archive from the the list archive pages. If you just want to play, I provide some test files below.
      3. Uncompress the archive, if used.
      4. Run the script in test mode (--test) on your file to check your configuration is correct for the errata you want for your distribution. Remember to specify -f archive if you are sung the downloaded archive format
      5. Run the script without the --test flag to push the errata to your spacewalk server
      6. The script is not very chatty when pushing errata - be patient as it takes about 15 seconds for each one to upload.
      7. Log in to spacewalk and examine your freshly-minted errata.

      Simple example usage (assuming customization of config file and use of a digest posting):

      ./centos-errata.py /tmp/centos-digest-message.txt
      

      More complicated usage:

      ./centos-errata.py --i386-channel my-i386-updates \
                        --server spacewalk.example.com \ 
                        --i386-packagedir /centos-mirror/5.3/updates/x86_64/RPMS \
                       /tmp/centos-announce-digest.txt
      

      Test mode usage, using archive format:

      ./centos-errata.py -f archive --test /tmp/2009-May.txt     
        

      Change Log

      Version 0.2 2010-05-28
      • Search spacewalk server for packages (thanks to Raal Goff)
      • Multiple architecture support
      • User can specify configuration files
      • Scraping of mail-archive.com and RHN for errata details (thanks to Raal Goff)
      • Improved argument parsing logic
      Version 0.1 2009-05-30
      • First release of the tool

      Limitations/TODO list

      1. MBOX format is not supported for input. It should be
      2. Errata are very basic. If you want full errata, then buying Satellite is your best bet
      3. Updating preexisting errata is not possible
      4. The tool does not check to see if the update_channel exists
      5. The tool can only publish errata to one channel per architecture
      6. Maybe the tool should try and push missing packages to the named update_channel, if they exist on disk. Unfortunately the XMLRPC api does not seem to support an pushPackage function (unless I'm being blind) so adding this function would require importing the necessary code from rhnpush
      7. All the classes (RHNSession and friends) and other generally-useful code should be moved to a module
      8. The config file should probably reside in /etc/sysconfig/rhn. This is a packaging problem though
      9. Better docs, more testing, fedora support...

      Files

      Acknowledgements and stuff

      This script is based on rhn-tool by Lars Jonsson. The script and support material is licenced under the terms of the LGPL.

      Raal Goff produced an amended version of the script that introduced multiple architecture support, spacewalk server searches and website scraping. This script essentially incorporates his changes and tidies up argument parsing. Thanks Raal!