I’m hoping this is the correct section (i can change to development if better) to post in. Basically I could really do with some help getting an ERB if statement to work. My template is to auto subscribe new hosts and I have it working by using gsub to remove parts of the foreman_url. See below. This works fine with the 4 proxies we have in difference DC’s, but for the master, it does not.
When I preview this snippet against any host other than our master, it formats perfectly and works, but for the master, it fails and keeps http in there with the rest of the url:
I tried an if statement to simply curl the actual url (not the foreman_url variable but this is also failing:
<% if (foreman_url(‘provision’) == ‘http://sv-prod-foreman01.ourdomain.com’) -%>
You can use foreman_server_url instead which will return the value from the setting.
You can navigate to the Template DSL help via Administer > About on the right, the url is /templates_doc on your system. This gives you an overview of existing options and clicking on them will give you some explanation.
Same result:
running the preview against a host controlled by a proxy (else statement) formats and works fine
but against a host controlled by the master (sv-prod-foreman), it still shows the extra parts of the url even though Ive hardcoded the url (no gsub variables):
As a debugging tool, you can also use the ‘squid’ markers and it will output the values for you in the rendered template, for example <%= foreman_url('provision') %>.
spoke too soon. The preview tab finally worked using the above code against 2 different servers, which is what I needed
Then I built and the anaconda file showed it running differently to what the preview showed. Im stumped
thanks yes i did this and it’s definitely returning the correct value to what I expect to see and then use
I also checked the templates section in the legacyUI for this new host I built and it shows the correct code being used. anaconda shows the wrong command being used. Going to restart foreman now to see if something has cached but if anyone knows what else it could be, pls let me know