Bug 1576234 - Discovery Rules Issues
Summary: Discovery Rules Issues
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Documentation
Version: 6.3.1
Hardware: All
OS: All
unspecified
high
Target Milestone: Unspecified
Assignee: Stephen Wadeley
QA Contact: Melanie Corr
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-09 06:28 UTC by Waldirio M Pinheiro
Modified: 2019-09-26 14:56 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-06-06 18:53:20 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Waldirio M Pinheiro 2018-05-09 06:28:21 UTC
Description of problem:
Hi all, I'll describe some issues on the guide, when we are implementing, some rules recommended in our official docs will not work as expected.

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

How reproducible:
100%

Steps to Reproduce:
1. Create a new Discovery Rule
2. Copy / Paste the rule from the official doc
3. Create a new machine, define the mac as filter
4. FDI / Auto Provision

Actual results:
Error and backtrace

Expected results:
Start the process according the rule

Additional info:


Document URL: 

Section Number and Name: 

Describe the issue: 

Suggestions for improvement: 

Additional information:

Comment 1 Waldirio M Pinheiro 2018-05-09 06:43:32 UTC
Document URL: 
https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html-single/provisioning_guide/#Provisioning_Bare_Metal_Hosts-Creating_Discovery_Rules

Section Number and Name: 
6.5. Creating Discovery Rules

Describe the issue: 
There are some recommendations that should works, according below

---
- myhost-<%= rand(99999) %>
- abc-<%= @host.facts['bios_vendor'] + '-' + rand(99999) %>
- xyz-<%= @host.hostgroup.name %>
- srv-<%= @host.discovery_rule.name %>
- server-<%= @host.ip.gsub('.','-') + '-' + @host.hostgroup.subnet.name %> 
---

Suggestions for improvement: 

- myhost-<%= rand(99999) %>
Fine


- abc-<%= @host.facts['bios_vendor'] + '-' + rand(99999) %>
===
// Expected Hostname
abc-seabios-2551.local.domain

// Original
abc-<%= @host.facts['bios_vendor'] + '-' + rand(99999) %>

//Fixed
abc-<%= @host.facts['bios_vendor'] + '-' + rand(99999).to_s %>

// Error
---
2018-05-09 01:23:42 e73c434a [app] [I] Match found for host mac5254005ecbf1 (38) rule fdi02 (8)
2018-05-09 01:23:42 e73c434a [templates] [I] Rendering template 'Unnamed'
2018-05-09 01:23:42 e73c434a [app] [W] Action failed
 | TypeError: no implicit conversion of Fixnum into String
 | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.2/lib/safemode/jail.rb:31:in `+'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.2/lib/safemode/jail.rb:31:in `method_missing'
===


- xyz-<%= @host.hostgroup.name %>
===
// Expected Hostname
xyz-hg_rhel75.local.domain

// Original
xyz-<%= @host.hostgroup.name %>

// Error
---
Error: Failed to auto provision host xyz-hg_rhel75.local.domain: Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123 Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123
---

// Explanation
The main point here is, on my host group I use "_" and then we get the issue.

// Fixed
xyz-<%= @host.hostgroup.name.gsub('_','-') %>

// Final Name
xyz-hg-rhel75.local.domain
===


- srv-<%= @host.discovery_rule.name %>
===
// Expected Hostname
srv-fdi03.local.domain

// Original
srv-<%= @host.discovery_rule.name %>

// Error
Oops, we're sorry but something went wrong undefined method '#discovery_rule' for Host::Managed::Jail (Host::Managed)

---
Safemode::NoMethodError
undefined method '#discovery_rule' for Host::Managed::Jail (Host::Managed)
/opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.2/lib/safemode/jail.rb:22:in `method_missing'
Unnamed:53:in `bind'
/opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.2/lib/safemode.rb:51:in `eval'
/opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.2/lib/safemode.rb:51:in `eval'
--- 

No fix here
===


- server-<%= @host.ip.gsub('.','-') + '-' + @host.hostgroup.subnet.name %> 
===
// Expected Hostname
server-192-168-56-152-192.168.56_net

// Original
server-<%= @host.ip.gsub('.','-') + '-' + @host.hostgroup.subnet.name %>

// Error
---
2018-05-09 02:20:24 d92545a1 [app] [E] Auto provisioning failed: Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC95
2 and RFC1123 and Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123
2018-05-09 02:20:24 d92545a1 [app] [W] Failed to auto provision host server-192-168-56-152-192.168.56_net.local.domain: Name hostname can contain only lowercase lette
rs, numbers, dashes and dots according to RFC921, RFC952 and RFC1123 Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, R
FC952 and RFC1123
---


// Fixed
server-<%= @host.ip.gsub('.','-') + '-' + @host.hostgroup.subnet.name.gsub('.','-').gsub('_','-') %>

// Final Name
server-192-168-56-152-192-168-56-net.local.domain 
===



Ok, there are a lot of recommendations here to change on the page but the main point is, I believe be VERY IMPORTANT inform two points

1. If customer is using some information which contain "." or "_" will fail unless he did the correct follow up.

2. One complete list with all methods to customer should be amazing, or at least one way to get/retrieve/collect this information up to date.



Best Regards
-- 
Waldirio M Pinheiro | Senior Software Maintenance Engineer

Comment 2 Stephen Wadeley 2018-05-16 12:34:52 UTC
Hello Waldiro

If we go through the guides adding a sentence to say underscores and dots in host group and host names are not supported by discovery rules, would that take care of most of this issue?


