Ansible常见模块module用法汇总-下一朵云

Ansible常见模块module用法汇总:

一、mount模块

- name: mount partiton to /data
  mount:
      path: /data
      src: /dev/datevg/data
      fstype: xfs
      state: mounted

二、 parted模块

- name:create a new partiton
  parted:
       device: /dev/vda
       number: 1
       ps://xwenw.com/tag/flags" target="_blank">flags: [lvm]
       state: present
       part_start: 1GiB
       part_end: 2GiB

三、yum模块

- name: use yum install packages
  yum:
      name: 
             - php
             - mariadb
      state: latest
- name: another install 
  yum:
      name: "@DEV TOOLS"
      state: latest
- name: update
  yum:
      name: "*"
      state: latest

四、 get_url模块

- name: use get url download
  get_url:
        url: https://www.orcy.net.cn/3550.html
        dest: /www/var/html

五、 template模块

- name: template module
  template:
         src: index.html.j2
         dest: /webdev/html/index.html

六、service模块

- name: start service
  service:
        name: httpd
        state: started
        enabled: yes 

七、firewalld模块

- name: set firewalld rule
  firewalld:
         service: http
         immediate: yes
         permanent: yes
         state: enabled

八、lvol模块

- name: create lv 
  lvol:
           vg: research
           lv: data
           size: 1500

九、filesystem模块

- name: format a partition
  filesystem:
        fstype: ext4
        dev: /dev/vdb2

十、debug模块

- name: debug module
  debug:
         msg: "some notice"

十一、copy模块

- name: copy module
  copy:
        content: this content
        dest: /data/path/file1

十二、file模块

- name: create a directory
  file:
         path: /webdev
         state: directory
         group: webdev
         mode: "2775"
         setype: "httpd_sys_content_t"
- name: crete a link
  file:
         src: /webdev
         dest: /var/www/html
         state: link

十三、lineinfile模块

- name: lineinfile module
  lineinfile:
           path: /webdev/index.html
           regexp: "^Welcome to"
           line: "bye bye"

十四、group模块

- name: create a group
  group:
      name: webdev

十五、user模块

- name: add users
  user:
      name: natash
      password: XXX
      groups: webdev
      uid: 6666
      expires: 30

十六、cron模块

- name: add a crontab
  cron:
        uesr: natasha
        minute: "*/2"
        job: logger "Welcome to www.orcy.net.cn"
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。