瀏覽代碼

make it working

master
父節點
當前提交
d52a45a3c1
共有 3 個檔案被更改,包括 22 行新增7 行删除
  1. +7
    -3
      tasks/main.yml
  2. +8
    -0
      templates/parted_flags_args.j2
  3. +7
    -4
      templates/parted_partitions_args.j2

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

@@ -13,7 +13,7 @@
-- mklabel {{ item.label_type }}
with_items: "{{ hard_disks }}"

- name: write partitions
- name: create partitions
command:
parted --script
{{ item.0.device }}
@@ -22,8 +22,12 @@
- "{{ hard_disks }}"
- partitions

- fail:
msg: here
- name: set flags
command:
parted --script
{{ item.device }}
-- {{ lookup('template','parted_flags_args.j2') }}
with_items: "{{ hard_disks }}"

- name: sync
command: sync


+ 8
- 0
templates/parted_flags_args.j2 查看文件

@@ -0,0 +1,8 @@
{% for part in item.partitions %}
{% if part.flags is defined %}
{% set partnum = loop.index %}
{% for flag in part.flags %}
set {{ partnum }} {{ flag }} on
{% endfor %}
{% endif %}
{% endfor %}

+ 7
- 4
templates/parted_partitions_args.j2 查看文件

@@ -1,20 +1,23 @@
{% set disk = item.0 %}
{% set part = item.1 %}
mkpart
{% if disk.label_type == "msdos" or disk.label_type == "dvh" %}
{% if disk.label_type == "msdos" %}
"{{ part.part_type }}"
{% endif %}
{% if disk.label_type == "gpt" %}
"{{ part.name }}"
{% endif %}
{% if part.fs_type is defined %}
"{{ part.fs_type }}"
{% endif %}
{% if part.name is defined %}
"{{ part.name }}"
{% endif %}
"{{ part.start }}"
"{{ part.end }}"

{#
{% if part.flags is defined %}
{% set outer_loop = loop %}
{% for flag in part.flags %}
set {{ outer_loop.index }} {{ flag }} on
{% endfor %}
{% endif %}
#}

Loading…
取消
儲存