# Specify \`servername\` without rewriting the portal configuration

**URL:** https://discourse.openondemand.org/t/specify-servername-without-rewriting-the-portal-configuration/2276
**Category:** General Discussion
**Tags:** question
**Created:** [September 15, 2022, 10:31am UTC](https://discourse.openondemand.org/t/specify-servername-without-rewriting-the-portal-configuration/2276 "2022-09-15T10:31:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lost](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/lost/32/862_2.png) [@lost](https://discourse.openondemand.org/u/lost)
#### Post date: [September 15, 2022, 10:31am UTC](https://discourse.openondemand.org/t/specify-servername-without-rewriting-the-portal-configuration/2276/1 "2022-09-15T10:31:40Z")

</div>

I want to build RockyLinux images including Open Ondemand which I can use for different clusters. The problem I have is that that requires setting the `servername` differently. Currently I’m using the `osc.ood-ansible` role with `ood_portal_generator: true` (as per default). This means that ansible writes ood\_portal.yml.j2 , then on the systemd unit start apache runs the portal generator to generate its config. I can’t see any way of providing `servername` via e.g. environment variables (which would allow me to write a systemd drop-in).

I really don’t want to modify [ondemand/ood-portal.conf.erb at master · OSC/ondemand · GitHub](https://github.com/OSC/ondemand/blob/master/ood-portal-generator/templates/ood-portal.conf.erb), has anyone got any ideas please??

I’m open to not using the portal generator, I see the ansible has that as an option to template the apache conf directly, but I’m not really sure of the trade-offs there. I.e. I don’t want to do something which is going against the direction of OOD development.

thanks  
Steve

---

<div class="post-metadata">

### Author: ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)
#### Post date: [September 15, 2022, 1:29pm UTC](https://discourse.openondemand.org/t/specify-servername-without-rewriting-the-portal-configuration/2276/2 "2022-09-15T13:29:38Z")

</div>

This is the config for `servername`.

> <https://github.com/OSC/ood-ansible/blob/8c81351a5b27d5859996e15fe690318faf7d1d03/defaults/main/ood_portal.yml#L27>

> [@lost](#):
>
> I can’t see any way of providing `servername` via e.g. environment variables (which would allow me to write a systemd drop-in).

I’m not sure I follow this. Why you’d need environment variables here. Even if you’re overwriting our system unit file, you should be able to use this ansible variable.

> [@lost](#):
>
> ’m open to not using the portal generator, I see the ansible has that as an option to template the apache conf directly, but I’m not really sure of the trade-offs there.

Do not use the ansible template as it’s likely out of date. That entire functionality is being deprecated so that we don’t have to maintain 2 different templates. Using the ood\_portal\_generator is the best way to go.

---

<div class="post-metadata">

### Author: ![lost](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/lost/32/862_2.png) [@lost](https://discourse.openondemand.org/u/lost)
#### Post date: [September 22, 2022, 1:43pm UTC](https://discourse.openondemand.org/t/specify-servername-without-rewriting-the-portal-configuration/2276/3 "2022-09-22T13:43:53Z")

</div>

Thanks. The reason for this is ansible is running inside a packer build VM, hoping to produce “generic” images which I can use for several clusters. So `servername` cannot be determined at the time the role runs. I think I’ve solved it actually - it turns out apache config uses environment vars so I think I can set servername to eg. `${OPENONDEMAND_SERVERNAME}` and create a systemd dropin which reads the actual value from userdata on instance creation.
