Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to restart development on provision #451

Open
dalepgrant opened this issue Aug 21, 2024 · 1 comment
Open

Add a flag to restart development on provision #451

dalepgrant opened this issue Aug 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@dalepgrant
Copy link
Sponsor

Summary

Would a flag to also restart the vm on provision be possible, something like trellis provision --reload --tags wordpress development (taking reload from vagrant)?

Currently to perform actions such as adding a new site, assuming the vm/vagrant is running, you must do the following:

  • trellis vm stop (or trellis down for vagrant)
  • trellis vm start (or trellis up for vagrant)
  • trellis provision --tags wordpress development

If you don't perform these steps, the provision fails on "Setup composer authentications":

TASK [wordpress-install : Setup composer authentications (HTTP Basic) - example.com] ***
failed: [default] (item=default-type.composer.deliciousbrains.com) => {"ansible_loop_var": "item", "changed": false, "item": {"hostname": "composer.deliciousbrains.com", "password": "hahayeahright", "username": "notleavingthishere"}, "msg": "In ConfigCommand.php line 218: File \"./composer.json\" cannot be found in the current directory config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [-j|--json] [-m|--merge] [--append] [--source] [--] [<setting-key> [<setting-value>...]]", "stdout": "\nIn ConfigCommand.php line 218:\n                                                                   \n  File \"./composer.json\" cannot be found in the current directory [the rest redacted, you get the gist]

This is because the folders haven't been mounted yet. Navigating to the site folder within the vm/vagrant box shows only an empty web folder, hence the composer.json cannot be found error.

Additional context

Originally posted by @dalepgrant in #421 (comment)

As ever, thank you Roots team 🙏

@dalepgrant dalepgrant added the enhancement New feature or request label Aug 21, 2024
@dalepgrant dalepgrant changed the title Add a flag to restart on provision Add a flag to restart development on provision Aug 21, 2024
@swalkinshaw
Copy link
Member

🤔 trellis provision --reload --tags wordpress development would be nice, but --reload assumes that provision even knows about a running VM or not... which it currently does not. Maybe it should but it doesn't 😅 Right now it attempts to determine which type of VM you're using (Vagrant or Lima) to set the properly inventory though even that can be naive.

Basically, it's easier to detect that Lima needs to be restarted by checking the generated config file than it is to actually restart it for you. Although, we could always just fire off vm stop && vm start commands and if it works, it works?

This brings up some other options and improvements:

  1. dev.yml playbook (or some role/task within it) should probably check + return a nice error if the /current folder is empty in Trellis itself. Pretty bad experience as is right now that it just randomly fails on the first task that tries to use that directory.
  2. if this is only an issue when adding a new site, what about Feature Request: "add" command for adding extra sites #390? Then instead of having to trellis provision --reload --tags wordpress development, we'd move all of that into trellis site add --provision or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants