ansible 常用模块命令记录
2016-10-14 00:00
260 查看
摘要: 官方文档 http://docs.ansible.com/ansible/intro_adhoc.html
1.copy 模块:把本地文件传输到指定路径;src 本地文件,dest目标文件。
2.file 模块:文件操作(修改权限,新建目录等) state有如下参数 file,directory,link,hard,touch,absent
state=touch 新建文件
state=directory 新建目录
state=absent 删除
3.user 模块,state只有present,absent两个参数
4.yum 模块 state有如下参数 absent,present,installed,removed,latest
5.server 模块有如下参数 running,started,stopped,restarted,reloaded
1.copy 模块:把本地文件传输到指定路径;src 本地文件,dest目标文件。
# 复制本地文件到指定路径 [root@web1 ~]# ansible var -m copy -a "src=/root/test.log dest=/root/test.log.bak"
2.file 模块:文件操作(修改权限,新建目录等) state有如下参数 file,directory,link,hard,touch,absent
state=touch 新建文件
state=directory 新建目录
state=absent 删除
# 权限操作,文件须存在, [root@web1 ~]# ansible var -m file -a "dest=/root/a.txt mode=600 owner=mysql group=mysql" # state=directory 新建目录;类似 mkdir -p [root@web1 ~]# ansible var -m file -a "dest=/root/txt mode=600 owner=mysql group=mysql state=directory" # state=absent 删除 [root@web1 ~]# ansible var -m file -a "dest=/root/a.txt state=absent"
3.user 模块,state只有present,absent两个参数
# 新建用户 [root@web1 ~]# ansible all -m user -a "name=foo password=<crypted password here>" # 删除用户 [root@web1 ~]# ansible all -m user -a "name=foo state=absent"
4.yum 模块 state有如下参数 absent,present,installed,removed,latest
# 安装 [root@web1 ~]# ansible webservers -m yum -a "name=name state=present" # yum install 指定版本 [root@web1 ~]# ansible webservers -m yum -a "name=name1.5 state=present" # yum install 最新版本 [root@web1 ~]# ansible webservers -m yum -a "name=name state=latest" # yum remove [root@web1 ~]# ansible webservers -m yum -a "name=name state=removed"
5.server 模块有如下参数 running,started,stopped,restarted,reloaded
# 启动 [root@web1 ~]# ansible webservers -m service -a "name=httpd state=started" # 重启 [root@web1 ~]# ansible webservers -m service -a "name=httpd state=restarted" # 重载 [root@web1 ~]# ansible webservers -m service -a "name=httpd state=reloaded" # 停止 [root@web1 ~]# ansible webservers -m service -a "name=httpd state=stopped"
相关文章推荐
- Ansible命令应用之常用模块(持续更新中)
- 详解Ansible服务常用命令模块
- ansible常用命令及模块的使用方法
- Ansible服务常用命令模块详细解析
- linux常用命令使用记录(一)
- Ubuntu: Debian(Ubuntu) 常用命令大全[记录]
- Vi常用且实用命令(持续调加,重在记录,呵呵)
- Oracle常用dump命令,记录一下备查。
- linux常用命令——4/19记录
- Debian(Ubuntu) 常用命令大全[记录]
- 数据常用命令,记录下来
- Summit48 学习记录常用命令
- linux常用文件统计命令记录
- 转载只为记录经典之<Linux 常用命令集锦>
- 转摘只为记录经典之<CVS常用命令速查手册>
- linux命令,记录课堂上常用的
- (Ubuntu) 常用命令大全[记录]
- ClearCase 最常用命令记录
- linux追加模块的网卡驱程 和 一些常用的命令笔记
- Oracle常用dump命令,记录一下备查。