nextcloud / ansible-collection-nextcloud-admin

The ansible galaxy for your nextcloud administrative needs.

Home Page:https://galaxy.ansible.com/nextcloud/admin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installing required and recommended PHP packages fails

juius-b opened this issue · comments

commented

While installing the required and recommended PHP packages on a vagrant virtual machine with Ubuntu 22.04 LTS, the role consistenly fails to install the seventh package cURL. The following shows the relevant parts of the error message:

TASK [nextcloud.admin.install_nextcloud : [PHP] - Required and recommended packages are installed.] ***
changed: [default] => (item=imagemagick)
[...]
changed: [default] => (item=php8.1-imap)
failed: [default] (item=php8.1-curl) => changed=false
  ansible_loop_var: item
  cache_update_time: 1681750513
  cache_updated: false
  item: php8.1-curl
  msg: |-
    '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"       install 'php8.1-curl=8.1.18-1+ubuntu22.04.1+deb.sury.org+1'' failed: E: Sub-process /usr/bin/dpkg returned an error code (1)
  rc: 100
  stderr: |-
    E: Sub-process /usr/bin/dpkg returned an error code (1)
  stderr_lines: <omitted>
  stdout: |-
    Reading package lists...
    Building dependency tree...
    Reading state information...
    The following NEW packages will be installed:
      php8.1-curl
    0 upgraded, 1 newly installed, 0 to remove and 75 not upgraded.
   [...]
    Setting up php8.1-curl (8.1.18-1+ubuntu22.04.1+deb.sury.org+1) ...

    Creating config file /etc/php/8.1/mods-available/curl.ini with new version
    Processing triggers for php8.1-fpm (8.1.18-1+ubuntu22.04.1+deb.sury.org+1) ...
    Job for php8.1-fpm.service failed.
    See "systemctl status php8.1-fpm.service" and "journalctl -xeu php8.1-fpm.service" for details.
    invoke-rc.d: initscript php8.1-fpm, action "restart" failed.
    [0;1;31m×[0m php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
         Loaded: loaded (]8;;file://ubuntu2204.localdomain/lib/systemd/system/php8.1-fpm.service/lib/systemd/system/php8.1-fpm.service]8;;; enabled; vendor preset: enabled)
         Active: [0;1;31mfailed[0m (Result: start-limit-hit) since Mon 2023-04-17 16:55:52 UTC; 4ms ago
           Docs: ]8;;man:php-fpm8.1(8)man:php-fpm8.1(8)]8;;
        Process: 21588 ExecStart=/usr/sbin/php-fpm8.1 --nodaemonize --fpm-config /etc/php/8.1/fpm/php-fpm.conf (code=exited, status=0/SUCCESS)
        Process: 21591 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, status=0/SUCCESS)
        Process: 21936 ExecStopPost=/usr/lib/php/php-fpm-socket-helper remove /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, status=0/SUCCESS)
       Main PID: 21588 (code=exited, status=0/SUCCESS)
         Status: "Ready to handle connections"
            CPU: 30ms

    Apr 17 16:55:50 ubuntu2204.localdomain systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...
    Apr 17 16:55:50 ubuntu2204.localdomain systemd[1]: Started The PHP 8.1 FastCGI Process Manager.
    Apr 17 16:55:52 ubuntu2204.localdomain systemd[1]: Stopping The PHP 8.1 FastCGI Process Manager...
    Apr 17 16:55:52 ubuntu2204.localdomain systemd[1]: php8.1-fpm.service: Deactivated successfully.
    Apr 17 16:55:52 ubuntu2204.localdomain systemd[1]: Stopped The PHP 8.1 FastCGI Process Manager.
    Apr 17 16:55:52 ubuntu2204.localdomain systemd[1]: [0;1;38;5;185m[0;1;39m[0;1;38;5;185mphp8.1-fpm.service: Start request repeated too quickly.[0m
    Apr 17 16:55:52 ubuntu2204.localdomain systemd[1]: [0;1;38;5;185m[0;1;39m[0;1;38;5;185mphp8.1-fpm.service: Failed with result 'start-limit-hit'.[0m
    Apr 17 16:55:52 ubuntu2204.localdomain systemd[1]: [0;1;31m[0;1;39m[0;1;31mFailed to start The PHP 8.1 FastCGI Process Manager.[0m
    dpkg: error processing package php8.1-fpm (--configure):
     installed php8.1-fpm package post-installation script subprocess returned error exit status 1
    Processing triggers for php8.1-cli (8.1.18-1+ubuntu22.04.1+deb.sury.org+1) ...
    Errors were encountered while processing:
     php8.1-fpm
    needrestart is being skipped since dpkg has failed
  stdout_lines: <omitted>
changed: [default] => (item=php8.1-intl)
changed: [default] => (item=php8.1-bz2)

systemd seems to have a limit of 5 restarts per 10 seconds which is violated by this task. As it is the seventh package, it triggers the sixth restart, causing the failure.

Looking at the tasks of the install_nextcloud role, I suspected the loop with_items with the builtin package module to be the problem. Removing this loop and naming the packages explicitly removed the issue. I then had the same issue with the following tasks that installs extra PHP packages. There, as the variable that provides the loop with items already is a list, it can be specified as the name directly, eliminating the need for a loop.

commented

Sorry, I have never done this before. How do I share my proposed changes with you?

Hi @juius-b! Thanks for your report. Are you running collection/role with some modifications or with default values? Molecule test actually checking installing this packages on Ubuntu22.04 for different versions of NC and it seems to work fine, so that's why I'm asking for more details.
Here's last test run for Ubuntu22.04 NC26: https://github.com/nextcloud/ansible-collection-nextcloud-admin/actions/runs/4819149181/jobs/8581993243#step:7:213

It's possible that there is some bug in Ansible itself, but we can take a closer look.
WDYT @aalaesar @staticdev?

Hello there.
Could comes from many things like apt config somehow different in the host.
I suspect a config failure on php that make systemd restarting it too many times

commented

Are you running collection/role with some modifications or with default values?

Yes, the issue already occurred when I was running the role with default values and I also just double checked. I'm using this vagrant box for testing.

Curiously, on my second "double-check" it worked without errors but failed on my third ... Maybe you can reproduce a failed run at least once, too?

As a note on efficiency, the apt module discourages the use of :loops and the package module seems to call it.

So far, the pipeline only covers Debian and Ubuntu, but builtin package managers yum and dnf, as well as community maintained package managers pacman and apk support passing a list to the name option directly, too.

Hi @juius-b! Sorry for late response. Thanks for your contribution, it makes sense nowadays. It was a loop since forever - probably it was not compatible in the past.