Configure Kernel Args and Tuned and then reboot for Compute

* On top of the https://review.openstack.org/#/c/411204
* Added Kernel args and Tune-d configuration
* Added provision to provide different kernel args per role (applicable
  for different types of compute roles only)

Implements: blueprint tuned-nfv-dpdk

Change-Id: I5c538428c376c9d2ebd1c364f0ee8503fd7d620e
This commit is contained in:
Saravanan KR 2016-12-16 18:45:57 +05:30
parent 384c400d47
commit 4f9a16d38b
3 changed files with 174 additions and 0 deletions

View File

@ -0,0 +1,16 @@
resource_registry:
# Create the registry only for roles with the word "Compute" in it. Like ComputeOvsDpdk, ComputeSriov, etc.,
{% for role in roles %}
{% if "Compute" in role.name %}
OS::TripleO::{{role.name}}::PreNetworkConfig: ../extraconfig/pre_network/{{role.name.lower()}}-host_config_and_reboot.yaml
{% endif %}
{% endfor %}
parameter_defaults:
# Sample parameters for Compute and ComputeOvsDpdk roles
#ComputeKernelArgs: ""
#ComputeTunedProfileName: ""
#ComputeHostCpuList: ""
#ComputeOvsDpdkKernelArgs: ""
#ComputeOvsDpdkTunedProfileName: ""
#ComputeOvsDpdkHostCpuList: ""

View File

@ -0,0 +1,58 @@
---
- name: Configuration to be applied before rebooting the node
connection: local
hosts: localhost
tasks:
# Kernel Args Configuration
- block:
- name: Ensure the kernel args ( {{ _KERNEL_ARGS_ }} ) is present as TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS
lineinfile:
dest: /etc/default/grub
regexp: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
insertafter: '^GRUB_CMDLINE_LINUX.*'
line: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" {{ _KERNEL_ARGS_ }} "'
- name: Add TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS to the GRUB_CMDLINE_LINUX parameter
lineinfile:
dest: /etc/default/grub
line: 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX:+$GRUB_CMDLINE_LINUX }${TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}"'
insertafter: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
- name: Generate grub config file
command: grub2-mkconfig -o /boot/grub2/grub.cfg
become: true
when: _KERNEL_ARGS_|default("") != ""
# Tune-d Configuration
- block:
- name: Tune-d Configuration
lineinfile:
dest: /etc/tuned/cpu-partitioning-variables.conf
regexp: '^isolated_cores=.*'
line: 'isolated_cores={{ _HOST_CPUS_LIST_ }}'
when: _HOST_CPUS_LIST_|default("") != ""
- name: Tune-d provile activation
shell: tuned-adm profile {{ _TUNED_PROFILE_NAME_ }}
become: true
when: _TUNED_PROFILE_NAME_|default("") != ""
# Provisioning Network workaround
# The script will be executed before os-net-config, in which case, only Provisioning network will have IP
# BOOTPROTO of all interface config files (except provisioning), will be set to "none" to avoid reboot failing to acquire IP on other networks
- block:
- find:
paths: /etc/sysconfig/network-scripts/
patterns: ifcfg-*
register: ifcfg_files
- replace:
dest: "{{ item.path }}"
regexp: '^BOOTPROTO=.*'
replace: 'BOOTPROTO=none'
when:
- item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') != "lo"
# This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage)
# Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4']['address'] is undefined
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') ]['ipv4']['address'] is undefined
with_items:
- "{{ ifcfg_files.files }}"

View File

@ -0,0 +1,100 @@
heat_template_version: 2016-10-14
description: >
Do some configuration, then reboot - sometimes needed for early-boot
changes such as modifying kernel configuration
parameters:
server:
type: string
{{role}}KernelArgs:
type: string
default: ""
{{role}}TunedProfileName:
type: string
default: ""
{{role}}HostCpusList:
type: string
default: ""
conditions:
param_exists:
or:
- not:
equals:
- get_param: {{role}}KernelArgs
- ""
- not:
equals:
- get_param: {{role}}TunedProfileName
- ""
resources:
HostParametersConfig:
type: OS::Heat::SoftwareConfig
condition: param_exists
properties:
group: ansible
inputs:
- name: _KERNEL_ARGS_
- name: _TUNED_PROFILE_NAME_
- name: _HOST_CPUS_LIST_
outputs:
- name: result
config:
get_file: ansible_host_config.ansible
HostParametersDeployment:
type: OS::Heat::SoftwareDeployment
condition: param_exists
properties:
name: HostParametersDeployment
server: {get_param: server}
config: {get_resource: HostParametersConfig}
actions: ['CREATE'] # Only do this on CREATE
input_values:
_KERNEL_ARGS_: {get_param: {{role}}KernelArgs}
_TUNED_PROFILE_NAME_: {get_param: {{role}}TunedProfileName}
_HOST_CPUS_LIST_: {get_param: {{role}}HostCpusList}
RebootConfig:
type: OS::Heat::SoftwareConfig
condition: param_exists
properties:
group: script
config: |
#!/bin/bash
# Stop os-collect-config to avoid any race collecting another
# deployment before reboot happens
systemctl stop os-collect-config.service
/sbin/reboot
RebootDeployment:
type: OS::Heat::SoftwareDeployment
condition: param_exists
depends_on: HostParametersDeployment
properties:
name: RebootDeployment
server: {get_param: server}
config: {get_resource: RebootConfig}
actions: ['CREATE'] # Only do this on CREATE
signal_transport: NO_SIGNAL
outputs:
result:
value:
get_attr: [HostParametersDeployment, result]
condition: param_exists
stdout:
value:
get_attr: [HostParametersDeployment, deploy_stdout]
condition: param_exists
stderr:
value:
get_attr: [HostParametersDeployment, deploy_stderr]
condition: param_exists
status_code:
value:
get_attr: [HostParametersDeployment, deploy_status_code]
condition: param_exists