# Ansible apt upgraded accidently PHP 8.2 to 8.3

**URL:** <https://forum.ansible.com/t/ansible-apt-upgraded-accidently-php-8-2-to-8-3/3390>\
**Category:** Get Help\
**Tags:** apt, php, playbook, debian\
**Created:** [January 18, 2024, 7:35pm UTC](https://forum.ansible.com/t/ansible-apt-upgraded-accidently-php-8-2-to-8-3/3390 "2024-01-18T19:35:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![righter83](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/righter83/32/2032_2.png) [@righter83](https://forum.ansible.com/u/righter83)\
**Post date:** [January 18, 2024, 7:35pm UTC](https://forum.ansible.com/t/ansible-apt-upgraded-accidently-php-8-2-to-8-3/3390/1 "2024-01-18T19:35:57Z")

</div>

Hi

I had a strange issue before on a Debian 12 server.  
I update our Debian server with Ansible:

```auto
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
apt: upgrade=dist force_apt_get=yes

```

This resulted then to this on the affected server:

```auto
Commandline: /usr/bin/apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold dist-upgrade
Install: php8.3-xml:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-zip:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-mbstring:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-common:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-readline:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-opcache:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-curl:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-mysql:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), linux-image-5.10.0-27-amd64:amd64 (5.10.205-2, automatic), php8.3-bz2:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-cli:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-fpm:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic), php8.3-gd:amd64 (8.3.1-1+0~20231221.15+debian11~1.gbp28f2f4, automatic)
Upgrade: php-gd:amd64 (2:8.2+93+0~20231125.47+debian11~1.gbpc7171d, 2:8.3+94+0~20240109.49+debian11~1.gbpe06825), php-common:amd64 (2:93+0~20231125.47+debian11~1.gbpc7171d, 2:94+0~20240109.49+debian11~1.gbpe06825), php-curl:amd64 (2:8.2+93+0~20231125.47+debian11~1.gbpc7171d, 2:8.3+94+0~20240109.49+debian11~1.gbpe06825), linux-image-amd64:amd64 (5.10.197-1, 5.10.205-2), php-mbstring:amd64 (2:8.2+93+0~20231125.47+debian11~1.gbpc7171d, 2:8.3+94+0~20240109.49+debian11~1.gbpe06825), php-bz2:amd64 (2:8.2+93+0~20231125.47+debian11~1.gbpc7171d, 2:8.3+94+0~20240109.49+debian11~1.gbpe06825), php-fpm:amd64 (2:8.2+93+0~20231125.47+debian11~1.gbpc7171d, 2:8.3+94+0~20240109.49+debian11~1.gbpe06825), php-mysql:amd64 (2:8.2+93+0~20231125.47+debian11~1.gbpc7171d, 2:8.3+94+0~20240109.49+debian11~1.gbpe06825), php-xml:amd64 (2:8.2+93+0~20231125.47+debian11~1.gbpc7171d, 2:8.3+94+0~20240109.49+debian11~1.gbpe06825), php-zip:amd64 (2:8.2+93+0~20231125.47+debian11~1.gbpc7171d, 2:8.3+94+0~20240109.49+debian11~1.gbpe06825), postfix:amd64 (3.5.18-0+deb11u1, 3.5.23-0+deb11u1)
End-Date: 2024-01-09 14:13:28

```

That destroyed then a php-cli script which runs only on PHP 8.2.  
8.3 was never installed before on that server. I checked APT history.

Any idea why this had happende? We never had something before with manually apt upgrade…

Thanks

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [January 19, 2024, 7:51am UTC](https://forum.ansible.com/t/ansible-apt-upgraded-accidently-php-8-2-to-8-3/3390/2 "2024-01-19T07:51:48Z")

</div>

Hi,

My bet is on `upgrade=dist` parameter, which would result in ansible running `apt-get dist-upgrade`, as shown in your output.

From the man page:

```plaintext
dist-upgrade
           dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if
           necessary. The dist-upgrade command may therefore remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.

```

I suggest you switch this [parameter](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#parameter-upgrade) value to ‘yes’ or ‘safe’:

> If yes or safe, performs an aptitude safe-upgrade.

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [January 19, 2024, 9:43am UTC](https://forum.ansible.com/t/ansible-apt-upgraded-accidently-php-8-2-to-8-3/3390/3 "2024-01-19T09:43:07Z")

</div>

To add to @ptn 's comment, I expect you have the [DEB.SURY.ORG](https://deb.sury.org/) repo configured, PHP 8.3 was added fairly recently to it, one result is that previously `apt install php-xml` would install the latest which was `php8.2-xml` but now it’ll install `php8.3-xml`.

FWIW I maintain [a role](https://git.coop/webarch/php) that is designed to install and configure `deb.sury.org` packages or Debian PHP packages.

---

<div class="post-metadata">

**Author:** ![righter83](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/righter83/32/2032_2.png) [@righter83](https://forum.ansible.com/u/righter83)\
**Post date:** [January 22, 2024, 2:24pm UTC](https://forum.ansible.com/t/ansible-apt-upgraded-accidently-php-8-2-to-8-3/3390/4 "2024-01-22T14:24:24Z")

</div>

Hi ok that makes sense with the dist. Yes I have The special repo from sury.  
So I’ll try with the safe option.

Thanks!!
