0

I have installed and configured Ansible. My environment is as below:

  • Control Machine is Ubuntu 14.04
  • Nodes are Centos 7

Below is my hosts file:

# 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

I would like to install packages to nodes but I can't, althouh ansible ping goes successfully from Ubuntu to nodes:

# ansible -m ping php 
192.168.2.240 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
192.168.2.250 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

My php.yml as below

# 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

Yaml syntax is correct; it was checked with an online yaml validator. But when I run

$ 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   

it fails.

2

The problem causing the ansible run to fail is given in your final terminal block:

No package matching 'php5-cli' found available, installed or updated

You should find that this also fails if you try to install it on the node without using ansible; try

node$ sudo apt install php5-cli

Remove php5-cli from your php.yml and try again.

  • I did as your says but gave me same error – Babak Mammadov Aug 9 '17 at 12:32
  • Yes Now It is works. I wrote wrong php5 package names after change this It works – Babak Mammadov Aug 9 '17 at 12:44
  • "Troubleshooting 101" -- a requirement for all would-be users of automation. – 0xSheepdog Sep 20 '17 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.