saltstack和ansible的区别
1、salt要安装agent;ansible不需要,通过ssh连接,省掉装agent的事。
2、salt在server端要启进程;ansible不需要,但这都无所谓差不多。3、salt与ansible都有模块,可使用任意语言开发模块。
4、salt与ansible都使用yaml语言格式编写剧本。
ansible由于走的是ssh,所以它有认证的过程,以及加密码的过程,这使得ansible非常慢,不适用
于大规模环境(指上千台)。
ansible 命令格式
1、COPY模块
ansible all -m copy -a "src=/home/yakamoz/test.sh dest=/tmp/"
2、PING模块
ansible slave -i /etc/ansible/hosts -m ping
3、SHELL模块
ansible 192.168.200.136 -m shell -a 'echo 1qaz | passwd --stdin root' 远程修改密码
4、COMMAND模块
ansible 192.168.200.136 -m command -a 'pwd' 不支持管道| 定向符>> >等特殊字符
5、SERVICE模块
ansible all -m service -a "name=httpd state=restarted" (started,stoped)
6、FILE模块
ansible all -m file -a "dest=/root/1.txt mode=600 owner=hadoop group=hadoop"
7、FETCH模块
ansible 192.168.200.136 -m fetch -a "src=/root/nihao/dda.log dest=/root/hello" 从远程机拉取
文件(文件夹不行)
创建软链接
ansible slave -m file -a "src=/tmp/1 dest=/tmp/2 owner=root state=link"
指定用户和需要root权限
ansible slave -m command -a "pwd" -u hadoop (指定用户) --sudo [k] (当需要root权限执行的化
,-k参数用来输入root密码)