Snippets not expanding

Latest response

I have some situations where kickstart snippets are not expanding.
I have a kickstart script redhat-register with the Template checked:

echo "redhat-register"
$SNIPPET('redhat_register')
echo "my-redhat-reg"
$SNIPPET('spacewalk/1/my-redhat-reg')
echo "root-ssh-keys"
$SNIPPET('spacewalk/1/root-ssh-keys')

The subject code in the generated kickstart file is as follows:
%post --log /root/ks-post.log.3
echo "redhat-register"

begin Red Hat management server registration

mkdir -p /usr/share/rhn/
wget http://llrhna01.ccci.org/pub/RHN-ORG-TRUSTED-SSL-CERT -O /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT
perl -npe 's/RHNS-CA-CERT/RHN-ORG-TRUSTED-SSL-CERT/g' -i /etc/sysconfig/rhn/*
rhnreg_ks --serverUrl=https://llrhna01.ccci.org/XMLRPC --sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT --activationkey=1-f98a7e024eec304590aafaece9ef4a81

end Red Hat management server registration

echo "my-redhat-reg"
$SNIPPET('spacewalk/1/my-redhat-reg')
echo "root-ssh-keys"
date
set -x -v
...

The files are:

[root@llrhna01 ~]# ls /var/lib/cobbler/snippets/redhat_register
/var/lib/cobbler/snippets/redhat_register
[root@llrhna01 ~]# ls /var/lib/cobbler/snippets/spacewalk/1/my-redhat-reg
/var/lib/cobbler/snippets/spacewalk/1/my-redhat-reg
[root@llrhna01 ~]# ls /var/lib/cobbler/snippets/spacewalk/1/root-ssh-keys
/var/lib/cobbler/snippets/spacewalk/1/root-ssh-keys
[root@llrhna01 ~]#

Note that one of my org snippets expands and the other doesn't.

Responses

I found the problem. I had unescaped variables in my failing bash snippets. ${variable} rather than \${variable}

Tim,

Was going to reply earlier but had an issue with my account, but glad to see you have solved it.

There seems to be a few characters the parser doesn't like and it can break in all sorts of mysterious ways. From memory I have had issues with certain combinations of quotes if not escaped correctly too.

So I don't have much to add... other than I have seen this behaviour too and it is tedious to track down in larger configs (wish they would fix it).. also great to see someone else using snippets (I often get blank looks when I mention them).

While on the subject, I would love to see version control in snippets like you get with configuration files (if you are listening Red Hat!)

Glad you got it fixed Tim. Thanks for letting us know what resolved it.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.