topdown / VVV-Dashboard

Dashboard for Varying Vagrant Vagrants https://github.com/Varying-Vagrant-Vagrants/VVV
253 stars 40 forks source link

Dashboard does not load domains that were provisioned via VVV #52

Open davidwolfpaw opened 7 years ago

davidwolfpaw commented 7 years ago

I'm using the new provisioning system in VVV to create sites. When the sites are complete I go to the VVV dashboard and purge the hosts cache and refresh the page. New sites show as N/A (pictured in screenshot).

All of the links also display as "N/A" for the domain portion of the URL. For instance, the link to wp-admin is http://n/A/wp-admin.

screenshot 2017-03-17 06 52 41

topdown commented 7 years ago

I always used VV but I will try to look into this weekend.

ihorvorotnov commented 7 years ago

+1, confirmed. Just upgraded to VVV 2.0 and have the same issue. VV isn't ready for VV 2.0 yet, there are couple open issues.

neilgee commented 7 years ago
screen shot 2017-03-22 at 8 40 50 am

+1, also tested the new provisioning in VVV2 - the site is provisioned but if using VVV-Dashboard it is declared as N/A in sites list

erikJonsberg commented 7 years ago

This is still an issue when using the new provisioning system in VVV2. New sites show as N/A with bad paths - http://n/A/wp-admin or http://n/A/. Using vv -create works after manually adding a new site to vvv-custom.yml but is not in line with current provisioning.

syllie commented 7 years ago

+1

There are 2 things ongoing actually. The first is that VV doesn't provision in the expected format for VVV2.0 yet. And the second is that VVV-Dashboard builds its hosts_list relying on {host_path}/vvv-hosts,

I have done a 'standard' install in VVV2.0 using the provided example setup. With the 2.0 provisioning options and the way sites are being handled everything looks quite different. Main player would be the vvv-config.yml OR vvv-custom.yml (if exists) in the root of the VVV install. This is where all 2.0 sites are listed.

Setup of the example structure site is surprisingly easy and requires just 3 lines in the new yml file using the example repo (config is provided in vvv-config.yml). A site in itself gets a new directory structure, without vvv-hosts and using public_html instead of htdocs. Provisioning information and logs reside in subdirs.

<example-site>
- log
- provision
- public_html
wp-cli.yml

The vvv-config.yml / vvv-custom.yml files allow for full customization paths (vm_dir / local_dir) but these latter can be omitted and then the new 'default' paths will be used.

With the breaking changes on the VVV2.0 release, migration documentation has been provided - but like many - I am not inclined to spend time on moving sites. So I will continue with a mix of sites in old structures - as setup by VV) and use the new VVV2.0 format setting up future developments.

I hope the above provides a little bit more insight on what has happened under the hood. I believe for the dashboard to work with VVV2.0 it has to use yml files for knowledge of the site configuration. Sites setup for VVV1.x could be added to this file.

scarstens commented 7 years ago

+1 bump

swashata commented 7 years ago

Okay. I have had the same issue and after looking into the source files, I was able to fix this with some minor modifications. Now creating a pull request.

topdown commented 7 years ago

I merged in the changes that @swashata made in the PR. Could you all do a pull on the dashboard and verify its working properly for you now. NOTE: you need to copy the newly changed dashboard-custom.php to the default root overwriting the old one or make the changes from the PR which is just an addition to the paths.

ryanemitchell commented 7 years ago

Working for me. VVV-Dashboard shows new sites created with vvv-custom.yml after manually adding the site to dashboard/vvv_dash/hosts/defaults.php

neilgee commented 7 years ago

I tried this but it's still not adding new sites provisioned in VVV2 - I am using - Version: 0.2.0, Branch: 61e7ac6 master

ryanemitchell commented 7 years ago

@neilgee Try manually adding sites created with VVV2 to dashboard/vvv_dash/hosts/defaults.php. That worked for me.

neilgee commented 7 years ago

@ryanemitchell thanks - i see in the host_list function - I was hoping the PR was going to automatically add the sites.

topdown commented 7 years ago

It should. You should not have to edit code. I'll have to setup a fresh copy and go through the code and fix what ever is missing.

topdown commented 7 years ago

Ok, I can not get the adding a new site mentioning in the first original post to work at all. So if someone wants to shed light on that because following the instructions here https://develop.varyingvagrantvagrants.org/docs/en-US/adding-a-new-site/ is not working and each provision talks 10 minutes which in my opinion is crap. After 2.5 hours of changing little things and provisioning trying to get a site loaded I am not wasting more time. So someone using this process needs to explain.

One reason the domains are not loading in VVV Dashboard is they no longer use the vvv-hosts files, which is funny because its still included with the default WP installs. So create that file, probably in the sites directory and add the domain to the first line. THen purge the dashboard cache and the domain should load. Not sure about the rest since I can't get the instructions to work.

neilgee commented 7 years ago

This is not obvious in those docs but actually you can provision in just about 20secs with a single site command - so add the site first in vvv-custom.yml like so...

  example:
    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template
    hosts:
      - example.dev

