New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cobbler.py inventory script to more fully leverage Cobbler management fields #12090

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
9 participants
@gregmark
Contributor

gregmark commented Aug 25, 2015

SUMMARY

Refactored to leverage Cobbler system, profile, and management class parameters to produce a more robust and exact output; all configurable in cobbler.ini

    o  assigning system objects to groups based on owners and/or status and/or profiles,
       and/or management classes.
    o  assigning groups to parent groups based on the special management class parameter
       "parent". Only one parent per class is currently supported.
    o  assigning group and hostvars based on either or both ks_meta params or management
       parameters.
    o  Optional: have system objects inherit vars from their respective profiles
    o  Optional: Only include system objects with at least one interface w/ management = 1
    o  Limitations: there is no good way to assign groupvars or children to groups based on
       owners or status. Currently, parents can not be assigned in profiles and only one
       parent can be assigned per child group (this could be added easily).
    Tested with Cobbler 2.6.7.

Also, I refrained making two other changes before I got some maintainer feedback. First, while the script will still support earlier Cobbler versions that lack management groups, it seems to me that using the system object's management tab as the primary driver of the Ansible inventory is the best practice moving forward. With that in mind, I only coded parent/children management to be based on "management class params", not ks_meta or mgmt_parameters from systems or profiles.

Secondly, a next good step should be to add a "parents" field to the management class dict, separate from mgmt_class[params], where multiple parents are separated by whitespace. I wasn't sure if we should support multiple parents before that change, but if we did, I also wasn't sure what the best "Cobbler way" to make this assignment. Either comma separated, whitespace, or something else?

Finally, this is the most python coding I have ever done. I am very green, so please provide suggestions if my code is messy or too complicated.

Thanks.

--Greg Chavez

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

contrib/inventory/cobbler.ini
contrib/inventory/cobbler.py

ANSIBLE VERSION

2.3

ADDITIONAL INFORMATION

Greg Chavez added some commits Aug 25, 2015

Greg Chavez Greg Chavez
Refactored to leverage Cobbler system, profile, and management class …
…parameters to produce a more robust and exact output; all configurable in cobbler.ini
Greg Chavez Greg Chavez
if inherit_profiles == 1, mgmt_classes are inherited as well as ksmet…
…a and mgmt_params

prevent duplicate entires with assign_list()
added some comments and other cosmetic changes

@gregmark gregmark changed the title from Refactored to leverage Cobbler system, profile, and management class … to Update cobbler.py inventory script more fully leverage Cobbler management fields Aug 27, 2015

@gregmark gregmark changed the title from Update cobbler.py inventory script more fully leverage Cobbler management fields to Update cobbler.py inventory script to more fully leverage Cobbler management fields Aug 27, 2015

@jimi-c jimi-c removed the P3 label Dec 7, 2015

@bcoca bcoca added the needs_rebase label Mar 21, 2016

@ansibot ansibot added the affects_2.3 label Dec 13, 2016

# Prevent redundancy
if self.profile_groups and self.inherit_profiles:
self.inherit_pofiles = False

This comment has been minimized.

@dcoshea

dcoshea Dec 13, 2016

Typo "pofiles" should be "profiles"

@ansibot

This comment has been minimized.

Contributor

ansibot commented Jan 5, 2017

@gregmark This PR was tested by travis-ci.org, which is no longer used. Please rebase your branch to trigger running of current tests.

click here for bot help

@ansibot

This comment has been minimized.

Contributor

ansibot commented Jan 6, 2017

@gregmark This PR was tested by travis-ci.org, which is no longer used. Please rebase your branch to trigger running of current tests.

click here for bot help

@ansibot

This comment has been minimized.

Contributor

ansibot commented Apr 4, 2017

@gregmark Greetings! Thanks for taking the time to open this pullrequest. In order for the community to handle your pullrequest effectively, we need a bit more information.

Here are the items we could not find in your description:

  • issue type
  • ansible version
  • component name

Please set the description of this pullrequest with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/PULL_REQUEST_TEMPLATE.md

click here for bot help

@gregmark

This comment has been minimized.

Contributor

gregmark commented Jun 27, 2017

Will do. I had begun to think this pull request would never happen. I'll start fixing these problems.

@gregmark gregmark closed this Jun 27, 2017

@gregmark gregmark reopened this Jun 27, 2017

@gregmark

This comment has been minimized.

Contributor

gregmark commented Jun 27, 2017

Whoa! Did not mean to close this.

@ansibot ansibot removed the stale_ci label Jun 27, 2017

@thaumos

This comment has been minimized.

Contributor

thaumos commented Jul 21, 2017

hey @gregmark, would you be willing to do a rebase on this so it fires off another test?

@dcoshea

This comment has been minimized.

dcoshea commented Mar 20, 2018

It would be nice if there was a way to request that all parameters be passed through to Ansible, not just ksmeta and mgmt_params. For example, I'd like Ansible to be able to see all of the network interfaces for a machine as configured in Cobbler, and if I recall correctly (it's been a while since I looked at this) this wasn't available.

@k4pu77

This comment has been minimized.

k4pu77 commented Mar 23, 2018

@dcoshea - I was looking for the same functionality as you and can confirm that the configured network interfaces are listed when you run the script and therefore available to ansible. Even in version in the current devel branch. You can do stuff like:

- debug: var=cobbler['interfaces']['eth0']['ip_address']

There are additional parameters exported.

Addition: I took me felt ages to realize that if you change orderby_keyname = 'owners' to orderby_keyname = 'mgmt_classes' in the inventory script, the hosts will be grouped by management class which is a pretty handy feature. No clue why this is not a configurable property.

@ansibot ansibot added the needs_repo label May 2, 2018

@gregmark

This comment has been minimized.

Contributor

gregmark commented May 16, 2018

OK, let's see if I can get this thing working again.

@sandinak

This comment has been minimized.

sandinak commented May 16, 2018

+1 on this .. it really needs some attention and to be integrated.

@ansibot ansibot removed the stale_ci label Jun 1, 2018

@ansibot ansibot removed the new_contributor label Sep 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment