ansible playbook挂载硬盘实例

  |   0 评论   |   0 浏览

例子:mountdisk.yml

- hosts: all
  gather_facts: no
  vars:
    disks:
      /dev/vdb1: /data
  tasks:
  - name: "mkdir /data"
    file:
      path: "{{ item.value }}"
      state: directory
      mode: 0644
    with_dict: "{{ disks }}"

  - name: umount datanode disks
    mount:
      path: "{{ item.value }}"
      state: absent
    with_dict: "{{ disks }}"

  - name: format datanode disks
    filesystem: fstype=ext4 dev="{{ item.key }}" force=true
    with_dict: "{{ disks }}"

  - name: mount datanode disks
    mount:
      path: "{{ item.value }}"
      src: "{{ item.key }}"
      fstype: ext4
      opts: "defaults"
      state: mounted
    with_dict: "{{ disks }}"

执行

ansible-playbook -i hosts mountdisk.yml

标题:ansible playbook挂载硬盘实例
作者:SmiteLi
地址:https://smite.site/articles/2020/02/11/1581434856752.html