浏览代码

split parted invocation

master
父节点
当前提交
c470fe0f1f
共有 2 个文件被更改,包括 16 次插入7 次删除
  1. +13
    -3
      tasks/main.yml
  2. +3
    -4
      templates/parted_partitions_args.j2

+ 13
- 3
tasks/main.yml 查看文件

@@ -6,15 +6,25 @@
- include: setup_Debian.yml
when: ansible_os_family == "Debian"

#- include: gdisk.yml

- name: write partition table
command:
parted --script
{{ item.device }}
-- {{ lookup('template','parted_args.j2') }}
-- mklabel {{ item.label_type }}
with_items: "{{ hard_disks }}"

- name: write partitions
command:
parted --script
{{ item.0.device }}
-- {{ lookup('template','parted_partitions_args.j2') }}
with_subelements:
- "{{ hard_disks }}"
- partitions

- fail:
msg: here

- name: sync
command: sync



templates/parted_args.j2 → templates/parted_partitions_args.j2 查看文件

@@ -1,7 +1,7 @@
mklabel {{ item.label_type }}
{% for part in item.partitions %}
{% set disk = item.0 %}
{% set part = item.1 %}
mkpart
{% if item.label_type == "msdos" or item.label_type == "dvh" %}
{% if disk.label_type == "msdos" or disk.label_type == "dvh" %}
"{{ part.part_type }}"
{% endif %}
{% if part.fs_type is defined %}
@@ -18,4 +18,3 @@ mkpart
set {{ outer_loop.index }} {{ flag }} on
{% endfor %}
{% endif %}
{% endfor %}

正在加载...
取消
保存