From c470fe0f1f6b97ca7ded852567915ee36d707c48 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Wed, 11 Oct 2017 04:00:14 +0000 Subject: [PATCH] split parted invocation --- tasks/main.yml | 16 +++++++++++++--- ...{parted_args.j2 => parted_partitions_args.j2} | 7 +++---- 2 files changed, 16 insertions(+), 7 deletions(-) rename templates/{parted_args.j2 => parted_partitions_args.j2} (71%) diff --git a/tasks/main.yml b/tasks/main.yml index 3bd8cf8..5a90796 100644 --- a/tasks/main.yml +++ b/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 diff --git a/templates/parted_args.j2 b/templates/parted_partitions_args.j2 similarity index 71% rename from templates/parted_args.j2 rename to templates/parted_partitions_args.j2 index f0aeee9..b039029 100644 --- a/templates/parted_args.j2 +++ b/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 %}