ansible功能模块

一、shell 模块(调用/bin/bash)

 

例子: -name: “update war”

  shell:  “echo “abc”“

 

二、file 模块

 

例子:- name “mkdir file”

  file: `path=/root/foo.txt state=touch mode=0755 owner=foo group=foo`

 

 

三、copy模块

 

例子: - name: “copy file”

  copy: `remote_src=no src=role/testbox/files/foo.sh dest=/root/foo.sh mode=0644 force=yes`

 

四、stat模块

 

例子:-name “check foo.sh”

stat: `path=/root/foo.sh`

register: script_stat

 

五、debug模块

 

  例子: - debug: msg=foo.sh exists

  when: script_stat.exists

 

六、command(不能调用/bin/bash)

 

 

七、template模块

 

例子:  - name: “write the nginx config file”

    template: src=roles/testbox/templates/nginx.con.j2 dest=/etc/nginx/nginx.con

 

 

八、packaging模块

 

例子: - name: enusure nginx is at the latest version

    yum: pkg=nginx state=latest. (centos,rehat)

 

例子: - name: enusure nginx is at the latest version

    yum: pkg=nginx state=latest.  (Debian,Ubuntu)

 

九、service模块

 

例子:- name: start nginx service

  service: name=nginx state=started

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值