Browse Source

Issue #382: Configuring Dell PowerSwitches

Signed-off-by: sakshiarora13 <sakshi_arora1@dell.com>
Lucas A. Wilson 3 years ago
parent
commit
438c2f3d96

+ 2 - 0
control_plane/ethernet.yml

@@ -17,6 +17,8 @@
    hosts: all
    gather_facts: false
    connection: network_cli
+   collections:
+    - dellemc.os10
    vars:
      ansible_network_os: dellemc.os10.os10
    roles:

+ 110 - 1
control_plane/input_params/ethernet_vars.yml

@@ -11,4 +11,113 @@
 #  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.
----
+
+
+# ---Default configurations written for Dell PowerSwitch S4128T-ON---
+# ---Change the configurations as per the switch model to avoid failures---
+
+# Global configuration for switch
+os10_config:
+    - "interface vlan1"
+    - "exit"
+
+# Interface configuration for switch
+os10_interface:
+    ethernet 1/1/1:
+      desc: "Port 1"
+      admin: up
+    ethernet 1/1/2:
+      desc: "Port 2"
+      admin: up
+    ethernet 1/1/3:
+      desc: "Port 3"
+      admin: up
+    ethernet 1/1/4:
+      desc: "Port 4"
+      admin: up
+    ethernet 1/1/5:
+      desc: "Port 5"
+      admin: up
+    ethernet 1/1/6:
+      desc: "Port 6"
+      admin: up
+    ethernet 1/1/7:
+      desc: "Port 7"
+      admin: up
+    ethernet 1/1/8:
+      desc: "Port 8"
+      admin: up
+    ethernet 1/1/9:
+      desc: "Port 9"
+      admin: up
+    ethernet 1/1/10:
+      desc: "Port 10"
+      admin: up
+    ethernet 1/1/11:
+      desc: "Port 11"
+      admin: up
+    ethernet 1/1/12:
+      desc: "Port 12"
+      admin: up
+    ethernet 1/1/13:
+      desc: "Port 13"
+      admin: up
+    ethernet 1/1/14:
+      desc: "Port 14"
+      admin: up
+    ethernet 1/1/15:
+      desc: "Port 15"
+      admin: up
+    ethernet 1/1/16:
+      desc: "Port 16"
+      admin: up
+    ethernet 1/1/17:
+      desc: "Port 17"
+      admin: up
+    ethernet 1/1/18:
+      desc: "Port 18"
+      admin: up
+    ethernet 1/1/19:
+      desc: "Port 19"
+      admin: up
+    ethernet 1/1/20:
+      desc: "Port 20"
+      admin: up
+    ethernet 1/1/21:
+      desc: "Port 21"
+      admin: up
+    ethernet 1/1/22:
+      desc: "Port 22"
+      admin: up
+    ethernet 1/1/23:
+      desc: "Port 23"
+      admin: up
+    ethernet 1/1/24:
+      desc: "Port 24"
+      admin: up
+    ethernet 1/1/25:
+      desc: "Port 25"
+      admin: up
+    ethernet 1/1/26:
+      desc: "Port 26"
+      admin: up
+    ethernet 1/1/27:
+      desc: "Port 27"
+      admin: up
+    ethernet 1/1/28:
+      desc: "Port 28"
+      admin: up
+    ethernet 1/1/29:
+      desc: "Port 29"
+      admin: up
+    ethernet 1/1/30:
+      desc: "Port 30"
+      admin: up
+    vlan 1:
+      admin: up
+
+# save_changes_to_startup is a boolean flag. By default, this option is set to false.
+# When set to true, it will save the switch's running configuration to the startup configuration file
+# after the role applies its configuration. This will allow the configuration to persist after a
+# restart or power failure.
+save_changes_to_startup: false

+ 3 - 0
control_plane/roles/network_ethernet/files/temp/readme.md

@@ -0,0 +1,3 @@
+This folder is to store temporary files for powerswitch configuration. 
+
+Deleting this folder may result in unexpected failure.

