roots / trellis

WordPress LEMP stack with PHP 8.2, Composer, WP-CLI and more
https://roots.io/trellis/
MIT License
2.51k stars 607 forks source link

Install Dependencies with Composer Issue #1263

Closed tonybeato closed 3 years ago

tonybeato commented 3 years ago

Description

Initial "vagrant up" fails at the "Install Dependencies with Composer" task.

Steps to reproduce

  1. Follow steps at https://roots.io/docs/trellis/master/installation/#create-a-project
  2. Edit group_vars/development/wordpress_sites.yml & vault.yml config files
  3. In the trellis directory, run "vagrant up"

Error Message (verbose):

task path: /Users/USERNAME/sites/samplesite.com/trellis/roles/wordpress-install/tasks/main.yml:24
redirecting (type: modules) ansible.builtin.composer to community.general.composer
Using module file /Users/USERNAME/.pyenv/versions/3.8.1/lib/python3.8/site-packages/ansible_collections/community/general/plugins/modules/composer.py
Pipelining is enabled.
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: vagrant
<127.0.0.1> SSH: EXEC ssh -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/Users/USERNAME/sites/samplesite.com/trellis/.vagrant/machines/default/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="vagrant"' -o ConnectTimeout=30 -o ControlPath=/Users/USERNAME/.ansible/cp/055b8f4af0 127.0.0.1 '/bin/sh -c '"'"'python3 && sleep 0'"'"''
<127.0.0.1> (1, b'', b'Traceback (most recent call last):\n  File "<stdin>", line 102, in <module>\n  File "<stdin>", line 94, in _ansiballz_main\n  File "<stdin>", line 40, in invoke_module\n  File "/usr/lib/python3.8/runpy.py", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code\n    exec(code, run_globals)\n  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 267, in <module>\n  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 213, in main\n  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 166, in get_available_options\n  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible/module_utils/basic.py", line 2140, in from_json\n  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads\n    return _default_decoder.decode(s)\n  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode\n    raise JSONDecodeError("Expecting value", s, err.value) from None\njson.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)\n')
<127.0.0.1> Failed to connect to the host via ssh: Traceback (most recent call last):
  File "<stdin>", line 102, in <module>
  File "<stdin>", line 94, in _ansiballz_main
  File "<stdin>", line 40, in invoke_module
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 267, in <module>
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 213, in main
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 166, in get_available_options
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible/module_utils/basic.py", line 2140, in from_json
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
System info:
  Ansible 2.10.4; Vagrant 2.2.7; Darwin
  Trellis version (per changelog): "Validate that `letsencrypt_contact_emails` is a list"
---------------------------------------------------
MODULE FAILURE
See stdout/stderr for the exact error
Traceback (most recent call last):
  File "<stdin>", line 102, in <module>
  File "<stdin>", line 94, in _ansiballz_main
  File "<stdin>", line 40, in invoke_module
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/a
nsible_collections/community/general/plugins/modules/composer.py", line 267,
in <module>
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/a
nsible_collections/community/general/plugins/modules/composer.py", line 213,
in main
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/a
nsible_collections/community/general/plugins/modules/composer.py", line 166,
in get_available_options
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/a
nsible/module_utils/basic.py", line 2140, in from_json
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
The full traceback is:
Traceback (most recent call last):
  File "<stdin>", line 102, in <module>
  File "<stdin>", line 94, in _ansiballz_main
  File "<stdin>", line 40, in invoke_module
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 267, in <module>
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 213, in main
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible_collections/community/general/plugins/modules/composer.py", line 166, in get_available_options
  File "/tmp/ansible_composer_payload_mfuo3k1v/ansible_composer_payload.zip/ansible/module_utils/basic.py", line 2140, in from_json
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
failed: [default] (item={'key': 'samplesite.com', 'value': {'site_hosts': [{'canonical': 'samplesite.test', 'redirects': ['www.samplesite.test']}], 'local_path': '../site', 'admin_email': 'admin@samplesite.test', 'multisite': {'enabled': False}, 'ssl': {'enabled': False, 'provider': 'self-signed'}, 'cache': {'enabled': False}}}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "key": "samplesite.com",
        "value": {
            "admin_email": "admin@samplesite.test",
            "cache": {
                "enabled": false
            },
            "local_path": "../site",
            "multisite": {
                "enabled": false
            },
            "site_hosts": [
                {
                    "canonical": "samplesite.test",
                    "redirects": [
                        "www.samplesite.test"
                    ]
                }
            ],
            "ssl": {
                "enabled": false,
                "provider": "self-signed"
            }
        }
    },
    "module_stdout": "",
    "rc": 1
}

Reproduces how often:

I've experienced the error consistently on multiple new installs of the latest version of Trellis.

Versions

Trellis v1.7.0

HEAD Validate that letsencrypt_contact_emails is a list (#1250) Add config for PHP CLI (#1261)

-macOS Big Sur v11.0.1 -Ansible v2.10.4 -Composer v2.0.8

Additional information

Reverting Trellis version back to [2383753] temporarily solved the issue.

rkaalma commented 3 years ago

+1 Having the same behavior.

swalkinshaw commented 3 years ago

Okay... finally tracked down the problem. I should have paid more attention to the commit you said broke this @tonybeato. I naively thought the 2 PRs merged since then couldn't possibly have broken it. Turns out https://github.com/roots/trellis/pull/1261 broke this.

Summary:

Deprecated: Directive 'track_errors' is deprecated in Unknown on line 0


* obviously that isn't valid JSON, which caused the JSON decoding error you saw
* #1261 defined the PHP CLI config with that deprecated option which broke it

So before this, we never had a config for PHP CLI and everything was fine 😅 

Conclusion: https://github.com/roots/trellis/pull/1264 is the fix for this
dirad commented 3 years ago

For me, updating and running again still failed in the same spot.

TASK [ntp : Populate service facts.] *******************************************
System info:
  Ansible 2.8.0; Vagrant 2.2.14; Linux
  Trellis version (per changelog): "Fix #1263 - Remove deprecated PHP option `track_errors`"
---------------------------------------------------
Malformed output discovered from systemd list-unit-files: accounts-
daemon.service                enabled         enabled
fatal: [default]: FAILED! => {"changed": false}

RUNNING HANDLER [fail2ban : restart fail2ban] **********************************
changed: [default]

RUNNING HANDLER [ferm : restart ferm] ******************************************
skipping: [default]

PLAY RECAP *********************************************************************
default                    : ok=30   changed=11   unreachable=0    failed=1    skipped=16   rescued=0    ignored=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
swalkinshaw commented 3 years ago

@dirad that isn't the same spot and it's not related to Composer? It failed on TASK [ntp : Populate service facts.].

See https://discourse.roots.io/t/trellis-malformed-output-discovered-from-systemd-list-unit-files-accounts-daemon-service/19628/6