--- # file: tasks/boot.yml - name: boot - define config set_fact: boot_config: # set clocksource at boot - dest: /etc/update-extlinux.conf line: 'default_kernel_opts="\1 clocksource=tsc tsc=reliable"' regex: '^default_kernel_opts="((?!.*clocksource=tsc tsc=reliable).*)"$' - name: boot - stat config file with_items: '{{boot_config|default([])}}' stat: path: '{{item.dest}}' changed_when: false register: boot_config_stat - name: boot - update config when: item.1.stat.exists with_together: - '{{boot_config|default([])}}' - '{{boot_config_stat.results}}' lineinfile: backrefs: true dest: '{{item.0.dest}}' line: '{{item.0.line}}' regex: '{{item.0.regex}}' become: yes notify: - update boot config register: boot_config_handler_notify