服务器数据盘初始化
程序员文章站
2022-07-04 09:19:47
---- name: disk | primary | partition parted: device: "{{ item.device }}" number: "{{ item.number }}" label: gpt part_start: "{{ item.start }}" part_end: "{{ item.end }}" part_type: primary state: present with_items: -....
---
- name: disk | primary | partition
parted:
device: "{{ item.device }}"
number: "{{ item.number }}"
label: gpt
part_start: "{{ item.start }}"
part_end: "{{ item.end }}"
part_type: primary
state: present
with_items:
- "{{ disk_partitions }}"
tags:
- disk_primary_partition
- name: disk | ext4 | filesystem
filesystem:
fstype: ext4
dev: "{{ item.device }}{{ item.number }}"
force: yes
with_items:
- "{{ disk_partitions }}"
tags:
- disk_ext4_filesystem
- name: disk | mount | dir
mount:
fstype: ext4
src: "{{ item.device }}{{ item.number }}"
path: "{{ item.mount }}"
state: mounted
with_items:
- "{{ disk_partitions }}"
tags:
- disk_mount_dir
执行命令,这里 -e 可以自定义参数。
ansible-playbook -i env/init init.yml -e '{"disk_partitions":[{"number":"1","start":"0%","end":"50%","device":"/dev/sdb","mount":"/opt"},{"number":"2","start":"50%","end":"100%","device":"/dev/sdb","mount":"/data"}]}'
本文地址:https://blog.csdn.net/wyl9527/article/details/107912160
下一篇: 谷歌眼镜强势回归 我们从中能学到什么?