7

Here is the part of YAMLcode that i am trying to run on a node which has operating system, Centos-7......

file hierarchy is --> roles/install_tools/tasks/main.yml

its not working fine, YAML syntax is also valid and correct !

Could someone help me ?

---
- name: install the Development tools package group
  yum:
   name: "@Development tools"
   state: present

- name: Install common software requirements
  ignore_errors: yes
  become: true
  yum: pkg={{ item }} state=present
  with_items:
    - yum-plugin-fastestmirror
    - epel-release
    - git
    - libyaml-devel 
    - libnet-devel 
    - libnetfilter_queue-devel 
    - libpcap-devel 
    - pcre-devel 
    - file-devel 
    - jansson-devel 
    - nss-devel 
    - libcap-ng-devel 
    - lua-devel 
    - binutils 
    - gmp 
    - gmp-devel 
    - make 
    - ld 
    - glibc.i686 
    - python-pip 
    - perl-Sys-Syslog
    - readline-devel 
    - ncurses-devel 
    - openssl-devel 
    - easy-rsa
    - flex 
    - bison 
    - pcre 
    - zlib 
    - zlib-devel 
    - libpcap 
    - libdnet 
    - libdnet-devel 
    - m4
    - gcc  
    - mysql-devel 
    - python-devel 
    - geoip 
    - geoip-devel 
    - libffi-devel 
    - vim 
    - lsof 
    - wget 
    - mlocate 
    - htop 
    - net-tools 
    - traceroute
    - tcpdump 
    - radiusclient-ng.x86_64 
    - gmp-devel 
    - iptables-services 
    - dnsmasq 
    - pptpd 
    - mariadb-devel
    - lzo-devel.x86_64
    - crontabs
    - gcc 
    - make 
    - rpm-build 
    - autoconf.noarch 
    - zlib-devel 
    - pam-devel 
    - openssl-devel

The error it is showing is;

TASK [install_tools : Install common software requirements] ***********************
failed: [meracentos] (item=[u'yum-plugin-fastestmirror', u'epel-release', u'git', u'libyaml-devel', u'libnet-devel', u'libnetfilter_queue-devel', u'libpcap-devel', u'pcre-devel', u'file-devel', u'jansson-devel', u'nss-devel', u'libcap-ng-devel', u'lua-devel', u'binutils', u'gmp', u'gmp-devel', u'make', u'ld', u'glibc.i686', u'python-pip', u'perl-Sys-Syslog', u'readline-devel', u'ncurses-devel', u'openssl-devel', u'easy-rsa', u'flex', u'bison', u'pcre', u'zlib', u'zlib-devel', u'libpcap', u'libdnet', u'libdnet-devel', u'm4', u'gcc', u'mysql-devel', u'python-devel', u'geoip', u'geoip-devel', u'libffi-devel', u'vim', u'lsof', u'wget', u'mlocate', u'htop', u'net-tools', u'traceroute', u'tcpdump', u'radiusclient-ng.x86_64', u'gmp-devel', u'iptables-services', u'dnsmasq', u'pptpd', u'mariadb-devel', u'lzo-devel.x86_64', u'crontabs', u'gcc', u'make', u'rpm-build', u'autoconf.noarch', u'zlib-devel', u'pam-devel', u'openssl-devel']) => {"changed": false, "failed": true, "item": ["yum-plugin-fastestmirror", "epel-release", "git", "libyaml-devel", "libnet-devel", "libnetfilter_queue-devel", "libpcap-devel", "pcre-devel", "file-devel", "jansson-devel", "nss-devel", "libcap-ng-devel", "lua-devel", "binutils", "gmp", "gmp-devel", "make", "ld", "glibc.i686", "python-pip", "perl-Sys-Syslog", "readline-devel", "ncurses-devel", "openssl-devel", "easy-rsa", "flex", "bison", "pcre", "zlib", "zlib-devel", "libpcap", "libdnet", "libdnet-devel", "m4", "gcc", "mysql-devel", "python-devel", "geoip", "geoip-devel", "libffi-devel", "vim", "lsof", "wget", "mlocate", "htop", "net-tools", "traceroute", "tcpdump", "radiusclient-ng.x86_64", "gmp-devel", "iptables-services", "dnsmasq", "pptpd", "mariadb-devel", "lzo-devel.x86_64", "crontabs", "gcc", "make", "rpm-build", "autoconf.noarch", "zlib-devel", "pam-devel", "openssl-devel"], "msg": "No package matching 'ld' found available, installed or updated", "rc": 126, "results": ["yum-plugin-fastestmirror-1.1.31-40.el7.noarch providing yum-plugin-fastestmirror is already installed", "git-1.8.3.1-6.el7_2.1.x86_64 providing git is already installed", "binutils-2.25.1-22.base.el7.x86_64 providing binutils is already installed", "gmp-1:6.0.0-12.el7_1.x86_64 providing gmp is already installed", "make-1:3.82-23.el7.x86_64 providing make is already installed", "No package matching 'ld' found available, installed or updated"]}
slm
  • 15,396
  • 12
  • 109
  • 124
