Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1468906 - [RFE] [6.3] Creating hostgroups script
Summary: [RFE] [6.3] Creating hostgroups script
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Docs Hammer CLI Guide
Version: 6.2.10
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: Unspecified
Assignee: Sergei Petrosian
QA Contact: Stephen Wadeley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-09 16:55 UTC by Shadd
Modified: 2019-04-01 20:26 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-31 13:21:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Example on Creating Multiple Host Groups (985 bytes, text/plain)
2017-08-31 14:14 UTC, Sergei Petrosian
no flags Details

Description Shadd 2017-07-09 16:55:20 UTC
Document URL: 
https://access.redhat.com/documentation/en-us/red_hat_satellite/6.2/html-single/hammer_cli_guide/#sect-CLI_Guide-Creating_a_Host_Group

Section Number and Name: 
6.1. Creating a Host Group

Describe the issue:
Only useful if a customer wants a single Environment 
If ran as is Parent_ID and HgID can provide multiple ids and the script is not in a loop  so it fails with to many variables 

Suggestions for improvement: 
Verify correct variables are in /root/.bashrc or add them into script
ARCH=
DOMAIN=
PROXYID=
NETNAME=
CAID=
MEDID=
ORGID=
LOCID=
OSID=
PARTTABLEID=

source /root/.bashrc

Set variables for loop

ENVIROMENT=$(hammer environment list |awk -F "|" {'print $2'}|grep -v -|grep -v NAME |sed 's/ //g' |grep -v production)
LEL=$(hammer lifecycle-environment list --organization $ORG |awk -F "|" {'print $2'}|grep -v - |grep -v NAME)

for loop to add hostgroups
for i in $ENVIROMENT; do for j in $(hammer --csv environment list |awk -F "," {'print $2'}| awk -F "_" {'print $3'}); do hammer hostgroup create --name rhel-7-"$j" --environment "$i" --architecture "$ARCH" --domain "$DOMAIN" --subnet "$NETNAME" --puppet-proxy-id "$PROXYID" --puppet-ca-proxy-id "$CAID" --medium-id "$MEDID" --organization-ids "$ORGID" --location-ids "$LOCID" --operatingsystem-id "$OSID" --partition-table-id $PARTTABLEID ; done; done


Additional information:

Comment 1 Andrew Dahms 2017-07-13 05:37:40 UTC
Assigning to Sergei for review.

Comment 4 Shadd 2017-08-30 17:43:42 UTC
What info can I provide to close this ticket?

Comment 7 Sergei Petrosian 2017-08-31 14:14:25 UTC
Created attachment 1320608 [details]
Example on Creating Multiple Host Groups

Find working document with the example of script on creating multiple host groups in the attachment.


Note You need to log in before you can comment on or make changes to this bug.