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

推荐订阅源

WordPress大学
WordPress大学
博客园 - 司徒正美
I
InfoQ
宝玉的分享
宝玉的分享
G
Google Developers Blog
J
Java Code Geeks
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
腾讯CDC
F
Fortinet All Blogs
A
About on SuperTechFans
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
B
Blog RSS Feed
博客园 - 聂微东
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
L
LangChain Blog
Microsoft Azure Blog
Microsoft Azure Blog
aimingoo的专栏
aimingoo的专栏

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