设为首页 加入收藏

TOP

Ansible(二) - 配置及命令简介(三)
2017-10-13 10:37:14 】 浏览:3976
Tags:Ansible 配置 命令 简介
ient主机生效:

# ansible -a "df -h" --limit "client"

 

执行一个耗时任务:(-B 3600表示最多运行60分钟,-P 60表示每隔60s获取一次状态)

ansible all -B 3600 -P 60 -a "/usr/bin/long_running-operation --do-stuff"

 

其他ansible参数可使用ansible -h查看。

 

 

3> 常用模块命令举例

①file模块

创建文件符链接:

# ansible local -m file -a "src=/etc/resolv.conf dest=/tmp/resolv.conf state=link"

更改文件权限为755,属组为root:root:

ansible local -m file -a "dest=/tmp/resolv.conf mode=755 owner=root group=root"

 

②service模块

启动NTP服务:

# ansible local -m service -a "name=ntpd state=started enabled=yes"

 

③copy模块

将本地文件拷贝到远程服务器:

# ansible local -m copy -a "src=/etc/ansible/ansible.cfg dest=/tmp/ansible.cfg owner=root group=root mode=0644"

更多模块请参考命令ansible-doc -l

模块官网 http://docs.ansible.com/ansible/latest/list_of_all_modules.html

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇OpenLDAP配置TLS加密传输 下一篇Ansible(一) - 入门及安装

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目