欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

服务器数据盘初始化

程序员文章站 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

相关标签: saltstack/ansible