Browse Source

make it working

master
parent
commit
d52a45a3c1
3 changed files with 22 additions and 7 deletions
  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 View File

@@ -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 View File

@@ -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 View File

@@ -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…
Cancel
Save