| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- ---
- - name: Define kernel regex
- set_fact: kernel_regex="\.yn[0-9]{8}\."
- - name: test if nbd is supported
- environment:
- PATH: $PATH:/usr/sbin:/sbin
- shell: modprobe nbd
- register: nbd_status
- ignore_errors: yes
- no_log: true
- failed_when: false
- - name: nbd facts
- set_fact:
- nbd_ok: true
- when: nbd_status.rc == 0
- - name: Is Cloud kernel running
- shell: |
- uname -r | grep -E "{{ kernel_regex }}"
- register: is_yunion_kernel_running
- changed_when: false
- failed_when: false
- - name: Is cloud kernel installed
- shell: |
- if rpm --version &>/dev/null; then
- count=$(rpm -qa |grep kernel |grep -E "{{ kernel_regex }}" |wc -l || :)
- elif dpkg --version &>/dev/null; then
- count=$(dpkg -l |grep kernel |grep -E "{{ kernel_regex }}" |wc -l || :)
- fi
- [[ "$count" -ge 1 ]]
- args:
- executable: /bin/bash
- register: is_yunion_kernel_installed
- changed_when: false
- failed_when: false
- - name: install customized kernel
- include_tasks: "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version |lower }}-{{ ansible_architecture }}.yml"
- when:
- - nbd_ok|default(false)|bool == false
- - is_yunion_kernel_installed.rc != 0
- - name: Check /proc/cmdline for huge pages configuration
- command: "grep -w 'hugepagesz=1G' /proc/cmdline"
- register: hugepagesz
- changed_when: false
- check_mode: true
- when:
- - ansible_architecture == 'x86_64'
- - name: Check /proc/cmdline for huge pages configuration
- command: "grep -w 'default_hugepagesz=1G' /proc/cmdline"
- register: default_hugepagesz
- changed_when: false
- check_mode: true
- when:
- - ansible_architecture == 'x86_64'
- - name: Check if oc-hugetlb-gigantic-pages.service is active
- shell:
- cmd: systemctl is-active oc-hugetlb-gigantic-pages
- register: hugepage_service_status
- failed_when: false
- when:
- - ansible_architecture == 'x86_64'
- - name: set default fact to_init_hugetlb
- set_fact:
- hugetlb_is_ready: false
- when:
- - ansible_architecture == 'x86_64'
- - name: Set hugetlb fact if conditions are met
- set_fact:
- hugetlb_is_ready: true
- when:
- - ansible_architecture == 'x86_64'
- - hugepagesz.rc == 0
- - default_hugepagesz.rc == 0
- - hugepage_service_status.rc == 0
- # setup hugetlb
- - name: Setup hugepage
- include_tasks: 'hugetlb.yml'
- when:
- - ansible_architecture == 'x86_64'
- - hugetlb_is_ready == false
- - name: SSH Reboot system if hugetlb conf is updated
- reboot:
- reboot_timeout: 900 # 15 mins
- connect_timeout: 900 # 15 mins
- become: yes
- when:
- - ansible_architecture == 'x86_64'
- - hugetlb_is_ready == false
- - is_controller_node is not defined or is_controller_node|default(false)|bool == false
- - ansible_connection == "ssh"
- - name: Local Reboot system if hugetlb conf is updated
- command: reboot
- become: yes
- when:
- - ansible_architecture == 'x86_64'
- - hugetlb_is_ready == false
- - is_controller_node is not defined or is_controller_node|default(false)|bool == false
- - ansible_connection == "local"
|