微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