myos/ansible/roles/hosts/tasks/boot.yml

59 lines
1.9 KiB
YAML
Raw Normal View History

2021-02-09 17:05:00 +01:00
---
# file: tasks/boot.yml
- name: boot - define config
set_fact:
boot_config:
2022-06-30 23:37:10 +02:00
# set docker optimizations - armbian
- dest: /boot/armbianEnv.txt
line: 'docker_optimizations=on'
regex: ''
# set clocksource - grub
- dest: /etc/default/grub
line: 'GRUB_CMDLINE_LINUX="\1 clocksource=tsc tsc=reliable"'
regex: '^GRUB_CMDLINE_LINUX="((?!.*clocksource=tsc tsc=reliable).*)"$'
# set resources limits - grub
- dest: /etc/default/grub
line: 'GRUB_CMDLINE_LINUX="\1 cgroup_enable=memory swapaccount=1"'
regex: '^GRUB_CMDLINE_LINUX="((?!.*cgroup_enable=memory swapaccount=1).*)"$'
# set clocksource - syslinux
2021-02-09 17:05:00 +01:00
- dest: /etc/update-extlinux.conf
line: 'default_kernel_opts="\1 clocksource=tsc tsc=reliable"'
regex: '^default_kernel_opts="((?!.*clocksource=tsc tsc=reliable).*)"$'
2022-06-30 23:37:10 +02:00
# set resources limits - syslinux
- dest: /etc/update-extlinux.conf
line: 'default_kernel_opts="\1 cgroup_enable=memory swapaccount=1"'
regex: '^default_kernel_opts="((?!.*cgroup_enable=memory swapaccount=1).*)"$'
# set clocksource - uboot
- dest: /boot/cmdline.txt
line: '\1 clocksource=tsc tsc=reliable'
regex: '^((?!.*clocksource=tsc tsc=reliable).*)$'
# set resources limits - uboot
- dest: /boot/cmdline.txt
line: '\1 cgroup_enable=memory swapaccount=1'
regex: '^((?!.*cgroup_enable=memory swapaccount=1).*)$'
2021-02-09 17:05:00 +01:00
- name: boot - stat config file
2021-07-14 21:38:30 +02:00
with_items: '{{boot_config|default([])}}'
2021-02-09 17:05:00 +01:00
stat:
path: '{{item.dest}}'
2021-07-14 21:38:30 +02:00
changed_when: false
register: boot_config_stat
2021-02-09 17:05:00 +01:00
- name: boot - update config
2021-07-14 21:38:30 +02:00
when: item.1.stat.exists
with_together:
- '{{boot_config|default([])}}'
- '{{boot_config_stat.results}}'
2021-02-09 17:05:00 +01:00
lineinfile:
backrefs: true
dest: '{{item.0.dest}}'
line: '{{item.0.line}}'
regex: '{{item.0.regex}}'
2021-07-14 21:38:30 +02:00
become: yes
2021-02-09 17:05:00 +01:00
notify:
2022-06-30 23:37:10 +02:00
- update boot - syslinux
- update boot - grub
2021-07-14 21:38:30 +02:00
register: boot_config_handler_notify