Facts usage Example and testing

17 views
Skip to first unread message

Steve Pribyl

unread,
Aug 5, 2019, 11:31:07 AM8/5/19
to puppet-razor


Could someone provide a code example for checking facts in a kickstart.erb file?   I am not sure I am use the right syntax. 

Also is it possible to wget a file from razor as part of a development testing step?
I would like to see what files are getting generated and check for errors, doing so during an osinstall gets complicated. 
e.g.
wget https://razor/<something>/kickstart.cfg?<arg>&<arg> 

Thanks

Brian McNally

unread,
Aug 5, 2019, 1:12:05 PM8/5/19
to puppet...@googlegroups.com
I don't actually access any Facter facts currently in my kickstart.erb
file, but I think the syntax would be something like this:

node.facts['bios_release_date']

I believe you should be able to access any of the sources of information
listed when you run:

razor nodes $node-number | grep 'additional details'

So, that'd be these sources of information:

[facts, hw_info, log, metadata, policy, state, tags]

For example, I use a kickstart variable in my kickstart.erb:

partition_type="<%= node.metadata['partition_type'] %>"
if [ "$partition_type" == "small" ]; then
...
fi

partition_type is a custom variable that's part of the node's metadata
that we set manually:

razor update-node-metadata node12 partition_type small

--
Brian McNally
> --
> You received this message because you are subscribed to the Google
> Groups "puppet-razor" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-razor...@googlegroups.com
> <mailto:puppet-razor...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-razor/9bb77067-84cb-4fe8-8445-c2db75ac4760%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-razor/9bb77067-84cb-4fe8-8445-c2db75ac4760%40googlegroups.com?utm_medium=email&utm_source=footer>.

Scott McClellan

unread,
Aug 5, 2019, 2:56:52 PM8/5/19
to puppet-razor
Hi Steve,

Brian got the first part `<%= node.facts['key'] %>`. The second you can hit a number of endpoints below (caveat: these are not part of the API, so could be subject to change... however unlikely that may seem):

*Note: ## should just be the node number, e.g. "5" for "node5".

- Raw task files (not for .erb files): https://razor:8150/svc/file/raw/${filename}
- Rendered broker files: https://razor:8150/svc/broker/##/install (append `?script=install.ps1` for e.g. Windows machines)

Hope that helps,

Scott

--
You received this message because you are subscribed to the Google Groups "puppet-razor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-razor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-razor/9bb77067-84cb-4fe8-8445-c2db75ac4760%40googlegroups.com.

Steve Pribyl

unread,
Aug 6, 2019, 8:14:57 AM8/6/19
to puppet-razor
Thanks all this helps, I had a syntax error in my code from not understanding. 

<%= is assignment
<% is code  

Also thanks for the URL hints, that helps a great deal. 


On Monday, August 5, 2019 at 1:56:52 PM UTC-5, Scott McClellan wrote:
Hi Steve,

Brian got the first part `<%= node.facts['key'] %>`. The second you can hit a number of endpoints below (caveat: these are not part of the API, so could be subject to change... however unlikely that may seem):

*Note: ## should just be the node number, e.g. "5" for "node5".

- Raw task files (not for .erb files): https://razor:8150/svc/file/raw/${filename}
- Rendered broker files: https://razor:8150/svc/broker/##/install (append `?script=install.ps1` for e.g. Windows machines)

Hope that helps,

Scott

On Mon, Aug 5, 2019 at 10:31 AM Steve Pribyl <sjpr...@gmail.com> wrote:


Could someone provide a code example for checking facts in a kickstart.erb file?   I am not sure I am use the right syntax. 

Also is it possible to wget a file from razor as part of a development testing step?
I would like to see what files are getting generated and check for errors, doing so during an osinstall gets complicated. 
e.g.
wget https://razor/<something>/kickstart.cfg?<arg>&<arg> 

Thanks

--
You received this message because you are subscribed to the Google Groups "puppet-razor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages