我正在尝试在Ubuntu 14.04上通过ansible安装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
得到了这个
TASK [common-php: Install PHP]************************************************ 失败:[symfony-demo](项= [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-ldap'U 'php5-imagick', U 'php5- hash', U 'php5-sqlite']) => {"failed": true,"项":[" php5-fpm"、"php5-cli"、"php5-curl","php5-mcrypt","php5-common"、"php5-json"、"php5-intl"、"php5-gd"、"php5-mysql","php5-redis", "php5-ldap", "php5-imagick", "php5- hash","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
我已经这样修改了剧本:
- 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
希望对你有所帮助