# Insert Variable Values when loading a Cloud Config?

**URL:** <https://www.ruby-forum.com/t/insert-variable-values-when-loading-a-cloud-config/244924>\
**Category:** NGINX\
**Created:** [July 11, 2016, 3:41pm UTC](https://www.ruby-forum.com/t/insert-variable-values-when-loading-a-cloud-config/244924 "2016-07-11T15:41:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [July 11, 2016, 3:41pm UTC](https://www.ruby-forum.com/t/insert-variable-values-when-loading-a-cloud-config/244924/1 "2016-07-11T15:41:10Z")

</div>

I asked a question on another site  
([Does bare-metal coreos etcd2 support the templating feature of coreos-cloudinit? - Stack Overflow](http://stackoverflow.com/questions/37032806/does-bare-metal-coreos-etcd2-support-the-templating-feature-of-coreos-cloudinit))  
about loading a cloud config from nginx onto a bare-metal core-os  
machine.

The question involves trying to have nginx fill in the variables for the  
$private\_ipv4 and $public\_ipv4 when a config is loaded up. Does this  
require that I use php-fpm to somehow recognize the machine sending the  
request, and then fill in the variables when the cloud-config is  
requested?

Posted at Nginx Forum:

> **[Insert Variable Values when loading a Cloud Config?](https://forum.nginx.org/read.php?2,268241,268241#msg-268241)**
>
> I asked a question on another site (http://stackoverflow.com/questions/37032806/does-bare-metal-coreos-etcd2-support-the-templating-feature-of-coreos-cloudinit) about loading a cloud config from nginx onto a bare-metal core-os machine. The question...

---

<div class="post-metadata">

**Author:** ![leeand00](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c37758/32.png) [@leeand00](https://www.ruby-forum.com/u/leeand00)\
**Post date:** [July 11, 2016, 8:31pm UTC](https://www.ruby-forum.com/t/insert-variable-values-when-loading-a-cloud-config/244924/2 "2016-07-11T20:31:29Z")

</div>

On Mon, Jul 11, 2016 at 09:40:45AM -0400, leeand00 wrote:

Hi there,

> The question involves trying to have nginx fill in the variables for the  
> $private\_ipv4 and $public\_ipv4 when a config is loaded up. Does this  
> require that I use php-fpm to somehow recognize the machine sending the  
> request, and then fill in the variables when the cloud-config is requested?

I think that the nginx side of the question is:

A file exists on the filesystem. A request is made for the matching  
url. Can nginx return the file contents, making some textual  
substitutions  
in the file contents?

If that is the question, then the answers probably involves: does nginx  
know what the desired substitutions are? (As in, where do the suitable  
values for $private\_ipv4 and $public\_ipv4 come from?)

If nginx can know, then probably the sub\_filter module  
([Module ngx\_http\_sub\_module](http://nginx.org/r/sub_filter)) can help.

You made need to check that you can include a literal $ in the string  
to replace, but that should be a straightforward enough test after you  
know that nginx can know what the replacement strings are.

If sub\_filter is not suitable, then you could use any other active  
content  
system (such as php-fpm) to do the work. The details will matter.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![leeand00](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c37758/32.png) [@leeand00](https://www.ruby-forum.com/u/leeand00)\
**Post date:** [July 12, 2016, 3:24am UTC](https://www.ruby-forum.com/t/insert-variable-values-when-loading-a-cloud-config/244924/3 "2016-07-12T03:24:30Z")

</div>

This is just a guess, but probably a hashap…or maybe a DNS server that  
assigns them statically. But I suppose CoreOS has to request it from  
nginx,  
so it could probably even just pull it out of the request.

Posted at Nginx Forum:

> **[Re: Insert Variable Values when loading a Cloud Config?](https://forum.nginx.org/read.php?2,268241,268250#msg-268250)**
>
> I asked a question on another site (http://stackoverflow.com/questions/37032806/does-bare-metal-coreos-etcd2-support-the-templating-feature-of-coreos-cloudinit) about loading a cloud config from nginx onto a bare-metal core-os machine. The question...

---

<div class="post-metadata">

**Author:** ![leeand00](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c37758/32.png) [@leeand00](https://www.ruby-forum.com/u/leeand00)\
**Post date:** [July 12, 2016, 10:16pm UTC](https://www.ruby-forum.com/t/insert-variable-values-when-loading-a-cloud-config/244924/4 "2016-07-12T22:16:00Z")

</div>

On Mon, Jul 11, 2016 at 09:24:11PM -0400, leeand00 wrote:

Hi there,

> This is just a guess, but probably a hashap…or maybe a DNS server that  
> assigns them statically. But I suppose CoreOS has to request it from nginx,  
> so it could probably even just pull it out of the request.

When you can see what the request is, and what information it includes,  
and when you can see how nginx-or-something-else can take that  
information  
and determine the correct public and private addresses to use, then you  
may have enough information to configure sub\_filter (or something else)  
to return the content that you want.

Most of those missing pieces are not nginx-specific.

There might be someone here who knows about them; but if they are  
CoreOS-specific, you may have better luck on a CoreOS list.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
