Closed jt-adwisemedia closed 2 years ago
Probably makes sense to support natively. In the meantime, I think you could use extra vars:
trellis deploy --extra-vars ansible_limit=kinsta_production production
@jt-adwisemedia I assume you're using the limit
option because of this guide? https://kinsta.com/blog/bedrock-trellis/
In most cases, limit
shouldn't be needed at all because there's only one host per environment. Ie: one staging server, one production server, etc.
We'll try and get that guide updated because limit
seems redundant. This means you also don't need that option when using the CLI. You can verify this by just running trellis deploy production
and making sure it does the same thing as with --limit
.
If there's a difference, feel free to re-open this issue.
@swalkinshaw I've come here looking for exactly this. Example of a use case here in Roots Discourse.
We have our Trellis structured as follows:
trellis/
├── group_vars/
└── production/
├── main.yml
└── vault.yml
└── staging/
└── host_vars
└── server1/
└── wordpress_sites.yml
└── server2/
└── staging1/
└── staging2/
Our deploy then looks like this with the old deploy.sh script:
./bin/deploy.sh production domain.example --limit=server1
Not strictly related to this issue, but if I try to run your suggestion while provisioning, trellis-cli gives an error
trellis provision --extra-vars ansible_limit=server1 production
Error: production is not a valid environment, valid options are [development]
That should work... can you try it with quotes?
trellis provision --extra-vars "ansible_limit=server1" production
Wait sorry I misread that error message. It's handling the command correctly but it's only detecting the development
environment for some reason?
Do you not have a wordpress_sites.yml
file under production
? That's how it detects environments
No, the wordpress_sites.yml
files are under the host_vars
folders, one per server so we can choose which site(s) sit where.
Opened a new issue for that: https://github.com/roots/trellis-cli/issues/278
Summary
Add support for the
--limit
flag for thetrellis deploy <environment>
command, currently we have to write the entireansible-playbook deploy.yml -e env=production -e site=yoursite.tld --limit=kinsta_production
, would be nice if you could just writetrellis deploy production --limit=kinsta_production
.Motivation
Nice quality of life change, convenience.