[Spacewalk-list] Using getVar in a Snippet

Kalchik, Jeffery JDKalchik at landolakes.com
Tue Mar 8 13:21:19 UTC 2016


getVar (outside of #raw/#endraw, those will prevent Cheetah/koan interpolations) I thought would retrieve any value that can be seen via 'cobbler system dumpvars -name=<client>'.

In my case, I see profile, profile_name, as well as distro and distro_name.  The kickstart can be found in the kickstart variable.  I can pull in the values:

>From a kickstart file:
# Test getVar $getVar("profile","No Profile")

>From the generated kickstart:
# Test getVar dev-rhel5

My immediate suspicion is that you have an unclosed #raw tag somewhere above.

Jeff Kalchik
Systems Engineering
Land O'Lakes

From: spacewalk-list-bounces at redhat.com [mailto:spacewalk-list-bounces at redhat.com] On Behalf Of William H. ten Bensel
Sent: Monday, March 07, 2016 5:17 PM
To: spacewalk-list at redhat.com
Subject: Re: [Spacewalk-list] Using getVar in a Snippet

Uncertain about the getVar commands.  However the ks= can be found during the kickstart in /proc/cmdline as it has the entire command line that was sent via the anaconda boot options. This would include the ks= and other variable that can be obtained as well.  ie.  ip, gateway, netmask, nameserver and any other misc custom flags (do not have to be valid boot options) for %post snippets.

So, this information could be written out to a file during the server kickstart.  There may be some better ways to do this, but using /proc/cmdline has worked for years and continues to do so in Cent/RHEL 7.x.

%post --nochroot
        cat /proc/cmdline > /mnt/sysimage/xxxx/xxxx.out

%post
        cat /proc/cmdline > /xxxx/xxxxx.out
        ksurl=`awk -F"ks=" '{print $1}'  /xxxx/xxxxx.out |awk '{print $1}'`
        ks_profile="${ksurlf##*/}"
or  if cobbler or Cheetah has issues with the above...
       ks_profile=`echo "$ksurl" |rev |cut -d"/" -f1|rev`


- Thanks and good luck





From:        Emmett Hogan <ehogan at gmail.com<mailto:ehogan at gmail.com>>
To:        spacewalk-list at redhat.com<mailto:spacewalk-list at redhat.com>
Date:        03/07/2016 04:03 PM
Subject:        [Spacewalk-list] Using getVar in a Snippet
Sent by:        spacewalk-list-bounces at redhat.com<mailto:spacewalk-list-bounces at redhat.com>
________________________________



This email originated from outside of the company. Please use discretion if opening attachments or clicking on links.
________________________________


Hi Folks,

I am trying to determine profile used to kickstart a particular machine, I have tried every version of $getVar that I can think of:

(I started with the one in an example on the https://fedorahosted.org/cobbler/wiki/KickstartSnippetswiki page)..

#set $p = $getVar('$profile')

That didn't work, so I have tried:

#set $p = $getVar('profile')
#set p = $getVar('profile', 'None')
#set p = $getVar("profile", 'None')

I noticed in the post_install_network_config snippet, they use BOTH:

#set osversion = $getVar("os_version","")

and

#set $numbondingdevs = 0

(Note the use of $ in the 2nd set command...what's the difference?)

Added #raw/#endraw ... that didn't matter.

Help...please?

Thanks in advance.

-Emmett

This email originated from outside of the company.  Please use discretion if opening attachments or clicking on links.

_______________________________________________
Spacewalk-list mailing list
Spacewalk-list at redhat.com<mailto:Spacewalk-list at redhat.com>
https://www.redhat.com/mailman/listinfo/spacewalk-list



**



This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient. Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law. If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies.

**

This message may contain confidential material from Land O'Lakes, Inc. (or its subsidiary) for the sole use of the intended recipient(s) and may not be reviewed, disclosed, copied, distributed or used by anyone other than the intended recipient(s). If you are not the intended recipient, please contact the sender by reply email and delete all copies of this message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20160308/6d90d40c/attachment.htm>


More information about the Spacewalk-list mailing list