简体   繁体   中英

Upgrade php with Ansible (php7.1 to php7.4)

I am an SysOps in a french companies, i want to write an script to update php with Ansible, but i have an error, and i don't have found an solutions, i have install apt-transport-https, in all machines. Ansible was install in debian9 and the machine was in debian9 too.

My script


- hosts: all
  sudo: yes
  tasks:
    - apt_repository:
        repo: 'ppa:ondrej/php'
        state: present

    - name: Download the signing key
      shell: wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
      when: ansible_os_family == 'Debian'

    - name: Add the packages in sources lists
      shell: sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
      when: ansible_os_family == 'Debian'

    - name: Update packages
      become: true
      apt:
        update_cache=yes
      when: ansible_os_family == 'Debian'

    - name: Install php
      shell: apt install php7.4 php7.4-common php7.4-cli
      when: ansible_os_family == 'Debian'

    - name: Install extensions
      shell: apt install php7.4-curl php7.4-json php7.4-gd php7.4-mbstring php7.4-intl php7.4-bcmath php7.4-bz2 php7.4-readline php7.4-zip
      when: ansible_os_family == 'Debian'

    - name: Purge php
      shell: apt purge php7.1 libapache2-mod-php7.1
      when: ansible_os_family == 'Debian'

    - name: Check the new version of php
      shell: php -v
      when: ansible_os_family == 'Debian'

and the error:

TASK [Update packages] ********************************************************************************************************************************************************************************************************************** fatal: [192.168.11.138]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: E:The repository ' http://ppa.launchpad.net/ondrej/php/ubuntu stretch Release' does not have a Release file."} fatal: [192.168.11.137]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: E:The repository ' http://ppa.launchpad.net/ondrej/php/ubuntu stretch Release' does not have a Release file."} fatal: [192.168.11.142]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: E:The repository ' http://ppa.launchpad.net/ondrej/php/ubuntu stretch Release' does not have a Release file."} to retry, use: --limit @/etc/ansible/playbooks/upgrade-php.retry

Thank you for any helps :D

You have pointed to an Ubuntu ppa but no Ubuntu distribution is named stretch : http://ppa.launchpad.net/ondrej/php/ubuntu/dists/

However, the next two lines that specify the https://packages.sury.org/php/dists/ apt repository does appear to be for Debian specific distributions, and does contain the stretch release

So I believe it's a mixture of what Martin said and this suggestion: either remove the apt_repository: task if all of your machines are actually Debian, or guard that task with a when: which evaluates to true only for your Ubuntu machines

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM