Roots Discourse

TASK [deploy : Install Composer dependencies] in build-after gives ValueError: No JSON object could be decoded

Hello!

I’m deploying a site and I’m getting an error during the task Install Composer dependencies which is defined in roles/deploy/hooks/build-after.yml. It looks like python is unable to decode the composer.json. Here is my build-after.yml:

---
- name: Check for composer.json in project root or project_subtree_path
  stat:
    path: "{{ deploy_helper.new_release_path }}/composer.json"
  register: composer_json

- name: Fail if composer.json not found
  fail:
    msg: "Unable to find a `composer.json` file in the root of '{{ deploy_helper.new_release_path }}'. Make sure your repo has a `composer.json` file in its root or edit `repo_subtree_path` for '{{ site }}' in `wordpress_sites.yml` so it points to the directory with a `composer.json` file."
  when: not composer_json.stat.exists

- name: Setup composer authentications
  composer:
    command: config
    arguments: --auth http-basic.{{ composer_authentication.hostname }} {{ composer_authentication.username }} {{ composer_authentication.password }}
    working_dir: "{{ deploy_helper.new_release_path }}"
  no_log: true
  changed_when: false
  when:
    - composer_authentication.hostname is defined and composer_authentication.hostname != ""
    - composer_authentication.username is defined and composer_authentication.username != ""
    - composer_authentication.password is defined and composer_authentication.password != ""
  loop: "{{ composer_authentications }}"
  loop_control:
    loop_var: composer_authentication
    label: "{{ composer_authentication.hostname }}"

- name: Install Composer dependencies
  composer:
    no_scripts: "{{ composer_no_scripts }}"
    classmap_authoritative: "{{ composer_classmap_authoritative }}"
    working_dir: "{{ deploy_helper.new_release_path }}"

And here is the error I get:

MODULE FAILURE
See stdout/stderr for the exact error
Traceback (most recent call last):
  File "<stdin>", line 114, in <module>
  File "<stdin>", line 106, in _ansiballz_main
  File "<stdin>", line 49, in invoke_module
  File "/tmp/ansible_composer_payload_HDTHrW/__main__.py", line 271, in
<module>
  File "/tmp/ansible_composer_payload_HDTHrW/__main__.py", line 217, in main
  File "/tmp/ansible_composer_payload_HDTHrW/__main__.py", line 170, in
get_available_options
  File "/tmp/ansible_composer_payload_HDTHrW/ansible_composer_payload.zip/ans
ible/module_utils/basic.py", line 1997, in from_json
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

The full traceback is:
Traceback (most recent call last):
  File "<stdin>", line 114, in <module>
  File "<stdin>", line 106, in _ansiballz_main
  File "<stdin>", line 49, in invoke_module
  File "/tmp/ansible_composer_payload_HDTHrW/__main__.py", line 271, in <module>
  File "/tmp/ansible_composer_payload_HDTHrW/__main__.py", line 217, in main
  File "/tmp/ansible_composer_payload_HDTHrW/__main__.py", line 170, in get_available_options
  File "/tmp/ansible_composer_payload_HDTHrW/ansible_composer_payload.zip/ansible/module_utils/basic.py", line 1997, in from_json
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

I’m using trellis 1.5.0 with ansible 2.8.0.

I don’t really know how to debug this or what is causing this error. I’ve deployed a lot of sites without any problems on Kinsta servers before, but this time I’m bound to a Plesk server. Could it be a permission/ownership issue? I hope someone has an idea where to start or where to look to solve this!

Thanks!

This isn’t much help but I’ve never seen this error before (and this forum has been a lot of Ansible errors over the years).

Maybe try a newer/older Ansible version? I’d try searching ansible’s issues on GitHub as well.

This has cropped for me as well trying to deploy to an older trellis install. I’'m using Ansible 2.2.0.0 under virtualenv. Seems to be an unclear error to another issue but I haven’t figured that out yet. There’s a few of these on ansible’s git and none of them seem to be the same or get solved that same.

I eventually deployed using deployer.org, with some recipes from https://github.com/FlorianMoser/plesk-deployer to get my site working on a Plesk-server with releases, shared files/folders an everything. It doesn’t solve the issue, but at least I can have a deploy script which was the ultimate goal for me.