ansible有很多很多的模块,有一些是官方提供,有一些是别人提供,你也可以自己提供
模块的路径为:
1 |
/usr/lib/python2.7/site-packages/ansible/modules/ |
官方提供给我们很多模块的同时,我们需要一些帮助文档来了解如何使用这些模块
这个时候我们需要一个命令
1 |
ansible-doc -l |
这个命令会列出所有的相关的模块,例如我们想知道yum这个模块怎么用:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
$ ansible-doc yum less 458 (POSIX regular expressions) Copyright (C) 1984-2012 Mark Nudelman less 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 > YUM Installs, upgrade, removes, and lists packages and groups with the `yum' package manager. Options (= is mandatory): - conf_file The remote yum configuration file to use for the transaction. [Default: None] - 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'. (Choices: yes, no) [Default: no] - 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 ",". [Default: None] - 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 ",". [Default: None] - list Various (non-idempotent) commands for usage with `/usr/bin/ansible' and `not' playbooks. See examples. [Default: None] = 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. [Default: None] - state Whether to install (`present', `latest'), or remove (`absent') a package. (Choices: present, latest, absent) [Default: present] - update_cache Force updating the cache. Has an effect only if state is `present' or `latest'. (Choices: yes, no) [Default: no] Requirements: yum EXAMPLES: - name: install the latest version of Apache yum: name=httpd state=latest - name: remove the Apache package yum: name=httpd state=absent - name: install the latest version of Apache from the testing repo yum: name=httpd enablerepo=testing state=present - name: install one specific version of Apache yum: name=httpd-2.2.29-1.4.amzn1 state=present - name: upgrade all packages yum: name=* state=latest - name: install the nginx rpm from a remote repo yum: name=http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm state=present - name: install nginx rpm from a local file yum: name=/usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm state=present - name: install the 'Development tools' package group yum: name="@Development tools" state=present (END) |
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021