Ansible
2016-04-12 11:04
246 查看
1. Benifts
不需要后台进程,不需要数据库。
被管节点不需要agent.
不要求root权限
2. Requirment
manage node: >=python2.6
managed node: >=python2.4
----------------------------------------------------------------------------
role:
把配置文件整合到一起并最大程度保证其刚劲整洁,可重用
----------------------------------------------------------------------------
3. 简单命令
ansible -i hosts all -m ping -u user
-i:指定 inventory 文件,使用当前目录下的 hosts
all:针对 hosts 定义的所有主机执行,这里也可以指定组名或模式
m:指定所用的模块,我们使用 Ansible 内置的 ping 模块来检查能否正常管理远端机器
-u:指定远端机器的用户
ansible all -m shell -a "cat /root/.ssh/id_rsa.pub >> /root/.ssh/bbb"
ansible testservers -m command -a 'uname -a'
2. 剧本
剧本播放:
ansible-playbook deploy-blog-simple.yml
ansible-playbook -i hosts-demo site.yml
ansible-playbookpropel-vagrant-dev/provisioning/site.yml --extra-vars"@./propel-vagrant-dev/config.yml"
常用模块
1. command
在远程主机上执行命令
The command module
takes the command name followed by a listof space-delimited arguments. The given command will be executed on allselected nodes. It will not be processed through the shell, so variableslike $HOME andoperations
like "<", ">", "|",and "&" willnot
work (use the shellmodule
if you need these features).
ansible testservers -m shell -a 'ls -al'
2. shell
切换到某个shell执行指定的指令,参数与command相同。
## 将创建的脚本文件分发到远程
# ansible storm_cluster -m copy -a "src=/tmp/rocketzhang_test.sh dest=/tmp/rocketzhang_test.sh owner=root group=root mode=0755"
## 远程执行
# ansible storm_cluster -m shell -a "/tmp/rocketzhang_test.sh"
3.setup
用来查看远程主机的一些基本信息
ansible
storm_cluster -m setup
4. ping
## 用来测试远程主机的运行状态
# ansible storm_cluster -m ping
不需要后台进程,不需要数据库。
被管节点不需要agent.
不要求root权限
2. Requirment
manage node: >=python2.6
managed node: >=python2.4
----------------------------------------------------------------------------
role:
把配置文件整合到一起并最大程度保证其刚劲整洁,可重用
----------------------------------------------------------------------------
3. 简单命令
ansible -i hosts all -m ping -u user
-i:指定 inventory 文件,使用当前目录下的 hosts
all:针对 hosts 定义的所有主机执行,这里也可以指定组名或模式
m:指定所用的模块,我们使用 Ansible 内置的 ping 模块来检查能否正常管理远端机器
-u:指定远端机器的用户
ansible all -m shell -a "cat /root/.ssh/id_rsa.pub >> /root/.ssh/bbb"
ansible testservers -m command -a 'uname -a'
2. 剧本
剧本播放:
ansible-playbook deploy-blog-simple.yml
ansible-playbook -i hosts-demo site.yml
ansible-playbookpropel-vagrant-dev/provisioning/site.yml --extra-vars"@./propel-vagrant-dev/config.yml"
常用模块
1. command
在远程主机上执行命令
The command module
takes the command name followed by a listof space-delimited arguments. The given command will be executed on allselected nodes. It will not be processed through the shell, so variableslike $HOME andoperations
like "<", ">", "|",and "&" willnot
work (use the shellmodule
if you need these features).
ansible testservers -m shell -a 'ls -al'
2. shell
切换到某个shell执行指定的指令,参数与command相同。
## 将创建的脚本文件分发到远程
# ansible storm_cluster -m copy -a "src=/tmp/rocketzhang_test.sh dest=/tmp/rocketzhang_test.sh owner=root group=root mode=0755"
## 远程执行
# ansible storm_cluster -m shell -a "/tmp/rocketzhang_test.sh"
3.setup
用来查看远程主机的一些基本信息
ansible
storm_cluster -m setup
4. ping
## 用来测试远程主机的运行状态
# ansible storm_cluster -m ping
相关文章推荐
- MongoDB3.0添加用户认证
- 代码收集
- Linux下SVN提交时强制写日志问题
- 继电器驱动电路原理及注意事项
- STM32启动模式及API
- 自定义searchBar使其placeholder左对齐
- Linux下SVN提交时强制写日志问题
- apache-->tomcat的方向代理配置
- Android中Bitmap,byte[],Drawable相互转化
- MVC中的Html.ActionLink的介绍 ---转
- thrift配置——windows客户端与linux服务端通信(C++)
- SynchronizedMap和ConcurrentHashMap的深入分析
- git: 当正在开发时主分支更系
- C# 开启大地址内存以应对32位机器内存不够用问题
- python学习笔记(接口自动化框架 V1.0)
- 范数与距离的关系
- JSON
- 自动化测试之CYGWIN
- sprite的使用方法
- 性能測试命令字段解释