例子: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
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于