【发布时间】:2020-07-01 11:22:11
【问题描述】:
我是一家法国公司的 SysOps,我想编写一个脚本来使用 Ansible 更新 php,但我有一个错误,我没有找到解决方案,我已经安装了 apt-transport-https,在所有机器。 Ansible 安装在 debian9 中,机器也在 debian9 中。
我的脚本
- 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'
和错误:
任务 [更新软件包] ****************************************** ****************************************************** ****************************************************** ****************************************************** ************************ 致命:[192.168.11.138]:失败! => {"changed": false, "msg": "未能更新 apt 缓存:E: 存储库 'http://ppa.launchpad.net/ondrej/php/ubuntustretch Release' 没有发布文件。"} 致命:[192.168.11.137]:失败! => {"changed": false, "msg": "未能更新 apt 缓存:E: 存储库 'http://ppa.launchpad.net/ondrej/php/ubuntustretch Release' 没有发布文件。"} 致命:[192.168.11.142]:失败! => {"changed": false, "msg": "更新 apt 缓存失败:E: 存储库 'http://ppa.launchpad.net/ondrej/php/ubuntustretch Release' 没有发布文件。"} 要重试,请使用:--limit @/etc/ansible/playbooks/upgrade-php.retry
感谢您的帮助:D
【问题讨论】:
-
在我看来 repo: 'ppa:ondrej/php' 配置不正确。尝试将其设置为不存在的测试,我希望更新将起作用。也可以尝试在机器上手动运行apt update,可能会有更多线索。还有一个小提示,如果你将所有这些任务放在一个块中,那么当 ansible_os_family 时你只需要一个。
-
好的,我试试,谢谢马丁! :D