標籤:ansible yum模組
其實這些東西,包括之前的都是很早以前的東東了,就是怕忘記了,記錄一下。到時候可以翻翻看,因為第一次接觸的時候感覺上手挺快的,都是封裝好的。。
比如有一組機器需要安裝vim,那麼不能一個一個伺服器上ssh然後執行yum install vim -y。少的話還闊以,多的話,呵呵。。
yum模組用法
[[email protected] ~]# ansible-doc -s yumless 436Copyright (C) 1984-2009 Mark Nudelmanless comes with NO WARRANTY, to the extent permitted by law.For information about the terms of redistribution,see the file named README in the less distribution.Homepage: http://www.greenwoodsoftware.com/less- name: Manages packages with the `yum‘ package manager action: yum conf_file # The remote yum configuration file to use for the transaction. disable_gpg_check # Whether to disable the GPG checking of signatures of packages being installed. Has an effect only if state is `present‘ or `latest‘. disablerepo # `Repoid‘ of repositories to disable for the install/update operation. These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",". enablerepo # `Repoid‘ of repositories to enable for the install/update operation. These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",". exclude # Package name(s) to exclude when state=present, or latest list # Various (non-idempotent) commands for usage with `/usr/bin/ansible‘ and `not‘ playbooks. See examples. name= # Package name, or package specifier with version, like `name-1.0‘. When using state=latest, this can be ‘*‘ which means run: yum -y update. You can also pass a url or a local path to a rpm file. To operate on several packages this can accept a comma separated list of packages or (as of 2.0) a list of packages. state # Whether to install (`present‘ or `installed‘, `latest‘), or remove (`absent‘ or `removed‘) a package. update_cache # Force updating the cache. Has an effect only if state is `present‘ or `latest‘.
使用yum包管理器來管理軟體包
選項:
config_file:yum的設定檔
disable_gpg_check:關閉gpg_check
disablerepo:不啟用某個源
enablerepo:啟用某個源
list
name:要進行操作的軟體包的名字,也可以傳遞一個url或者一個本地的rpm包的路徑
state:狀態(present,absent,latest)
樣本使用yum安裝vim,這裡已經安裝過了,其他選擇根據自己需要的隨意選擇。
[[email protected] ~]# ansible web -m yum -a ‘name=vim state=present‘web | SUCCESS => { "changed": false, "msg": "", "rc": 0, "results": [ "vim-enhanced-2:7.4.629-5.el6.x86_64 providing vim is already installed" ]}
本文出自 “村裡的男孩” 部落格,請務必保留此出處http://noodle.blog.51cto.com/2925423/1769477
ansible之yum模組