From: nicoo Date: Sat, 12 Jan 2019 22:53:59 +0000 (+0100) Subject: ansible/base: Use map + join rather than a complicated loop X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=936223be25b8a342831b53bdccce83de1afebaad;p=noc.git ansible/base: Use map + join rather than a complicated loop --- 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: