【发布时间】:2019-11-11 08:38:14
【问题描述】:
我正在尝试使用Ansible Playbook 安装Php, Apache in RHEL。但我收到以下错误。
*失败:[18.191.65.251] (item=[u'php', u'php-mysql', u'php-pdo', u'php-gd', u'php-mbstring']) = > {“ansible_loop_var”:“项目”, "已更改": false, "失败": ["没有可用的 php-mysql 包。"], “项目”:[“php”,“php-mysql”,“php-pdo”,“php-gd”,“php-mbstring”], "msg": ["安装某些指定包失败"], "rc": 1, “结果”:[]}
我用来写剧本的代码如下
---
- hosts: all
become: yes
tasks:
- name: Install httpd
yum:
name: httpd
state: present
- name: starting httpd service
service:
name: httpd
enabled: yes
state: started
- name: Installing php packages
yum:
name: "{{ item }}"
state: present
with_items:
- php
- php-mysql
- php-pdo
- php-gd
- php-mbstring
- name: restart Apache service
service:
name: httpd
state: restarted
【问题讨论】:
-
你能从命令行安装它吗?
-
旁注:不要将
with_items与yum 一起使用,而是将列表直接传递给name参数。见first note on the module doc