Heat templates for deploying OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

104 lines
4.3 KiB

  1. - name: Get the command line args of the node
  2. command: cat /proc/cmdline
  3. register: cmdline
  4. - name: Get the active tuned profile
  5. command: tuned-adm active
  6. become: true
  7. register: tuned_active_profile
  8. # Kernel Args Configuration
  9. - block:
  10. - name: Ensure the kernel args ( {{ _KERNEL_ARGS_ }} ) is present as TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS
  11. lineinfile:
  12. dest: /etc/default/grub
  13. regexp: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
  14. insertafter: '^GRUB_CMDLINE_LINUX.*'
  15. line: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" {{ _KERNEL_ARGS_ }} "'
  16. - name: Add TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS to the GRUB_CMDLINE_LINUX parameter
  17. lineinfile:
  18. dest: /etc/default/grub
  19. line: 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX:+$GRUB_CMDLINE_LINUX }${TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}"'
  20. insertafter: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
  21. - name: Check grub config paths
  22. stat:
  23. path: "{{ item }}"
  24. register: grub_stat
  25. loop:
  26. - /boot/grub2/grub.cfg
  27. - /boot/efi/EFI/redhat/grub.cfg
  28. - /boot/efi/EFI/centos/grub.cfg
  29. - /boot/efi/EFI/fedora/grub.cfg
  30. - name: Generate grub config
  31. command: "grub2-mkconfig -o {{ item.stat.path }}"
  32. when: item.stat.exists|bool
  33. loop: "{{ grub_stat.results }}"
  34. - name: Set reboot required fact
  35. set_fact:
  36. reboot_required: true
  37. become: true
  38. when:
  39. - _KERNEL_ARGS_|default("") != ""
  40. - _KERNEL_ARGS_|default("") not in cmdline.stdout_lines[0]
  41. # Tune-d Configuration
  42. - block:
  43. - name: Check Tune-d Configuration file exists
  44. stat:
  45. path: /etc/tuned/{{ _TUNED_PROFILE_NAME_ }}-variables.conf
  46. register: tuned_conf_stat_result
  47. - name: Tune-d Configuration
  48. lineinfile:
  49. dest: /etc/tuned/{{ _TUNED_PROFILE_NAME_ }}-variables.conf
  50. regexp: '^isolated_cores=.*'
  51. line: 'isolated_cores={{ _TUNED_CORES_ }}'
  52. when: tuned_conf_stat_result.stat.exists and _TUNED_CORES_|default("") != ""
  53. - name: Tune-d profile activation
  54. shell: tuned-adm profile {{ _TUNED_PROFILE_NAME_ }}
  55. - name: Set reboot required fact
  56. set_fact:
  57. reboot_required: true
  58. become: true
  59. when:
  60. - _TUNED_PROFILE_NAME_|default("") != ""
  61. - _TUNED_PROFILE_NAME_|default("") not in tuned_active_profile.stdout_lines[0]
  62. # Check if os-net-config has run once, if yes, no need for the below workaround
  63. - find:
  64. paths: /etc/sysconfig/network-scripts/
  65. patterns: ifcfg-*
  66. contains: "# This file is autogenerated by os-net-config"
  67. register: os_net_ifcfg_files
  68. # Provisioning Network workaround
  69. # The script will be executed before os-net-config, in which case, only Provisioning network will have IP
  70. # BOOTPROTO of all interface config files (except provisioning), will be set to "none" to avoid reboot failing to acquire IP on other networks
  71. - block:
  72. - find:
  73. paths: /etc/sysconfig/network-scripts/
  74. patterns: ifcfg-*
  75. register: ifcfg_files
  76. - replace:
  77. dest: "{{ item.path }}"
  78. regexp: '^BOOTPROTO=.*'
  79. replace: 'BOOTPROTO=none'
  80. when:
  81. - item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') != "lo"
  82. # Ensure the interface information is available in the facts
  83. - hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') ] is defined
  84. # This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage)
  85. # Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4'] is undefined
  86. - hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') ]['ipv4'] is undefined
  87. with_items:
  88. - "{{ ifcfg_files.files }}"
  89. become: true
  90. when: os_net_ifcfg_files.matched == 0
  91. - name: Create a temp file to identify if reboot is required or not
  92. file:
  93. path: "/tmp/kernel_args_reboot_required.ansible"
  94. state: touch
  95. when: reboot_required is defined and reboot_required