Eu instalei e configurei o Ansible. Meu ambiente é como abaixo:
- Control Machine é o Ubuntu 14.04
- Nós são Centos 7
Abaixo está o meu arquivo hosts
:
# cat /etc/hosts
127.0.0.1 localhost
192.168.2.100 ubunansible.intern.local ubunansible
192.168.2.240 node1.intern.local node1
192.168.2.250 node2.intern.local node2
Eu gostaria de instalar pacotes para nós, mas não posso, embora o ping ansible seja executado com sucesso do Ubuntu para os nós:
# ansible -m ping php
192.168.2.240 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.2.250 | SUCCESS => {
"changed": false,
"ping": "pong"
}
Meu php.yml como abaixo
# cat php.yml
---
- hosts: php
remote_user: root
tasks:
- name: Install required packages
yum: update_cache=yes state=latest name={{ item }}
with_items:
- git
- mcrypt
- nginx
- php5-cli
- php5-curl
- php5-fpm
- php5-intl
- php5-json
- php5-mcrypt
- php5-sqlite
- sqlite3
A sintaxe de Yaml está correta; foi verificado com um validador yaml on-line.
Mas quando eu corro
$ ansible-playbook php.yml
PLAY [php] ********************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************
ok: [192.168.2.240]
ok: [192.168.2.250]
TASK [Install required packages] **********************************************************************************************
failed: [192.168.2.250] (item=[u'git', u'mcrypt', u'nginx', u'php5-cli', u'php5-curl', u'php5-fpm', u'php5-intl', u'php5-json', u'php5-mcrypt', u'php5-sqlite', u'sqlite3']) => {"changed": false, "failed": true, "item": ["git", "mcrypt", "nginx", "php5-cli", "php5-curl", "php5-fpm", "php5-intl", "php5-json", "php5-mcrypt", "php5-sqlite", "sqlite3"], "msg": "No package matching 'php5-cli' found available, installed or updated", "rc": 126, "results": ["No package matching 'php5-cli' found available, installed or updated"]}
failed: [192.168.2.240] (item=[u'git', u'mcrypt', u'nginx', u'php5-cli', u'php5-curl', u'php5-fpm', u'php5-intl', u'php5-json', u'php5-mcrypt', u'php5-sqlite', u'sqlite3']) => {"changed": false, "failed": true, "item": ["git", "mcrypt", "nginx", "php5-cli", "php5-curl", "php5-fpm", "php5-intl", "php5-json", "php5-mcrypt", "php5-sqlite", "sqlite3"], "msg": "No package matching 'php5-cli' found available, installed or updated", "rc": 126, "results": ["No package matching 'php5-cli' found available, installed or updated"]}
to retry, use: --limit @/etc/ansible/php.retry
PLAY RECAP ********************************************************************************************************************
192.168.2.240 : ok=1 changed=0 unreachable=0 failed=1
192.168.2.250 : ok=1 changed=0 unreachable=0 failed=1
falha.