From f8ab68e40dda046171de02df6a7c12514f570bf8 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 25 May 2019 03:12:47 +0200 Subject: replace all with_items with loop --- roles/vm/host/tasks/main.yml | 2 +- roles/vm/network/tasks/main.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'roles/vm') diff --git a/roles/vm/host/tasks/main.yml b/roles/vm/host/tasks/main.yml index 010fdce4..562e502e 100644 --- a/roles/vm/host/tasks/main.yml +++ b/roles/vm/host/tasks/main.yml @@ -17,7 +17,7 @@ notify: restart haveged - name: make sure installer directories exists - with_items: + loop: - "{{ debian_installer_path }}" - "{{ preseed_path }}" file: diff --git a/roles/vm/network/tasks/main.yml b/roles/vm/network/tasks/main.yml index 9bef36ed..cb73ef6e 100644 --- a/roles/vm/network/tasks/main.yml +++ b/roles/vm/network/tasks/main.yml @@ -1,7 +1,7 @@ --- - block: - name: remove legacy systemd.link units - with_items: + loop: - 50-virtio-kernel-names.link - 99-default.link file: @@ -9,7 +9,7 @@ state: absent - name: install systemd network link units - with_items: "{{ network.systemd_link.interfaces }}" + loop: "{{ network.systemd_link.interfaces }}" loop_control: index_var: interface_index template: -- cgit v1.2.3 From a5dc25ddf79c490b3c4118923d325b4af7bb65dc Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 25 May 2019 03:56:10 +0200 Subject: replace most with_dicts --- roles/info-beamer/config/tasks/main.yml | 6 +++--- roles/openwrt/image/tasks/prepare.yml | 24 ++++++++++++------------ roles/vm/guest/tasks/main.yml | 12 ++++++------ roles/vm/install/tasks/main.yml | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'roles/vm') diff --git a/roles/info-beamer/config/tasks/main.yml b/roles/info-beamer/config/tasks/main.yml index b4627fb7..cabc9a6b 100644 --- a/roles/info-beamer/config/tasks/main.yml +++ b/roles/info-beamer/config/tasks/main.yml @@ -51,13 +51,13 @@ when: info_beamer_wireless is defined - name: enable info-beamer feature flags + loop: "{{ info_beamer_feature_flags | dict2items }}" + loop_control: + label: "{{ item.key }}({{ item.value }}" copy: content: "" dest: "{{ info_beamer_base_path }}/config/{{ item.key }}" - with_dict: "{{ info_beamer_feature_flags }}" when: item.value - loop_control: - label: "{{ item.key }}({{ item.value }}" - name: install branding logo copy: diff --git a/roles/openwrt/image/tasks/prepare.yml b/roles/openwrt/image/tasks/prepare.yml index ffac3c3f..e03fe351 100644 --- a/roles/openwrt/image/tasks/prepare.yml +++ b/roles/openwrt/image/tasks/prepare.yml @@ -21,36 +21,36 @@ - name: Copy mixins in place [1/3] + loop: "{{ openwrt_mixin | dict2items }}" + loop_control: + label: "{{ item.key }}" file: dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}" src: "{{ item.value.link }}" force: yes follow: no state: link - with_dict: "{{ openwrt_mixin }}" when: '"link" in item.value' - loop_control: - label: "{{ item.key }}" - name: Copy mixins in place [2/3] + loop: "{{ openwrt_mixin | dict2items }}" + loop_control: + label: "{{ item.key }}" copy: src: "{{ item.value.file }}" dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}" mode: "{{ item.value.mode | default('0644') }}" - with_dict: "{{ openwrt_mixin }}" when: '"file" in item.value' - loop_control: - label: "{{ item.key }}" - name: Copy mixins in place [3/3] + loop: "{{ openwrt_mixin | dict2items }}" + loop_control: + label: "{{ item.key }}" copy: content: "{{ item.value.content }}" dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}" mode: "{{ item.value.mode | default('0644') }}" - with_dict: "{{ openwrt_mixin }}" when: '"content" in item.value' - loop_control: - label: "{{ item.key }}" - name: Generate /etc/fstab loop: "{{ openwrt_mounts }}" @@ -70,15 +70,15 @@ - name: Create UCI configuration files + loop: "{{ openwrt_uci | dict2items }}" + loop_control: + label: "{{ item.key }}" template: src: uci.j2 dest: "{{ openwrt_imgbuilder_files }}/etc/config/{{ item.key }}" mode: 0644 trim_blocks: yes # force: no ## TODO: fail when overwriting a file - with_dict: "{{ openwrt_uci }}" - loop_control: - label: "{{ item.key }}" - name: Create /etc/passwd template: diff --git a/roles/vm/guest/tasks/main.yml b/roles/vm/guest/tasks/main.yml index 4830d051..68c36be3 100644 --- a/roles/vm/guest/tasks/main.yml +++ b/roles/vm/guest/tasks/main.yml @@ -4,23 +4,23 @@ state: present - name: Configure rngd [1/2] + loop: '{{ rngd_config | dict2items }}' + loop_control: + label: "{{ item.key }}" lineinfile: path: /etc/default/rng-tools line: '{{ item.key }}={{ item.value }}' regexp: '^#?{{ item.key }}=' - with_dict: '{{ rngd_config }}' - loop_control: - label: "{{ item.key }}" notify: restart rngd - name: Configure rngd [2/2] + loop: '{{ rngd_config | dict2items }}' + loop_control: + label: "{{ item.key }}" lineinfile: path: /etc/default/rng-tools regexp: '^{{ item.key }}=(?!{{ item.value }})' state: absent - with_dict: '{{ rngd_config }}' - loop_control: - label: "{{ item.key }}" notify: restart rngd - name: Provide a root shell on the VM console [1/2] diff --git a/roles/vm/install/tasks/main.yml b/roles/vm/install/tasks/main.yml index a971a7be..dc272b67 100644 --- a/roles/vm/install/tasks/main.yml +++ b/roles/vm/install/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: create disks for vm - with_dict: "{{ hostvars[hostname].install_cooked.disks.virtio | default({}) | combine(hostvars[hostname].install_cooked.disks.scsi | default({})) }}" + loop: "{{ hostvars[hostname].install_cooked.disks.virtio | default({}) | combine(hostvars[hostname].install_cooked.disks.scsi | default({})) | dict2items }}" lvol: vg: "{{ item.value.vg }}" lv: "{{ item.value.lv }}" -- cgit v1.2.3 From 4115572673efed533e06ab9dfcba95bb77992593 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 1 Jun 2019 17:51:58 +0200 Subject: with_dict -> loop --- roles/sshd/tasks/main.yml | 16 +++++++++------- roles/vm/grub/tasks/main.yml | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'roles/vm') diff --git a/roles/sshd/tasks/main.yml b/roles/sshd/tasks/main.yml index 2c81f497..9d35e750 100644 --- a/roles/sshd/tasks/main.yml +++ b/roles/sshd/tasks/main.yml @@ -5,13 +5,15 @@ state: present - name: hardening ssh-server config - with_dict: - IgnoreRhosts: "yes" - PermitRootLogin: "without-password" - PubkeyAuthentication: "yes" - HostbasedAuthentication: "no" - PermitEmptyPasswords: "no" - UseDNS: "no" + vars: + sshd_options: + IgnoreRhosts: "yes" + PermitRootLogin: "without-password" + PubkeyAuthentication: "yes" + HostbasedAuthentication: "no" + PermitEmptyPasswords: "no" + UseDNS: "no" + loop: "{{ sshd_options | dict2items }}" loop_control: label: "{{ item.key }} = {{ item.value }}" lineinfile: diff --git a/roles/vm/grub/tasks/main.yml b/roles/vm/grub/tasks/main.yml index eb868d38..e663e808 100644 --- a/roles/vm/grub/tasks/main.yml +++ b/roles/vm/grub/tasks/main.yml @@ -1,15 +1,17 @@ --- - name: enable serial console in grub and for kernel - with_dict: - GRUB_TIMEOUT: 2 - GRUB_CMDLINE_LINUX: '"console=ttyS0,115200n8"' - GRUB_TERMINAL: serial - GRUB_SERIAL_COMMAND: >- - "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" + vars: + grub_options: + GRUB_TIMEOUT: 2 + GRUB_CMDLINE_LINUX: '"console=ttyS0,115200n8"' + GRUB_TERMINAL: serial + GRUB_SERIAL_COMMAND: >- + "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" + loop: "{{ grub_options | dict2items }}" + loop_control: + label: "{{ item.key }}" lineinfile: dest: /etc/default/grub regexp: "^{{ item.key }}=" line: "{{ item.key }}={{ item.value }}" notify: update grub - loop_control: - label: "{{ item.key }}" -- cgit v1.2.3