Saad
  • 916
  • 1
  • 15
  • 28
  • There is an error message for you: `No package matching 'ld' found available`. – Konstantin Suvorov May 17 '17 at 08:47
  • well, i also have remove "ld" and checked it multiple times, but its not working ! i can't sort out, why it is happening, i have used such strategy for UBUNTU and that was working fine for me ! but for centos, it is giving such errors – Saad May 17 '17 at 08:50
  • @SyedSaadAhmed are the correct repos enabled on the target machine? – PhilipGough May 17 '17 at 09:24
  • I didn't get what you said, "repos enabled" ?? @user2983542 – Saad May 17 '17 at 09:40
  • Well i have sorted the issue, it was because of ansible version !! some old verssion do not support new packages, i was running an older version that's why i was facing the issue ! Thanks :-) – Saad Jul 07 '17 at 08:42

4 Answers4

18

Use of with_items with the ansible yum is now deprecated. You should pass a list to name: as follows;

- name: Install common software requirements
  become: true
  yum:
    state: present
    name: 
      - yum-plugin-fastestmirror
      - epel-release
      - git
      - libyaml-devel 
      - libnet-devel 
      - libnetfilter_queue-devel 
      - libpcap-devel 
      - pcre-devel 
      - file-devel 
      - jansson-devel 
      - nss-devel 
      - libcap-ng-devel 
      - lua-devel 
      - binutils 
      - gmp 
      - gmp-devel 
      - make 
      - ld 
      - glibc.i686 
      - python-pip 
      - perl-Sys-Syslog
      - readline-devel 
      - ncurses-devel 
      - openssl-devel 
      - easy-rsa

The previous solution will give you the following error:

Invoking "yum" only once while using a loop via squash_actions is  deprecated. Instead of using a loop to supply multiple items and specifying `name: {{ item }}`, 
Abey
  • 165
  • 7
Jev Björsell
  • 891
  • 1
  • 9
  • 25
1

Below code worked for me -->

File - yumInstall.yml

---
- hosts: localhost
  gather_facts: False
  serial: 1
  tasks:
    - name: 1. Install Apache Packages
      yum: name={{ item }} state=present
      with_items:
          - httpd
          - yum-plugin-fastestmirror
          - epel-release
          - git
          - libyaml-devel
          - libnet-devel
          - libnetfilter_queue-devel
          - libpcap-devel
          - pcre-devel
          - file-devel
          - jansson-devel
          - nss-devel
          - libcap-ng-devel
          - lua-devel
          - binutils
          - gmp
          - gmp-devel
          - make
#          - ld
          - glibc.i686
          - python-pip
          - perl-Sys-Syslog
          - readline-devel
          - ncurses-devel
          - openssl-devel
          - easy-rsa
          - flex
          - bison
          - pcre
          - zlib
          - zlib-devel

Executing playbook:-

ansible-playbook -i hosts yumInstall.yml

[WARNING]: Found both group and host with same name: localhost

PLAY [localhost] *****************************************************************************************************************************************************************

TASK [1. Install Apache Packages] ************************************************************************************************************************************************ changed: [localhost] => (item=[u'httpd', u'yum-plugin-fastestmirror', u'epel-release', u'git', u'libyaml-devel', u'libnet-devel', u'libnetfilter_queue-devel', u'libpcap-devel', u'pcre-devel', u'file-devel', u'jansson-devel', u'nss-devel', u'libcap-ng-devel', u'lua-devel', u'binutils', u'gmp', u'gmp-devel', u'make', u'glibc.i686', u'python-pip', u'perl-Sys-Syslog', u'readline-devel', u'ncurses-devel', u'openssl-devel', u'easy-rsa', u'flex', u'bison', u'pcre', u'zlib', u'zlib-devel'])

PLAY RECAP *********************************************************************************************************************************************************************** localhost : ok=1 changed=1 unreachable=0 failed=0

Screenshot

SPM
  • 714
  • 1
  • 8
  • 17
  • Actually, i am using ansible version 2.2.0.0 ! After testing on couple of machines, The solution which i found is that my code is working properly on ansible version 2.3.0.0, i just upgrade my version and now it is executing my code. There must be a bug in "yum" module in ansible version 2.2.0.0 ! – Saad May 27 '17 at 07:11
  • might be, I am on ansible 2.3.0.0. – SPM May 29 '17 at 06:17
  • Yes, you can verify it by your own ! Move to ansible version 2.2.0.0 and your piece of YAML template will give you errors. I have tested it. – Saad May 29 '17 at 06:55
  • with_items is deprecated, use name list instead. – 9nix00 Mar 25 '19 at 09:36
1

there is two errors in your config.

  1. yum syntax error
  2. with_items is deprecated now.

example:

- name: Install Tools
  yum:
   state: present
   name:
    - telnet
    - htop
9nix00
  • 3,852
  • 2
  • 21
  • 27
1

You can use simple list:

    - name: Ensure useful util libs are present
      yum:
        name: ['httpie', 'the_silver_searcher', 'fasd', 'multitail', 'vim']
        state: present 
      become: True

or as yaml list

    - name: Ensure useful util libs are present
      yum:
        name:
          - httpie
          - the_silver_searcher
          - fasd
          - multitail
          - vim
        state: present 
      become: True
DmitrySemenov
  • 9,204
  • 15
  • 76
  • 121