Wordpress_env_defaults in helpers.yml not working?

Not sure what I’m missing here, but if I try and change any settings for wordpress_env_defaults in group_vars/all/helpers.yml, it does not update my .env file. Any advice out there?

Is this in development or for a remote server?

If you deployed and didn’t see any changes, it’s likely because there’s a separate definition of wordpress_env_defaults in the deploy role: trellis/main.yml at b6fde51906a5a8a6fad2860a8db585c7a0c4ae1a · roots/trellis · GitHub

What are you trying to accomplish exactly? There might be another way.

This is for a remote server. I was expecting that making changes to wordpress_env_defaults in helpers.yml would override roles/deploy/vars/main.yml.

I’m specifically trying to set disable_wp_cron and wp_post_revisions. It seemed like helpers.yml was a good place to do this … but I ended up just adding these to group_vars/all/vault.yml.

Any values defined under a site’s env setting will override those defaults. So you can just set them on a per site basis in group_vars/<env>/wordpress_sites.yml which is documented here (wp_post_revisions isn’t there, but should be since it’s supported too).

They aren’t “secrets” so they don’t need to be in vault.yml either.

I only added these 2 settings to group_vars/all/vault.yml since I’d like them to apply to all environments. If there’s another way to do that, let me know. Otherwise, yes, I’d have to add them on a per site basis like you described. I guess I just was confused about the purpose of helpers.yml … is that just for reference?

They are used in development since the deploy role isn’t included/used at all. There’s probably a better way to define them so it’s only done in one place :thinking: but while the values are the same, they access other variables in different ways so it’s hard to unify them.

So if one wants to be DRY, where is the best place to define environment variables for local/dev as well as remote environments. Is there any sort of global_env possible in all/main.yml or is all/vault.yml the only spot. Even if they are not secret.

I don’t think it’s possible unfortunately. You have to maintain the two different version of it.

I’ll give it some thought to see if any improvements can be made but it’s hard because each value is derived from a different implementation (dev vs deploy). It would be possible to extract out a common list of static/hardcoded attributes though but that’s only part of it.

Ok, thanks for the answer. In an older version of trellis I did use something called global_env: in the main.yml but that doesn’t seem to work anymore.