I am sorry but I cannot understand what you mean by "list with all methods ".

Thank you


https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/ch-configure_host_names#sec-Recommended_Naming_Practices

Comment 3 Waldirio M Pinheiro 2018-05-16 23:50:04 UTC
Hey Stephen, good morning

yea, will be interesting *really recommended* but in some examples will fail. Let me show one.

---
// Original
abc-<%= @host.facts['bios_vendor'] + '-' + rand(99999) %>

//Fixed
abc-<%= @host.facts['bios_vendor'] + '-' + rand(99999).to_s %>
---

On this case we are talking about different types, then the ".to_s" at the end will be mandatory *independent of "_" character*


Sorry about be clear about *all methods*, let me show below

---
- myhost-<%= rand(99999) %>
- abc-<%= @host.facts['bios_vendor'] + '-' + rand(99999) %>
- xyz-<%= @host.hostgroup.name %>
- srv-<%= @host.discovery_rule.name %>
- server-<%= @host.ip.gsub('.','-') + '-' + @host.hostgroup.subnet.name %> 
---

On this scenario, @host.<everything here>

Then one way to generate this list should be awesome to customer, he will be able to check on the content host what *option, method, namespace* will be available to work / request information.

Please let me know the correct name on this case, for sure this is my fault here. :)

Let me know if you need something else.


Best Regards
-- 
Waldirio M Pinheiro | Senior Software Maintenance Engineer

Comment 4 Stephen Wadeley 2018-05-18 07:46:55 UTC
Hello Waldirio

I will discuss this with lzap and rplevka next week.

Thank you

Comment 5 Stephen Wadeley 2018-05-23 09:06:30 UTC
Hello Waldiro


lzap could not see a problem with the example you gave in comment 3. If required, he can check it next week.

As to "list all the methods", lzap has added built in syntax help in Sat6.4

You might like to follow this RFE:

Bug 1581623 - [RFE] Add "Syntax Help" button for syntax help

Docs need to describe how to find that.


Thank you

Comment 6 Stephen Wadeley 2018-05-23 09:11:43 UTC
Hello


The "Provisioning Templates" page (/templates/provisioning_templates) has a "Documentation button which links to "3.5. Creating Provisioning Templates"[1]

that section in turn has text with links:

the Kickstart Syntax Reference in the Red Hat Enterprise Linux 7 Installation Guide. [2]

Templates accept the Embedded Ruby (ERB) syntax, for more information see Template Writing Reference in Managing Hosts. [3]

[1] https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/provisioning_guide/configuring_provisioning_resources#Configuring_Provisioning_Resources-Creating_Provisioning_Templates

[2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax


[3] https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/managing_hosts/appe-red_hat_satellite-managing_hosts-template_writing_reference

Comment 7 Stephen Wadeley 2018-05-28 11:41:32 UTC
6.4.5. Host Name Patterns[1]

      db-server-<%= @host.ip.gsub('.','-') + '-' + @host.hostgroup.subnet.name %>>          <--- Is that an extra > I see?


[1] https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/managing_hosts/chap-red_hat_satellite-managing_hosts-discovering_bare_metal_hosts_on_satellite#sect-Red_Hat_Satellite-Managing_Hosts-Provisioning_Discovered_Hosts-Host_Name_Patterns

Comment 8 Waldirio M Pinheiro 2018-05-28 17:21:37 UTC
Hello Stephen

6.4.5. Host Name Patterns[1]

db-server-<%= @host.ip.gsub('.','-') + '-' + @host.hostgroup.subnet.name %>>          <--- Is that an extra > I see?

Probably issue.

---
db-server-<%= @host.ip.gsub('.','-') + '-' + @host.hostgroup.subnet.name %>
---

to open and close ruby code.

Best Regards
-- 
Waldirio M Pinheiro | Senior Software Maintenance Engineer

Comment 9 Waldirio M Pinheiro 2018-05-28 17:22:08 UTC
Stephen,

Sorry, *typo*


Best Regards
-- 
Waldirio M Pinheiro | Senior Software Maintenance Engineer

Comment 10 Stephen Wadeley 2018-05-29 06:38:07 UTC
(In reply to Waldirio M Pinheiro from comment #9)
> Stephen,
> 
> Sorry, *typo*
> 
ACK, thanks (I will fix that now in all guides as its just a typo.)

Now we need to ask lzap about the first part of comment 3

IIUC, to_s means "integer to string", but I cannot understand what you are asking. Was this just unexpected or you think you should not have to use that?

Only lzap needs to understand your question I suppose, but its nice to have well formed questions.

Thank you

Comment 12 Stephen Wadeley 2018-05-29 07:09:18 UTC
Hello lzap

If I understand comment 1 correctly, the question is, are the xmaple in the guide correct or do we need to add to_s ?


Thank you

Comment 14 Lukas Zapletal 2018-05-29 13:22:31 UTC
I can confirm that rand() function returns integer which cannot be concatenated with string and to_s call is needed. I created a ticket to fix this in the helper box and also add few more new options:

http://projects.theforeman.org/issues/23729

Comment 22 Stephen Wadeley 2018-06-06 18:53:20 UTC
Hello

These changes are now live on the Customer Portal

6.5. Creating Discovery Rules

https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/provisioning_guide/provisioning_bare_metal_hosts#Provisioning_Bare_Metal_Hosts-Creating_Discovery_Rules


Thank you


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