diff --git a/docs/ansible.html b/docs/ansible.html new file mode 100644 index 00000000..0968214d --- /dev/null +++ b/docs/ansible.html @@ -0,0 +1,169 @@ + + +
+ +此快速参考备忘单提供了使用 Ansible 的各种方法。
+安装命令 | 环境 |
---|---|
brew install ansible | macos |
yum install -y ansible | centos |
pip install ansible | python |
文件路径 | 说明 |
---|---|
/etc/ansible/ansible.cfg | 系统范围的配置 |
~/ansible.cfg | 用户特定的配置 |
$pwd/ansible.cfg | 当前目录下的配置 |
/etc/ansible/hosts
mail.example.com
+
+[webservers]
+foo.example.com
+bar.example.com
+
+检查Inventory是否生效
+ansible all --list-hosts
+
+ping所有目标
+$ ansible all -m ping
+
+ping本地(不使用SSH连接)
+$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -m ping
+
+
+本地执行命令
+$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -a 'hostname'
+
+
+获取本地主机的信息
+$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -m setup
+
+
+获取远程到本地
+$ ansible target -m fetch -a "src=/tmp/seq dest=/tmp/seq"
+
+
+拷贝本地到远程
+$ ansible target -m copy -a "src=/tmp/seq dest=/tmp/seq"
+
+
+
+
+