Then to provision run vagrant provision --provision-with=site-example

https://tomjn.com/2017/01/16/whats-new-vvv-2-0/

scarstens commented 7 years ago

I don't know how topdown works right now, but is it not possible for topdown to parse the vvv-custom.yml file to assess which sites are setup? Vagrant provisions have always been slow, but if you use @neilgee recommendation, it will limit the provision to just the 1 install you need to deal with.

topdown commented 7 years ago

@neilgee that command doesn't do anything for me other than add the domain to the hosts. I am using the default init, so it should be running that and downloading wp (not) When provisioning is done (only adding the domain to hosts) it just redirects to the dashboard even if I have files in the public_html. Something is missing.

topdown commented 7 years ago

Actually, I can not get anything to provision other than the default sites.

scarstens commented 7 years ago

@topdown Can you paste your yml file in here? I'm pretty sure indentation and exact syntax matters.

neilgee commented 7 years ago

I was having that behaviour at some stage - can't quite remember how it rectified, make sure you do a git pull on VVV2 to have the latest.

swashata commented 7 years ago

Okay since this is working for me (auto listing sites added with new vvv method) I am going to break it down on how this is working. I am assuming the site in question is xyz.dev so naturally it should reside inside www/xyz directory.

  1. No, it doesn't look into the vvv-custom.yaml or vvv-config.yaml file at all. I know it should, but it doesn't.
  2. It looks for directories inside www. Here in our case it finds www/xyz.
  3. For each directory it finds, it looks for a vvv-hosts and if not found provision/vvv-hosts file. This is used to get the domain name (xyz.dev). With the new method, we are supposed to place inside provision/vvv-hosts.
  4. For each directory it finds, it looks for a wp-cli.yml file from where it gets the public folder. It was htdocs before, but now it is public_html.

And that's it really. So make sure that

  1. You have vvv-hosts or provision/vvv-hosts file inside the sites directory.
  2. You have wp-cli.yml file saying path: public_html or what-ever path where WordPress is actually installed.
  3. Under www/default dashboard you have copied over the new file cp dashboard/dashboard-custom.php .
  4. You have cleared host cache under http://vvv.dev
ironicmoka commented 7 years ago

I don't have any vvv-hosts file in the www/xyz/provision/ folder, just these three:

I did a fresh vvv installation after VVV2 was relased, and I created all website with the new yml method

neilgee commented 7 years ago

Same here, confirm that no vvv-hosts file in newly provisioned sites in VVV2 .

swashata commented 7 years ago

@ironicmoka @neilgee

I see that. So with the new provisioning I need to read settings from the vvv-custom.yml file. I will see if I can make something like that. But for now, could you please put a vvv-hosts file inside provision directory with the following content

yoursite.dev

This won't break anything and VVV dashboard will start working again.

Mte90 commented 7 years ago

Any updates for that? In the meantime I changed on hosts.php line 85 "N/A" with basename($this->host_path) . '.dev' in that way also on N/A the domain is right because often the folder name is the same of the domain

topdown commented 7 years ago

I added a new branch vvv2 with @Mte90 suggestion above if you guys want to checkout that branch and try it.

topdown commented 7 years ago

I still can not get VVV2 to do anything with vvv-custom.yml So testing the custom site setup via https://github.com/Varying-Vagrant-Vagrants/custom-site-template is useless and does literally nothing. I don't know how you guys are getting it to work but at this point, the custom site thing and vvv2 are no good to me and has already cost me 4 days of screwing around trying to get this to work.

The reality is for me to work on the dashboard VVV2 and the custom site process has to be working and it's just not on my end. No idea why.

Mte90 commented 7 years ago

Hoping that can help this is my vvv-custom.yml https://gist.github.com/Mte90/a94e6fb73f68f0958809308dea94c2d3 Also I saw (already reported) that if the folder of the new website added not exist on VVV/www doesn't exist doesn't download anything. The commando vagrant --provision-with site-name do the provision only of the new website.

topdown commented 7 years ago

@Mte90 I striped yours down to just the demo site https://gist.github.com/topdown/4fbb740ffc7c6e875c23caaf9f2aa15c Then created the folder demo Ran vagrant provision --provision-with=demo It created the host entry and ended, screenshot attached. No downloading or anything, its like the process just ends. This is the same result I have been having the entire time. I event reinstalled triggers and hostupdater thinking maybe that would fix it. screen shot 2017-08-17 at 11 40 50 am

Mte90 commented 7 years ago

Seems that this flag is not working :-/

swashata commented 7 years ago

So I added a site through VVV default provisioning. https://github.com/Varying-Vagrant-Vagrants/custom-site-template

Then inside provision directory, I just dropped a file vvv-hosts with mysite.dev content and it started showing in the dashboard.

So for VVV-Dashboard to fully work with new provisioning, we need to parse the vvv-custom.yml file.

