Bug 1127164 - Correctly set hostgroup after provisioning from PXE menu
Summary: Correctly set hostgroup after provisioning from PXE menu
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Puppet
Version: 6.0.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: Unspecified
Assignee: Amir
QA Contact: Lukas Zapletal
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2014-08-06 10:08 UTC by Nick Strugnell
Modified: 2019-08-12 14:02 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:54:17 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 6952 None None None 2016-04-22 16:55:56 UTC

Internal Links: 1198065 1198070

Description Nick Strugnell 2014-08-06 10:08:13 UTC
Description of problem:
When we provision from the standard PXE menu, we can choose which hostgroup template to install the new server from.

Version-Release number of selected component (if applicable):
6 beta


How reproducible:
always


Steps to Reproduce:
1. Create some hostgroups with associated content views and lifecycle environments
2. Build the PXE default menu from the Provisioning Templates screen
3. PXE boot a new server
4. From the boot menu, select a hostgroup boot option

Actual results:
Machine boots and installs, however once it has registered with foreman, it is not in a hostgroup


Expected results:
The newly installed machine should be in the same hostgroup that we selected in the PXE menu.


Additional info:
Candidate patch:

patch -p0 -l -f << EOF
--- /usr/share/foreman/app/models/host/managed.rb      2014-08-06 08:24:18.912311511 +0000
+++ /usr/share/foreman/app/models/host/managed.rb  2014-08-06 09:06:02.716311124 +0000
@@ -404,6 +404,14 @@
     host ||= Host.new(:name => hostname, :certname => certname) if Setting[:create_new_host_when_facts_are_uploaded]
 
     return Host.new, true if host.nil?
+
+    # set hostgroup defaults if provided by a fact
+    hostgroup_fact='foreman_hostgroup'
+    if facts.keys.include?(hostgroup_fact)
+      host.hostgroup = Hostgroup.find_by_title(facts[hostgroup_fact])
+      host.set_hostgroup_defaults
+    end
+
     # if we were given a certname but found the Host by hostname we should update the certname
     host.certname = certname if certname.present?
 
EOF

Comment 1 RHEL Product and Program Management 2014-08-06 10:13:46 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Dominic Cleal 2014-08-06 10:19:26 UTC
Created redmine issue http://projects.theforeman.org/issues/6952 from this bug

Comment 4 Peter Vreman 2015-03-03 10:22:48 UTC
Looks like the foreman-plugin-default-hostgroup provides already basic code to select a hostgroup. One thing that is missing in that plugin is a dynamic hostgroup name based on facts. E.g. a foreman_hostgroup facts that the host can provide to select its own custom hostgroup.

Comment 5 Peter Vreman 2015-03-03 13:02:51 UTC
Added two new requests to use the foreman plugin default_hostgroup
BZ1198065
BZ1198070

Comment 6 Peter Vreman 2015-08-04 11:45:12 UTC
This request to select the right hostgroup also applies to AWS dynamic workload (autoscaling and spot instance). The cloud-init script can then generate the foreman_xxxxx facts and then call puppet agent to have the host registered

Comment 7 Peter Vreman 2016-03-16 13:15:57 UTC
For the foreman plugin default_hostgroup i have opened an issue to request for dynamic hostgroup name based on a fact. Currently this is not allowed yet.

https://github.com/theforeman/foreman_default_hostgroup/issues/16

Comment 8 Bryan Kearney 2016-08-10 19:02:22 UTC
Upstream bug component is Configuration Management

Comment 9 Bryan Kearney 2016-08-10 20:03:28 UTC
Upstream bug component is Provisioning

Comment 10 Bryan Kearney 2016-08-10 22:03:14 UTC
Upstream bug component is Puppet

Comment 11 Peter Vreman 2016-08-31 08:40:12 UTC
Confirm that the patch is still needed and also still working for Sat6.2.1

Comment 14 Daniel Lobato Garcia 2016-12-23 07:40:50 UTC
https://github.com/theforeman/foreman/pull/4112 nearly ready for merge upstream

Comment 15 pm-sat@redhat.com 2017-01-09 14:48:31 UTC
Upstream bug assigned to afeferku@redhat.com

Comment 16 pm-sat@redhat.com 2017-01-09 14:48:36 UTC
Upstream bug assigned to afeferku@redhat.com

Comment 17 pm-sat@redhat.com 2017-01-11 13:18:50 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/6952 has been resolved.

Comment 18 Lukas Zapletal 2017-08-23 11:52:14 UTC
[root@zzzap ~]# rpm -q foreman katello
foreman-1.15.3-1.el7sat.noarch
katello-3.4.4-2.el7sat.noarch

Comment 19 pm-sat@redhat.com 2018-02-21 16:54:17 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> 
> For information on the advisory, and where to find the updated files, follow the link below.
> 
> If the solution does not work for you, open a new bug report.
> 
> https://access.redhat.com/errata/RHSA-2018:0336


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