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

Php 8.0 install error caused by php-json #57

Closed
hedii opened this issue Dec 6, 2020 · 10 comments
Closed

Php 8.0 install error caused by php-json #57

hedii opened this issue Dec 6, 2020 · 10 comments

Comments

@hedii
Copy link

hedii commented Dec 6, 2020

Hi,
This line is problematic when installing php 8.0 on a Debian system :

- "php{{ php_version }}-json"

php-json is packaged with php 8.0 by default, we get the error: Package 'php8.0-json' has no installation candidate

fatal: [monitoring01]: FAILED! => {
    "cache_update_time": 1607244127,
    "cache_updated": false,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "force_apt_get": false,
            "install_recommends": false,
            "name": [
                "php8.0",
                "php8.0-apcu",
                "php8.0-cli",
                "php8.0-common",
                "php8.0-curl",
                "php8.0-dev",
                "php8.0-fpm",
                "php8.0-gd",
                "php8.0-imap",
                "php8.0-json",
                "php8.0-mbstring",
                "php8.0-opcache",
                "php8.0-sqlite3",
                "php8.0-xml",
                "php8.0-yaml"
            ],
            "only_upgrade": false,
            "package": [
                "php8.0",
                "php8.0-apcu",
                "php8.0-cli",
                "php8.0-common",
                "php8.0-curl",
                "php8.0-dev",
                "php8.0-fpm",
                "php8.0-gd",
                "php8.0-imap",
                "php8.0-json",
                "php8.0-mbstring",
                "php8.0-opcache",
                "php8.0-sqlite3",
                "php8.0-xml",
                "php8.0-yaml"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "update_cache_retries": 5,
            "update_cache_retry_max_delay": 12,
            "upgrade": null
        }
    },
    "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"      install 'php8.0' 'php8.0-apcu' 'php8.0-cli' 'php8.0-common' 'php8.0-curl' 'php8.0-dev' 'php8.0-fpm' 'php8.0-gd' 'php8.0-imap' 'php8.0-json' 'php8.0-mbstring' 'php8.0-opcache' 'php8.0-sqlite3' 'php8.0-xml' 'php8.0-yaml' -o APT::Install-Recommends=no' failed: E: Package 'php8.0-json' has no installation candidate\n",
    "rc": 100,
    "stderr": "E: Package 'php8.0-json' has no installation candidate\n",
    "stderr_lines": [
        "E: Package 'php8.0-json' has no installation candidate"
    ],
    "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nPackage php8.0-json is a virtual package provided by:\n  php8.0-phpdbg 8.0.0-1+0~20201206.6+debian9~1.gbp33744b\n  php8.0-fpm 8.0.0-1+0~20201206.6+debian9~1.gbp33744b\n  php8.0-cli 8.0.0-1+0~20201206.6+debian9~1.gbp33744b\n  php8.0-cgi 8.0.0-1+0~20201206.6+debian9~1.gbp33744b\n  libphp8.0-embed 8.0.0-1+0~20201206.6+debian9~1.gbp33744b\n  libapache2-mod-php8.0 8.0.0-1+0~20201206.6+debian9~1.gbp33744b\n\n",
    "stdout_lines": [
        "Reading package lists...",
        "Building dependency tree...",
        "Reading state information...",
        "Package php8.0-json is a virtual package provided by:",
        "  php8.0-phpdbg 8.0.0-1+0~20201206.6+debian9~1.gbp33744b",
        "  php8.0-fpm 8.0.0-1+0~20201206.6+debian9~1.gbp33744b",
        "  php8.0-cli 8.0.0-1+0~20201206.6+debian9~1.gbp33744b",
        "  php8.0-cgi 8.0.0-1+0~20201206.6+debian9~1.gbp33744b",
        "  libphp8.0-embed 8.0.0-1+0~20201206.6+debian9~1.gbp33744b",
        "  libapache2-mod-php8.0 8.0.0-1+0~20201206.6+debian9~1.gbp33744b",
        ""
    ]
}
@frock81
Copy link

frock81 commented Dec 18, 2020

I stumbled upon this issue when trying to use php-versions role in conjunction with the php role. I tried setting the variable php_packages: ["php8.0"] of the php role to get around installing php8.0-json. The problem is that the php_packages is only set in that role if it was not defined before (line 20 task of geerlingguy.php/tasks/main.yml), thus it gets the default __php_packages. And the php_packages variable is defined (conditionally to hostvars) in the php-versions role (line 8 taks of geerlingguy.php-versions/tasks/main.yml).

I circumvent the problem by setting the php_packages between the roles execution:

---
- hosts: all
  tasks:
    - name: import php-versions role
      import_role:
        name: geerlingguy.php-versions

    - name: "set php_packages fact to circumvent issue #57"
      set_fact:
        php_packages:
          - php8.0

    - name: import php installation role
      import_role:
        name: geerlingguy.php

After that the installation proceeded. Maybe using hostvars is another way to make it work.

I don't have a good proposal to fix. Perhaps the same pattern of the php version role can be used in the php-versions role and set php_packages to __php_packages only if it is not defined before.

@frock81
Copy link

frock81 commented Dec 23, 2020

On a second thought, these are two different problems. One is php8.0-json on a Debian as reported (which release?) or Ubuntu Focal, which I'm using, system and the other is the usage of the two roles with the php_packages variable.

@hedii
Copy link
Author

hedii commented Dec 23, 2020

One is php8.0-json on a Debian as reported (which release?)

Debian 9

@rtuin
Copy link

rtuin commented Jan 8, 2021

I've also ran into this issue. Didn't find a way around except commenting the php-json line in the vars file.
I'd be happy to contribute a fix on this, however not sure what a good approach would be.
Do you have any suggestions here @geerlingguy?

@geerlingguy
Copy link
Owner

This was fixed today in PR #64 — thanks!

@federicoaaguirre
Copy link

Hi there, in debian 10 it is still failing:
fatal: [127.0.0.1]: FAILED! => {"failed": true, "msg": "The conditional check 'php_version is version('8.0', '>=')' failed. The error was: template error while templating string: no test named 'version'. String: {% if php_version is version('8.0', '>=') %} True {% else %} False {% endif %}\n\nThe error appears to have been in '/tmp/packer-provisioner-ansible-local/6068f2d6-4802-f5b4-976d-d2fb215b759d/roles-galaxy/php-versions/tasks/main.yml': line 8, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Remove missing JSON extension for PHP 8.0 (included by default)\n ^ here\n"}

I've override php_version var with '7.4'

@geerlingguy
Copy link
Owner

@federicoaaguirre - What version of Ansible are you running? It looks like the version you're running is missing the version() jinja2 test plugin.

@federicoaaguirre
Copy link

Hi @geerlingguy thanks for your quick response.! I'm try it with 2.4.4 and also i've tried it with 2.9.

@geerlingguy
Copy link
Owner

Ansible 2.4 is extremely out of date (it's been out of support for a couple years).

2.9 or later should work perfectly fine though. If you can confirm that you have installed Ansible 2.9 and you're still getting that error, please consider opening a new bug report.

@federicoaaguirre
Copy link

@geerlingguy thansk again it works perfect with 2.9.

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

5 participants