服务器数据盘初始化
程序员文章站
2022-04-01 19:43:01
---- 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
上一篇: 温州出台物联网产业创新发展三年行动方案