通过Ansible安装PHP Pear包,具有幂等性

我正在使用Ansible安装 PHP的Pear包,如下所示:
- name: Add Phergie PEAR channel.
  command: pear channel-discover pear.phergie.org
  ignore_errors: yes

- name: Install Phergie and related plugins.
  command: pear install pear.phergie.org/{{ item }}
  with_items:
  - Phergie
  - Phergie_Plugin_AltNick
  ignore_errors: yes

ignore_errors是必需的,因为pear在运行之前已成功运行/完成的命令时总是报告错误(例如:

TASK: [Add Phergie PEAR channel.] ********************************************* 
failed: [10.31.9.210] => {"changed": true,"cmd": ["pear","channel-discover","pear.phergie.org"],"delta": "0:00:01.089340","end": "2013-12-27 10:16:25.640083","item": "","rc": 1,"start": "2013-12-27 10:16:24.550743"}
stdout: Channel "pear.phergie.org" is already initialized
...ignoring

TASK: [Install Phergie and related plugins.] ********************************** 
failed: [10.31.9.210] => (item=Phergie) => {"changed": true,"install","pear.phergie.org/Phergie"],"delta": "0:00:03.698780","end": "2013-12-27 10:16:30.337371","item": "Phergie","start": "2013-12-27 10:16:26.638591"}
stdout: phergie/Phergie is already installed and is the same as the released version 2.1.0
install failed
...ignoring
failed: [10.31.9.210] => (item=Phergie_Plugin_AltNick) => {"changed": true,"pear.phergie.org/Phergie_Plugin_AltNick"],"delta": "0:00:01.779589","end": "2013-12-27 10:16:33.231524","item": "Phergie_Plugin_AltNick","start": "2013-12-27 10:16:31.451935"}
stdout: phergie/Phergie_Plugin_AltNick is already installed and is the same as the released version 2.1.0
install failed
...ignoring

是否有更好(更幂等)的方式来运行pear命令,而不必滚动一堆大的,红色忽略的错误?

从Ansible v2开始,有一个额外的模块用于管理PEAR扩展: http://docs.ansible.com/ansible/pear_module.html

所以现在你可以使用:

- pear: name=Net_URL2 state=latest

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


如何选择合适的 C++ Web 开发框架?
利用 C++ 框架构建高并发 Web 应用的策略
用 C++ 框架开发跨平台图形应用程序
golang框架中安全编码实践的最佳指南是什么?
golang框架与其他语言框架在设计理念上的区别有哪些?
C++ 图形框架与其他语言框架的比较
C++ 框架与其他 Web 开发框架的对比分析
使用 C++ 框架构建大型项目最佳实践
C++ 框架如何提高大型项目开发效率
C++ 框架中依赖注入的持续集成与部署工具
如何与社区协作和贡献到自定义 Golang 框架?
C++ 框架在大型项目中如何实现模块化开发
使用 C++ 框架开发跨平台 Web 应用
C++ 框架在大型项目中的优缺点
golang框架在性能上的优势体现在哪些方面?
C++ 框架在嵌入式系统内存优化中的优势
golang框架在人工智能与机器学习中的作用
如何扩展 Golang 框架以支持特定功能?
如何利用 Go Modules 和依赖项管理来自定义 Golang 框架?
Golang 框架中的性能优化技巧