I'm trying to define a static media server that uses a common website layout (e.g. with directories etc/
, log/
, html/
, etc.), as well as an nginx config that will get included into a host-wide nginx config. The site's nginx config needs to make use of the doc root that gets defined by the declared layouts::website
resource.
So, what I'd like to do is something like this:
class sites::static ($sites_dir) {
$domain = "static.example.com"
layouts::website {$domain:
base_dir => $sites_dir,
name => $domain,
}
nginx::siteconfig {$domain:
domain => $domain,
doc_root => $layouts::website[$domain]::doc_root,
}
}
Which could then be used by declaring:
class {'sites::static': sites_dir => "/opt/sites"}
However, the above fails because the $layouts::website[$domain]::doc_root
part is invalid. I've tried various alternatives here, unsuccessfully.
Is this possible? If not, how would you suggest I accomplish the stated goal of using a base layout that then needs to be used by various bits that will populate content within that base layout?
sites::static
scope and pass it to the declared resources, however doing that pretty much defeats the purpose of modularizing things into separate components in the first place.