diff --git a/tasks/main.yml b/tasks/main.yml index 5a90796..7a961cf 100644 --- a/tasks/main.yml +++ b/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 diff --git a/templates/parted_flags_args.j2 b/templates/parted_flags_args.j2 new file mode 100644 index 0000000..eb92bab --- /dev/null +++ b/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 %} diff --git a/templates/parted_partitions_args.j2 b/templates/parted_partitions_args.j2 index b039029..b37d3cb 100644 --- a/templates/parted_partitions_args.j2 +++ b/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 %} +#}