+ 31 - 0
control_plane/roles/network_ethernet/tasks/apply_config.yml

@@ -0,0 +1,31 @@
+# Copyright 2021 Dell Inc. or its subsidiaries. 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.
+
+---
+- name: Set build directory
+  set_fact:
+    build_dir: "{{ role_path }}/files/temp"
+
+- name: Apply switch configuration
+  dellos10_config:
+    commands: "{{ os10_config }}"
+  when: os10_config is defined
+
+- name: Apply switch interface configuration
+  include_role:
+    name: dellemc.os10.os10_interface
+  vars:
+    - hostname: "{{ inventory_hostname }}"
+      os10_cfg_generate: true
+  when: os10_interface is defined

+ 27 - 13
control_plane/roles/network_ethernet/tasks/main.yml

@@ -1,19 +1,33 @@
 # Copyright 2021 Dell Inc. or its subsidiaries. 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
+# 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
+#     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.
+# 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.
 ---
+# tasks file for network_ethernet
 
-# Will be updated later in each PR
-- name: Pass
-  debug:
-    msg: "Pass"
+- name: Include base variable file
+  include_vars: "{{ base_vars_file }}"
+
+- name: Check if ethernet switch is supported
+  block:
+    - name: Check pre-requisites
+      include_tasks: pre_requisites.yml
+
+    - name: Configure switch
+      include_tasks: apply_config.yml
+
+    - name: Save current switch configuration to startup-configuration
+      dellos10_command:
+        commands: "copy running-configuration startup-configuration"
+      when: save_changes_to_startup
+
+  when: ethernet_switch_support

+ 37 - 0
control_plane/roles/network_ethernet/tasks/pre_requisites.yml

@@ -0,0 +1,37 @@
+# Copyright 2021 Dell Inc. or its subsidiaries. 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.
+---
+
+- name: Check if ethernet_vars.yml exists
+  stat:
+    path: "{{ config_file }}"
+  register: stat_result
+
+- name: Fail if config file doesn't exist
+  fail:
+    msg: "{{ fail_msg_config_file }}"
+  when: not stat_result.stat.exists
+
+- name: Include switch config variable file
+  include_vars: "{{ config_file }}"
+
+- name: Assert save_config variable
+  assert:
+    that: "save_changes_to_startup == true or save_changes_to_startup == false"
+    success_msg: "{{ success_msg_save_config }}"
+    fail_msg: "{{ fail_msg_save_config }}"
+
+- name: Install paramiko
+  command: pip3 install paramiko -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
+  changed_when: false

+ 22 - 0
control_plane/roles/network_ethernet/vars/main.yml

@@ -0,0 +1,22 @@
+# Copyright 2021 Dell Inc. or its subsidiaries. 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.
+---
+# vars file for network_ethernet
+
+# Usage: pre_requisites.yml
+base_vars_file: "{{ role_path }}/../../input_params/base_vars.yml"
+config_file: "{{ role_path }}/../../input_params/ethernet_vars.yml"
+fail_msg_config_file: Ethernet config file doesn't exist.
+success_msg_save_config: Ethernet config file validated.
+fail_msg_save_config: save_config variable can only be set to true or false.

+ 10 - 0
roles/k8s_start_services/tasks/main.yml

@@ -181,6 +181,16 @@
   when: "'amdgpu-device-plugin' not in k8s_pods.stdout"
   tags: init
 
+- name: Install Spark Operator
+  command: "helm repo add spark-operator https://googlecloudplatform.github.io/spark-on-k8s-operator"
+  changed_when: true
+  tags: init
+
+- name: Install Spark Operator Namespace
+  command: "helm install my-release spark-operator/spark-operator --namespace spark-operator --create-namespace"
+  changed_when: true
+  tags: init
+
 - name: Deploy Volcano Scheduling
   command: "kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/master/installer/volcano-development.yaml"
   changed_when: true