惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
爱范儿
爱范儿
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
美团技术团队
Y
Y Combinator Blog
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
Martin Fowler
Martin Fowler
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
M
MIT News - Artificial intelligence
博客园 - Franky
V
Visual Studio Blog
I
InfoQ
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
博客园 - 司徒正美
L
LangChain Blog

Jiajun的技术笔记

你好,2026! TiDB 源码阅读(六):TiDB Coprocessor 源码解析 性能优化的核心思想 TiDB 源码阅读(五):索引 TiDB 源码阅读(四):AST、逻辑计划、物理计划 CockroachDB Serverless Architecture podman 无故退出 Cursor Control-L (CTRL-L) Keyboard Shortcuts in Terminal Replace docker with podman Using xmonad with xfce4 A RC script for freebsd frpc 自己动手写一个k8s controller AI 会取代你的(编程)岗位吗? 自建DERP服务器提升Tailscale连接速度(使用Nginx转发) 自动升级Docker容器 再读《程序员修炼之道-从小工到专家》 让浏览器下载文件 再读《软件随想录》/《黑客与画家》/《软技能》 HTTP 压力测试中的 Coordinated Omission 2的补码 编程语言中的 context 是什么? flutter macOS 构建出错 Flatpak 使用小记 Golang CAS 操作是怎么实现的 PostgreSQL 当MQ来使用 Clash 结合 工作VPN 的网络设计 使用 PostgreSQL 搭建 JuiceFS PostgreSQL 配置优化和日志分析 有GitHub Copilot?那就可以搭建你的ChatGPT4服务 窗口函数的使用(以PG为例)
ansible 简明教程
Jiajun Huang · 2017-06-22 · via Jiajun的技术笔记

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