2017-05-17 162 views
-3

这里是YAMLcode那我试图拥有操作系统的节点上运行的部分的CentOS-7 ......通过Ansible在Centos(节点)上安装多个yum软件包?

文件层次是 - >角色/ install_tools /任务/主。 yml

它不能正常工作,YAML语法也是有效和正确的!

有人可以帮助我吗?

--- 
- 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 

它显示的错误是;

任务[install_tools:安装常见的软件要求] *********************** 失败:[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“ ,“glibc.i686”,“python-pip”,“perl-Sys-Syslog”,“readline-devel”,“ncurses-devel”,“openssl-devel”,“easy-rsa”,“flex” bison“,”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” ,“make”,“rpm-bu ild“,”autoconf.noarch“,”zlib-devel“,”pam-devel“,”openssl-devel“],”msg“:”找不到可用,安装或更新的包'ld'“,”rc“ :126,“results”:[“yum-plugin-fastestmirror-1.1.31-40.el7.noarch provides yum-plugin-fastestmirror is already installed”,“git-1.8.3.1-6.el7_2.1.x86_64 provides git已安装“,”binutils-2.25.1-22.base.el7.x86_64提供binutils已安装“,”gmp-1:6.0.0-12.el7_1.x86_64提供gmp已安装“,”make -1:3.82-23.el7.x86_64提供使已安装”, “不包匹配的 'LD' 发现可用的,安装或更新”]}

+0

没有为你的错误消息:'不包匹配的 'LD' 发现available'。 –

+0

好吧,我也删除了“ld”,并多次检查它,但它不工作! 我无法理清,为什么会发生,我已经使用了UBUNTU的这种策略,这对我来说工作得很好! 但对于centos,它给出这样的错误 –

+0

@SyedSaadAhmed是在目标机器上启用的正确回购吗? – user2983542

回答

1

下面的代码为我工作 - >

文件 - 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 

执行剧本: -

ansible-剧本-i主机yumInstall。YML

[警告]:实测值两者组和主机具有相同名称:本地主机

PLAY [本地主机] ******** ************************************************** ************************************************** **************************************

任务[1。安装Apache软件包] ********************************************** ************************************************** ****************************** 已更改:[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 *********************************** ************************************************** ************************************************** ******************************** 本地主机:OK = 1 = 1变化可达= 0失败= 0

+0

其实,我使用的是正确的版本2.2.0.0! 在几台机器上测试之后,我发现的解决方案是我的代码在2.3.0.0版本上正常工作,我只是升级我的版本,现在它正在执行我的代码。 安全版本2.2.0.0中的“yum”模块中必须存在一个错误! –

+0

可能是,我在2.3.0.0上。 – SPM

+0

是的,你可以自己验证! 转到正确的版本2.2.0.0,你的YAML模板会给你错误。 我已经测试过它。 –