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

'Setup Permalink Structure' play in 'wordpress-install' does not skip sites as expected. #660

Closed
4 of 5 tasks
thisolivier opened this issue Sep 28, 2016 · 4 comments
Closed
4 of 5 tasks

Comments

@thisolivier
Copy link

Submit a feature request or bug report

Replace any X with your information.


What is the current behavior?

When running vagrant up, with the Wordpress-install role, Setup Permalink Structure does not check properly whether a Wordpress installation has taken place. If any site has installed Wordpress, that every site will attempt to setup the permalink structure.

TASK [wordpress-install : Install WP] ******************************************
changed: [default] => (item=superblog)
skipping: [default] => (item=statictest) 
changed: [default] => (item=patterncutting)
changed: [default] => (item=followerof)

...

TASK [wordpress-install : Setup Permalink Structure] ***************************
changed: [default] => (item=superblog)
---------------------------------------------------
Error: This does not seem to be a WordPress install.
Pass --path=`path/to/wordpress` or run `wp core download`.
failed: [default] (item=statictest) => {"changed": true, "cmd": ["wp", "rewrite", "structure", "/%postname%/", "--allow-root"], "delta": "0:00:00.300259", "end": "2016-09-27 10:31:47.035436", "failed": true, "item": "statictest", "rc": 1, "start": "2016-09-27 10:31:46.735177", "stderr": "Error: This does not seem to be a WordPress install.\nPass --path=`path/to/wordpress` or run `wp core download`.", "stdout": "", "stdout_lines": [], "warnings": []}

Note that the above error occurs because the site in question has a non-standard structure, however the play should not be run since site_install : false is set for this site. Hence why the wordpress-install play skips the site.

Looking at the conditional for the TASK [wordpress-install : Setup Permalink Structure], it seems as if it is checking whether the wp_install_results is marked as changed. This, I believe, is a bug (oles/wordpress-install/tasks/main.yml line:64).

when: wp_install_results | changed or wp_multisite_install_results | changed

The variable itself is as follows (from debugging). As per the expected behaviour of Anisible variables in loops, the variable has a top level 'changed' property, which will be true if any iteration of the loop has set 'changed' to true, as well as individual 'changed' properties for each interation. I've only included part of the variable so as not to clutter this report.

ok: [default] => {
    "wp_install_results": {
        "changed": true, 
        "msg": "All items completed", 
        "results": [
            {
                "_ansible_item_result": true, 
                "_ansible_no_log": false, 
                "changed": true, 
                "cmd": [
                    "wp", 
                    "core", 
                    "install", 
                    "--allow-root", 
                    "--url=http://superolivier.dev", 
                    "--title=superblog", 
                    "--admin_user=XXXXXXXXXX", 
                    "--admin_password=XXXXXXXXXX", 
                    "--admin_email=XXXXXXXXXX"
                ], 
                "delta": "0:00:04.483921", 
                "end": "2016-09-27 11:51:49.493592", 
                "invocation": {
                    "module_args": {
                        "_raw_params": "wp core install --allow-root --url=\"http://superolivier.dev\" --title=\"superblog\" --admin_user=\"XXXXXXXXXX\" --admin_password=\"XXXXXXXXXX\" --admin_email=\"XXXXXXXXXX\"", 
                        "_uses_shell": false, 
                        "chdir": "/srv/www/superblog/current/", 
                        "creates": null, 
                        "executable": null, 
                        "removes": null, 
                        "warn": true
                    }, 
                    "module_name": "command"
                }, 
                "item": {
                    "key": "superbly", 

                    "value": {
                        "admin_email": "XXXXXXXXXX", 
                        "cache": {
                            "enabled": false
                        }, 
                        "local_path": "../superblog", 
                        "multisite": {
                            "enabled": false
                        }, 
                        "site_hosts": [
                            {
                                "canonical": "superolivier.dev", 
                                "redirects": [
                                    "www.superolivier.dev"
                                ]
                            }
                        ], 
                        "ssl": {
                            "enabled": false, 
                            "provider": "self-signed"
                        }
                    }
                }, 
                "rc": 0, 
                "start": "2016-09-27 11:51:45.009671", 
                "stderr": "", 
                "stdout": "Success: WordPress installed successfully.", 
                "stdout_lines": [
                    "Success: WordPress installed successfully."
                ], 
                "warnings": []
            }, 
            ...

What is the expected or desired behavior?

Permalinks should only be setup if wordpress has been installed for a site. This would be accomplished be fixing the conditional on the permalink play to check the site specific 'changed' properties.

I believe that this is the intended behaviour of Trellis, since when ansible deploy is subsequently run, no further wordpress installs are run, hence the wp_install_results variable shows "changed": false, and all the permalink play is skipped for all sites.


Bug report

Please provide steps to reproduce, including full log output:

Set site_install: false for one site of a trellis containing more than one site. You will see that the permalink play described above still runs for that site. Logs are already detailed above.

Please describe your local environment:

Ansible version: 2.1.1.0

OS: 10.11.6

Vagrant version: 1.8.5

Where did the bug happen? Development or remote servers?

Development

Please provide a repository or your wordpress_sites config (if possible):

Documentation: https://roots.io/trellis/docs/local-development-setup/

wordpress_sites options: https://roots.io/trellis/docs/wordpress-sites

Define accompanying passwords/secrets in group_vars/development/vault.yml

wordpress_sites:
  followerof:
    site_hosts:
      - canonical: followerofnothing.dev
        redirects:
          - www.followerofnothing.dev
    local_path: ../followerof 
    admin_email: [email protected]
    multisite:
      enabled: false
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: false

  patterncutting:
    site_hosts:
      - canonical: olivier.dev
        redirects:
          - www.olivier.dev
    local_path: ../patterncutting 
    admin_email: [email protected]
    multisite:
      enabled: false
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: false

  superblog:
    site_hosts:
      - canonical: superolivier.dev
        redirects:
          - www.superolivier.dev
    local_path: ../superblog 
    admin_email: [email protected]
    multisite:
      enabled: false
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: false

  statictest:
    site_hosts:
      - canonical: static.dev
        redirects:
          - www.static.dev
    local_path: ../statictest 
    site_install: false
    db_create: false
    admin_email: [email protected]
    multisite:
      enabled: false
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: false

Apologies for any typos, my system's autocorrect went to town on this.

Is there a related Discourse thread or were any utilized (please link them)?

Installing a static site with Trellis - Note that this thread is attempting to perform non-standard actions with Trellis, whereas this bug affects standard behaviour.

@retlehs
Copy link
Member

retlehs commented Sep 28, 2016

dupe #637
fixed by #643

@retlehs retlehs closed this as completed Sep 28, 2016
@thisolivier
Copy link
Author

Not the same issue- not a multisite issue. The issue here is that permalink structure will not skip when it's supposed to. Apologies if I'm missing something.

@fullyint
Copy link
Contributor

@thisolivier Thanks for the report!
Would love it if you could test #661 given that you are so familiar with this particular issue.

@thisolivier
Copy link
Author

I can't comment on the refactoring of the multisite install (which, very elegant btw, looks like django syntax, which I didn't know came into ansible at all), but the conditional now works as expected. Many thanks!

fullyint added a commit that referenced this issue Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants