ansible 简明教程

栏目: 服务器 · 发布时间: 7年前

内容简介:ini格式的配置文件大家都懂吧。先编写一个host文件例如:保存为

ini格式的配置文件大家都懂吧。

先编写一个host文件例如:

[local]
127.0.0.1

保存为 localhost.ini

然后执行 ansible -i ./test.host.ini local -k -a 'ls'

就会有输出:

SSH password: 
127.0.0.1 | SUCCESS | rc=0 >>
code
docs
source
test

其中 ansible 的命令大致的格式就是 ansible [group] -a [command] group就是host文件里的组,默认有 allungroup 两个组,最后就是要执行的命令。 详见: http://docs.ansible.com/ansible/intro_patterns.html

-a 就是导入了一个默认模块,用来执行命令的。 -m 则用来导入特定模块,这个就需要 具体用到具体翻文档了。

也可以在家目录下新建一个 ansible.cfg 然后指定默认去找哪个host文件

[defaults]
inventory = ./test.host.ini

然后就可以这样干: ansible local -k -a 'ls' 了。具体很多配置可以参考这里: http://docs.ansible.com/ansible/intro_configuration.html

当然啦, ansible 只是一个临时用的命令,如果想多次使用一些命令,就可以上 ansible-playbook 了。

文档在: http://docs.ansible.com/ansible/playbooks.html

里面有很多模块,在: http://docs.ansible.com/ansible/modules_by_category.html

还有一个概念是role,这个瞄了几眼但是还没看完: http://docs.ansible.com/ansible/playbooks_roles.html


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Probability and Computing: Randomization and Probabilistic Techn

Probability and Computing: Randomization and Probabilistic Techn

Michael Mitzenmacher、Eli Upfal / Cambridge University Press / 2017-7-3 / USD 62.23

Greatly expanded, this new edition requires only an elementary background in discrete mathematics and offers a comprehensive introduction to the role of randomization and probabilistic techniques in m......一起来看看 《Probability and Computing: Randomization and Probabilistic Techn》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具