Introduce Centos7 support
This change introduces Centos7 support to engine using the default
scenario k8-calico-nofeature.
The distro to provision the machines with can be set by using -o
parameter of deploy.sh and it can either be ubuntu1804 or centos7.
If it is not specified, it will be set to ubuntu1804 by default.
Please note that only the default scenario, k8-calico-nofeature is
verified on centos7 so only this scenario is updated with centos7
in sdf.yml. The other scenarios will be updated once they are
verified on centos7. Apart from that, sdf.yml is updated with the
new name for the distro - previously it was only ubuntu and now
it is ubuntu1804.
DIB related parameters are also controlled by the distro setting now
and right dib_os_release and dib_os_element are set accordingly without
needing to set them manually.
Deployment image build using dib also depends on the variable
use_prebuilt_deployment_image now. If this variable is set to true like
how we are doing within CI, create_image_via_dib will be set to false.
Since use_prebuilt_deployment_image is set to false by default,
create_image_via_dib value will be set to true automatically for the
users who might be using the engine manually.
We also stopped calling out distro names for node configuration explicitly
and instead use ansible_os_family as we support one of each from debian
and rhel.
Change-Id: Ic951de6cf560d64630b72bd5727edafd9fb582bf
diff --git a/playbooks/roles/configure-targethosts/tasks/configure-network-RedHat.yml b/playbooks/roles/configure-targethosts/tasks/configure-network-RedHat.yml
new file mode 100644
index 0000000..729fed8
--- /dev/null
+++ b/playbooks/roles/configure-targethosts/tasks/configure-network-RedHat.yml
@@ -0,0 +1,56 @@
+---
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 The Nordix Foundation. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+- name: Configure modules
+ lineinfile:
+ dest: /etc/modules
+ state: present
+ create: yes
+ line: "8021q"
+
+- name: Add modules
+ modprobe:
+ name: 8021q
+ state: present
+
+- name: Compute mapping dict from mac address to device name
+ set_fact:
+ device_mac_dict: "{{ (device_mac_dict | default({})) | combine({item.macaddress: item.device}) }}"
+ with_items:
+ - "{{ ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined') | list }}"
+
+- name: Compute mapping dict from mac address to interface name (device name with/without VLAN info)
+ set_fact:
+ if_mac_dict: "{{ ( if_mac_dict | default({}) ) | combine({item.mac_address: (item.vlan == 'native') | ternary(device_mac_dict[item.mac_address], device_mac_dict[item.mac_address] + '.' + item.vlan) }) }}"
+ with_items:
+ - "{{ node.interfaces }}"
+
+- name: Configure networking for host
+ template:
+ src: "{{ ansible_os_family }}.interface.j2"
+ dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.value }}"
+ with_items:
+ - "{{ if_mac_dict | dict2items }}"
+
+- name: Restart network
+ service:
+ name: network
+ state: restarted
+
+# vim: set ts=2 sw=2 expandtab: