文章目录
- 1. 配置yum
- 2. 安装
- 3. 帮助
官方安装
以下centos或redhat安装
1. 配置yum
$ cat <>/etc/yum.repos.d/my.repo
[epel]
name=epel
baseurl=http://mirrors.aliyun.com/epel/7Server/x86_64/
enable=1
gpgcheck=0
eof
2. 安装
$ yum -y install ansible
3. 帮助
$ ansible-doc -h
Usage: ansible-doc [options] [module...]
Options:
-a, --all Show documentation for all modules
-h, --help show this help message and exit
-l, --list List available modules
-M MODULE_PATH, --module-path=MODULE_PATH
specify path(s) to module library (default=None)
-s, --snippet Show playbook snippet for specified module(s)
-v, --verbose verbose mode (-vvv for more, -vvvv to enable
connection debugging)
--version show program's version number and exit
其中"-l"选项⽤于列出ansible的模块,通常结合grep来筛选。例如找出和yum相关的可⽤模块。
$ ansible-doc -l | grep yum
yum Manages packages with the `yum' package manager
yum_repository Add or remove YUM repositories
再使⽤"-s"选项可以获取指定模块的使⽤帮助。例如,获取yum模块的使⽤语法。
ansible-doc -s yum
- 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
installroot # Specifies an alternative installroot, relative to which all packages
will be installed.
list # Package name to run the equivalent of yum listagainst.
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(using state=present).
To operate on several packages this can accept a comma separated list of
packages or (as of 2.0) a list of packages.
skip_broken # Resolve depsolve problems by removing packages that are causing problems
from the trans- action.
state # Whether to install (`present' or `installed', `latest'), or remove
(`absent' or `removed') a package.
update_cache # Force yum to check if cache is out of date and redownload if needed. Has
an effect only if state is `present' or `latest'.
validate_certs # This only applies if using a https url as the source of the rpm.
e.g. for localinstall. If set to `no', the SSL certificates will not be
validated. This should only set to `no' used on personally controlled
sites using self-signed certificates as it avoids verifying the source
site. Prior to 2.1 the code worked as if this was set to `yes'.