我正在尝试通过ansible在Ubuntu 14.04上安装php5,如下所示
- name: add ondrej ppa
become: true
apt_repository: repo=ppa:ondrej/php
- name: Update apt
sudo: true
apt: update_cache=yes
- name: Install PHP
sudo: true
apt: pkg={{ item }} state=latest
with_items: "{{ php__packages }}"
并且
php__ppa: name=php5 state=latest
php__packages:
- php5-fpm
- php5-cli
- php5-curl
- php5-mcrypt
- php5-common
- php5-json
- php5-intl
- php5-gd
- php5-mysql
- php5-redis
- php5-imagick
- php5-mhash
- php5-sqlite
并得到了这个
任务[common-php:安装PHP] ************************************************失败: [symfony-demo](item = [u' php5-fpm',u' php5-cli',u' php5-curl', 你是php5-mcrypt',你' php5-common',你' php5-json',你' php5-intl', 你是php5-gd',你' php5-mysql',你' php5-redis',你' php5-ldap', 你是php5-imagick',你' php5-mhash',你' php5-sqlite'])=> {"失败":是的, " item":[" php5-fpm"," php5-cli"," php5-curl"," php5-mcrypt& #34 ;, " php5-common"," php5-json"," php5-intl"," php5-gd"," php5- MySQL的&#34 ;, " php5-redis"," php5-ldap"," php5-imagick"," php5-mhash", " php5-sqlite"]," msg":"没有包匹配' php5-redis'是 可用"}
我也试过这个sudo apt-get install php5-redis
但是也一样
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-redis
答案 0 :(得分:1)
我修改过这样的剧本:
- hosts: all
become: yes
vars:
php_packages:
- php5
- php5-fpm
- php5-cli
- php5-curl
- php5-mcrypt
- php5-common
- php5-json
- php5-intl
- php5-gd
- php5-mysql
- php5-redis
- php5-imagick
- php5-mhash
- php5-sqlite
tasks:
- name: Add PPA apt key
apt_key:
id: "E5267A6C"
keyserver: "keyserver.ubuntu.com"
state: present
- name: add ondrej ppa
apt_repository:
repo: "ppa:ondrej/php"
- name: Update apt
apt:
update_cache: yes
- name: Install PHP
apt:
name: "{{ item }}"
state: latest
with_items: "{{ php_packages }}"
然后我运行剧本:
ansible-playbook -i 192.168.33.10, php5.yml
PLAY [all] *********************************************************************
TASK [setup] *******************************************************************
ok: [192.168.33.10]
TASK [Add PPA apt key] *********************************************************
changed: [192.168.33.10]
TASK [add ondrej ppa] **********************************************************
changed: [192.168.33.10]
TASK [Update apt] **************************************************************
changed: [192.168.33.10]
TASK [Install PHP] *************************************************************
changed: [192.168.33.10] => (item=[u'php5', u'php5-fpm', u'php5-cli', u'php5-curl', u'php5-mcrypt', u'php5-common', u'php5-json', u'php5-intl', u'php5-gd', u'php5-mysql', u'php5-redis', u'php5-imagick', u'php5-mhash', u'php5-sqlite'])
PLAY RECAP *********************************************************************
192.168.33.10 : ok=5 changed=4 unreachable=0 failed=0
希望能帮到你