Commit 2fea6a16 by Kevin Falcone

Merge pull request #2885 from edx/max/enhanced-networking

OPS-1383: Add role for turning on enhanced networking
parents 16691e37 c8f1f45d
profile: edx
compatible_instance_types: ['c3', 'c4', 'd2', 'i2', 'm4', 'r3']
\ No newline at end of file
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Tasks for role enhanced_networking
#
# Overview:
#
# This role ensures that enhanced networking
# (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html)
# is turned on on the AWS EC2 instances to which it it is applied.
#
# Note that turning on enhanced networking requires this role restart the instances
# where it turns it on. Instances where enhanced networking is already on or where
# enhanced networking is not supported for their instance type will NOT be restarted.
#
# Uses local actions so multiple actions can be done in parallel.
#
- name: Get ec2 facts
ec2_facts:
- name: Test for enhanced networking
local_action:
module: shell aws --profile {{ profile }} ec2 describe-instance-attribute --instance-id {{ ansible_ec2_instance_id }} --attribute sriovNetSupport
changed_when: False
become: False
register: enhanced_networking_raw
- name: Test for kernel module
shell: 'modinfo ixgbevf | grep -E ^version: | sed -E "s/^version: *//"'
register: ixgbevf_kernel_module
ignore_errors: yes
- set_fact:
# AWS would like 2.16 or 2.14 of this module, but says that Ubuntu's default of 2.11.3-k is ok
has_ixgbevf_kernel_module: "{{ (ixgbevf_kernel_module.stdout | default('0.0.0')) | replace('-k','') | version_compare('2.11.3','>=', strict=True) }}"
supports_enhanced_networking: "{{ (ansible_ec2_instance_type[:2] | lower) in compatible_instance_types }}"
enhanced_networking_already_on: "{{ (enhanced_networking_raw.stdout | from_json).SriovNetSupport.Value | default(None) == 'simple' }}"
- name: Shut down instances
local_action:
module: ec2
instance_ids: "{{ ansible_ec2_instance_id }}"
state: stopped
region: "{{ ansible_ec2_placement_region }}"
profile: "{{ profile }}"
wait: yes
become: False
when: supports_enhanced_networking and has_ixgbevf_kernel_module and not enhanced_networking_already_on
- name: Set enhanced networking instance attribute
local_action:
module: shell aws --profile {{ profile }} ec2 modify-instance-attribute --instance-id {{ ansible_ec2_instance_id }} --sriov-net-support simple
when: supports_enhanced_networking and has_ixgbevf_kernel_module and not enhanced_networking_already_on
- name: Start instances
local_action:
module: ec2
ansible_ec2_instance_ids: "{{ ansible_ec2_instance_id }}"
state: running
region: "{{ ansible_ec2_placement_region }}"
profile: "{{ profile }}"
wait: yes
become: False
when: supports_enhanced_networking and has_ixgbevf_kernel_module and not enhanced_networking_already_on
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment