From 936223be25b8a342831b53bdccce83de1afebaad Mon Sep 17 00:00:00 2001 From: nicoo Date: Sat, 12 Jan 2019 23:53:59 +0100 Subject: [PATCH] ansible/base: Use map + join rather than a complicated loop --- ansible/roles/base/tasks/07grub.yml | 2 +- ansible/usb-install.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/roles/base/tasks/07grub.yml b/ansible/roles/base/tasks/07grub.yml index d413ff6..a52f542 100644 --- a/ansible/roles/base/tasks/07grub.yml +++ b/ansible/roles/base/tasks/07grub.yml @@ -3,6 +3,6 @@ lineinfile: path: /etc/default/grub regexp: '^#?GRUB_CMDLINE_LINUX=' - line: 'GRUB_CMDLINE_LINUX="{% for opt,val in (install.kernel_cmdline | default({})).items() %}{{ opt }}={{ val }}{% if not loop.last %} {% endif %}{% endfor %}"' + line: 'GRUB_CMDLINE_LINUX="{{ map(lambda opt, val: opt + "=" + val, (install.kernel_cmdline or {}).items()).join(" ") }}"' when: install is defined and install.kernel_cmdline is defined notify: update grub diff --git a/ansible/usb-install.yml b/ansible/usb-install.yml index bf4ce64..d5730d9 100644 --- a/ansible/usb-install.yml +++ b/ansible/usb-install.yml @@ -49,7 +49,7 @@ LABEL linux KERNEL linux INITRD initrd.preseed.gz - APPEND install{% for opt,val in (install.kernel_cmdline | default({})).items() %} {{ opt }}={{ val }}{% endfor %} + APPEND install {{ map(lambda opt, val: opt + ' ' + val, (install.kernel_cmdline or {}).items()).join(' ') }} - name: Make the USB disk bootable pause: -- 1.7.10.4