Coder Social home page Coder Social logo

bandrea83 / katello-attach-subscription Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redhatsatellite/katello-attach-subscription

0.0 0.0 0.0 42 KB

automatically assign subscriptions to hypervisors based on certain rules

License: GNU General Public License v2.0

Ruby 100.00%

katello-attach-subscription's Introduction

katello-attach-subscription

automatically assign subscriptions to hypervisors based on certain rules

Description

katello-attach-subscription can be used to attach specific subscriptions to Katello hosts in Satellite 6. It is needed when you have multiple subscriptions that can be given to your hypervisors but want a more granular assignment than done by default by Satellite 6. You could for example give a specific subscription to a set of hosts that match a common hostname pattern or were submitted by a specific virt-who instance.

When run, katello-attach-subscription will execute the following steps:

  • Iterate over all content hosts of type Hypervisor of your organization
  • Search for a subscription that matches by hostname and (optionally) by the submitter (usually identified by the UUID of the virt-who instance)
  • If such a subscription is found:
    • ensure that it is attached to the content host
    • and all other subscriptions are removed from it

Requirements

Options

  • -U, --uri=URI URI to the Satellite, this must be https
  • -u, --user=USER User to log in to Satellite
  • -p, --pass=PASS Password to log in to Satellite
  • -o, --organization-id=ID ID of the Organization
  • -c, --config=FILE configuration in YAML format
  • -n, --noop do not actually execute anything
  • -H, --used-hypervisors-only only search for hypervisors that are in use
  • -s, --search=SEARCH only search for hypervisors that are in use
  • --use-cache read systems from the cache
  • --cache-file=FILE set the cache file for reading and writing
  • -d, --debug show debug code during execution

Configuration

katello-attach-subscription can be configured using an YAML file (katello-attach-subscription.yaml by default).

The configuration file consists of two main sections: settings and subs.

The settings section allows to set the same details as the commandline options. Any options given on the command line will override the respective config file settings.

:settings:
  :user: admin
  :pass: changeme
  :uri: https://localhost
  :org: 1
  :cachefile: 'katello-attach-subscription.cache'

The cachefile is meant to run this program in a faster way because retrieving all of the systems can require huge time. The cachefile will be written each time, while if --use-cache is specified on command line it will be readed and will skip systems extraction.

The subs section is an array of hashes which describe the subscriptions to be attached. Each subscription hash has an hostname entry which will be used as an regular expression to match the hostname of the content host in Katello. It also has a sub entry, which is an hash of array. The hash has product as key, which is a string to identify the type of subscription, and the content is an array of RedHat Pool ID of subscription to be attached to the host. An optional registered_by entry can be given to limit the matching to hosts that were submitted by a specific other host (a value of null or ~ skips check). This is the uid of the system running virt-who that has registered the hostname in Satellite. The type entry can be set if the host in question is not a hypervisor, but should get a subscription.

:subs:
  - 
    hostname: esxi[0-9]\.example\.com
    registered_by: "85e65e06-a117-4e8e-8aa1-72cb1e00b930"
    sub:
      rhel:
        - 4543828edcf35158c30abc3554c1e36a
        - 5543828edcf35158c30abc3554c1e36b
      jboss:
        - 6543828edcf35158c30abc3554c1e36c
        - 7543828edcf35158c30abc3554c1e36d
      satellite:
        - 7543828edcf35158c30abc3554c1e36e
  -
    hostname: esxi123\.example\.com
    sub:
      rhel:
        - 4543828edcf35158c30abc3554c1e36a
  -
    hostname: machine01\.example.com
    type: System
    sub:
      rhel:
        - b9548e4c9fa20b85f264fbaa2470b726

Caveats

Currently Satellite is not able to save fact that contain the socket number. Candlepin 2.0 (bug to be linked) and Virt-who 0.16 are needed https://bugzilla.redhat.com/show_bug.cgi?id=1307024. Assumption that only 1 sub is needed is done currently.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.