gpt4 book ai didi

ansible - 通过 Ansible 在 Centos(节点)上安装多个 yum 包?

转载 作者:行者123 更新时间:2023-12-01 08:23:44 28 4
gpt4 key购买 nike

这是我尝试在具有操作系统 Centos-7 的节点上运行的 YAMLcode 的一部分......

文件层次结构是
--> 角色/install_tools/tasks/main.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

它显示的错误是;
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"]}

最佳答案

使用 with_items ansible yum 现在已弃用。您应该将列表传递给 name:如下;

- 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

以前的解决方案会给你以下错误:
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 }}`, 

关于ansible - 通过 Ansible 在 Centos(节点)上安装多个 yum 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44019836/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com