@topdown How would you prefer doing it? Perhaps getting the yaml parser from symphony? Are you open to using composer as dependency? If so, then maybe I can cook something up.

scarstens commented 7 years ago

Why wouldn't you just use PHP core? http://php.net/manual/en/function.yaml-parse.php

swashata commented 7 years ago

Because it's a PECL function, not built into the core.

2017-09-01_9-44-36

scarstens commented 7 years ago

oh, yup, good point.

topdown commented 7 years ago

@swashata There's pros and cons to dependencies. One issue is that it requires people to install composer and install the dependency. But if they made it this far they already ran enough commands that they should be able to handle it. If we actually include it, then it removes that step for dashboard users but then it's one more thing to manage versions on and defeats one of the purposes of composer.

We could just read the yaml lines in the files and load hosts: sections. It might take a little matching and excluding but should be doable without the dependencies. Unless you can think of a reason why that would be a bad idea?

One thing I want to make sure of is that the old way of pulling domains in stays in tact (backward compatible) so that VVV1 users don't end up broken. So for anything major use the vvv2 branch so worse case, we can make separate releases.

swashata commented 7 years ago

@topdown Very well. We can perhaps just bring in the files instead of using composer and load them manually. I will see over this weekend and if everything goes smoothly send in a pull request.

JPry commented 7 years ago

@topdown

I'm not sure if this is something that you already worked out, but just in case you didn't I wanted to reply to your previous comment

Then created the folder demo Ran vagrant provision --provision-with=demo It created the host entry and ended, screenshot attached. No downloading or anything, its like the process just ends. This is the same result I have been having the entire time. I event reinstalled triggers and hostupdater thinking maybe that would fix it.

For this specific instance, the flag is --provision-with, and the value needs to be prefixed with site-. So the correct command should be vagrant provision --provision-with site-demo.

In regards to parsing the vvv-custom.yml file, I'm 👍 to using the Symfony YAML component. That's what I use in vvv-base.

7bitsio commented 6 years ago

@topdown @Mte90

I'v been out of the coding game for a while and I'm new to Git and VVV, so I'm not sure what I did is right or it would break anything but I made a workaround, and now any new site I provision is showing up correctly in the dashboard. Please give me your thoughts I would love to learn from you guys.

so I added a line to the "provision-site.sh" which I know is not part of this dashboard but part of VVV itself in the provision folder, I'm making this comment here because my interest was to have the site show up in the dashboard.

so after this part in the code:

for line in `cat ${VVV_CONFIG} | shyaml get-values sites.${SITE_ESCAPED}.hosts 2> /dev/null`; do
  if [[ -z "$(grep -q "^127.0.0.1 $line$" /etc/hosts)" ]]; then
  echo "127.0.0.1 $line # vvv-auto" >> "/etc/hosts"
  echo " * Added $line from ${VVV_CONFIG}"

  # add this lines
        echo "$line" > "$DIR/vvv-hosts"
  # to get inline confirmation
        echo " ** Added $line to $DIR/vvv-hosts"

As I said after years of break from coding I consider myself a newbie and this is my first attempt to help (so take it easy on me if what I'm doing or saying is stupid) :) and would appreciate any comments to help me learn and contribute to the community.

vertizio commented 6 years ago

Thank you @7bitsio. Your solution worked for me!

Mte90 commented 6 years ago

This patch works because reimplement the old behaviour of VVV 1.x, the 2.x use a yaml file for that informations. Also I think that will be not implemented back in VVV 2.x, the only way is add the support in the dashboard to parse the yaml file.

7bitsio commented 6 years ago

you made my day @phsab , I'm very happy to help

@Mte90 , I agree with you, but until that time I think this is the easiest and quickest solution for now

topdown commented 6 years ago

Just a heads up, they now added a version file to VVV https://github.com/Varying-Vagrant-Vagrants/VVV/blob/develop/version

This will allow dashboards and other tools to do a version check of VVV to maintain backward compatibility.

tomjn commented 6 years ago

Dashboards should parse vvv-custom.yml to get a list of hosts, as the default dashboard does via a PHP YAML parser, which you're welcome to reuse.

If after that you want to augment the listing with hosts from vvv_hosts files then that's great, but it shouldn't be the other way around.

I would advise that:

This way, someone visits the git repo, copy pastes the site entry from the readme into vvv-custom.yml, and runs vagrant provision, and hey presto, it checks out a copy of the site and runs all the setup scripts for you.

I doubt that in the future VVV will eliminate vvv_hosts support as it would break a lot of things, but a potential stopgap is to move the reading of vvv_hosts out of VVV into the site provisioner itself. vvv-init.sh can already add arbitrary hosts programmatically by adding them to the hosts file and using an Nginx config

tomjn commented 6 years ago

Oh and don't use vv. If you do, bring out the flamethrower and burn it with the fire of a thousand suns. It does not do things properly in VVV 1, and it definitely doesn't do things properly in VVV 2, and it does so in a destructive and fragile manner by reaching into the VM and modifying things. That these vv created sites don't explode when the VM is recreated surprises me