Externalize role
This commit is contained in:
commit
e94fcdc2df
2 changed files with 43 additions and 0 deletions
30
files/usr/local/sbin/update-grub
Executable file
30
files/usr/local/sbin/update-grub
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /etc/os-release
|
||||
if [ -d /sys/firmware/efi -a -e /boot/efi/EFI/centos/grub.cfg ]; then
|
||||
CONFDIR=/boot/efi/EFI/centos
|
||||
else
|
||||
CONFDIR=/boot/grub2
|
||||
fi
|
||||
#grep "^menuentry" /boot/grub2/grub.cfg | cut -d "'" -f2 | grep -Ev '(with debugging$|-rescue-)' | grep ^"$NAME" | sort -n | tail -n 1
|
||||
# grep "^menuentry" /boot/grub2/grub.cfg | cut -d "'" -f2 | grep -Ev '(with debugging$|-rescue-)' | head -n1
|
||||
# grub2-set-default "CentOS Linux (4.7.2-1.el7.elrepo.x86_64) 7 (Core)"
|
||||
# Contrôle : grub2-editenv list
|
||||
KERNLIST="$(ls -1 /boot/vmlinuz-* | grep -v rescue | sed 's|/boot/vmlinuz-\([.0-9]*\)-.*|\1|')"
|
||||
LASTMAJKERNEL="$(echo $KERNLIST | sed 's/ /\n/g' | cut -d. -f1 | sort -n -u | while read i; do
|
||||
echo $KERNLIST | sed 's/ /\n/g' | grep ^$i | cut -d. -f1-2 | sort -n -u -k2 -t.
|
||||
done | while read j; do
|
||||
echo $KERNLIST | sed 's/ /\n/g' | grep ^$j | sort -n -u -k3 -t.
|
||||
done | tail -n 1)"
|
||||
|
||||
KERNLIST="$(ls -1 /boot/vmlinuz-* | grep -v rescue | sed 's|/boot/vmlinuz-'${LASTMAJKERNEL}'-\([.0-9]*\).*|\1|')"
|
||||
LASTKERNEL="${LASTMAJKERNEL}-$(echo $KERNLIST | sed -e 's/ /\n/g' -e 's/.$//' | cut -d. -f1 | sort -n -u | while read i; do
|
||||
echo $KERNLIST | sed 's/ /\n/g' | grep ^$i | cut -d. -f1-2 | sort -n -u -k2 -t.
|
||||
done | while read j; do
|
||||
echo $KERNLIST | sed 's/ /\n/g' | grep ^$j | sort -n -u -k3 -t.
|
||||
done | tail -n 1)"
|
||||
|
||||
grub2-set-default "$(grep "^menuentry" "${CONFDIR}"/grub.cfg | cut -d "'" -f2 | grep -Ev '(with debugging$|-rescue-)' | grep ^"$NAME" | grep $LASTKERNEL | sort -n | tail -n 1)"
|
||||
|
||||
grub2-mkconfig -o "${CONFDIR}"/grub.cfg
|
||||
|
||||
13
tasks/main.yml
Normal file
13
tasks/main.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
- name: Install script update-grub
|
||||
copy: src=files/usr/local/sbin/update-grub dest=/usr/local/sbin/update-grub owner=root group=root mode=0755
|
||||
when: ansible_architecture == "x86_64" or ansible_architecture == "i386"
|
||||
- stat: path=/etc/dracut.conf.d/02-rescue.conf
|
||||
register: st
|
||||
- name: Copy dracut's rescue config file
|
||||
copy: src=/usr/lib/dracut/dracut.conf.d/02-rescue.conf dest=/etc/dracut.conf.d/02-rescue.conf remote_src=yes
|
||||
when: not st.stat.exists
|
||||
- name: Disable dracut's recue img
|
||||
lineinfile: dest=/etc/dracut.conf.d/02-rescue.conf regexp="^dracut_rescue_image" line="dracut_rescue_image=no" state=present
|
||||
# Nécessite un handler pour regénérer l'initramfs
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue