Skip to content

playbooks: Added Initial Ansible Playbooks #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions playbooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Intel Technology Enabling Ansible Playbooks

## Overview
This directory contains Ansible playbooks designed to automate the deployment and configuration of Intel technologies on Red Hat OpenShift clusters. These playbooks streamline the Intel feature provisioning and validation process on OpenShift environments.

## Prerequisites
Before running the playbook, ensure the following prerequisites are met:
- Provisioned RHOCP Cluster
- Red Hat Enterprise Linux (RHEL) system with [Ansible](https://docs.ansible.com/ansible/2.9/installation_guide/intro_installation.html#installing-ansible-on-rhel-centos-or-fedora) installed and configured with a `kubeconfig` to connect to your RHOCP cluster.

## Run the Playbook

To run the ansible playbook, clone this repository to your RHEL system. Navigate to the directory containing the playbook.

```bash
git clone https://github.com/intel/intel-technology-enabling-for-openshift.git

cd intel-technology-enabling-for-openshift/

ansible-playbook playbooks/intel_ocp_provisioning.yaml
```
17 changes: 17 additions & 0 deletions playbooks/configure_nfd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- name: NFD - Create NFD discovery CR
k8s:
state: present
definition: '{{ item }}'
wait: yes
wait_condition:
type: Available
status: 'False'
with_items: '{{ lookup("url", "https://raw.githubusercontent.com/intel/intel-technology-enabling-for-openshift/main/nfd/node-feature-discovery-openshift.yaml", split_lines=False) | from_yaml_all | list }}'
when: (item is not none)
- name: NFD - Create NFD rules instance CR
k8s:
state: present
definition: '{{ item }}'
wait: yes
with_items: '{{ lookup("url", "https://raw.githubusercontent.com/intel/intel-technology-enabling-for-openshift/main/nfd/node-feature-rules-openshift.yaml", split_lines=False) | from_yaml_all | list }}'
when: (item is not none)
27 changes: 27 additions & 0 deletions playbooks/install_device_plugins_operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- name: Create global OperatorGroup in openshift-operators namespace
k8s:
state: present
definition:
apiVersion: operators.coreos.com/v1alpha2
kind: OperatorGroup
metadata:
name: global-operators
namespace: openshift-operators

- name: Create Intel Device Plugins Operator Subscription
k8s:
state: present
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
labels:
operators.coreos.com/intel-device-plugins-operator.openshiftoperators: ""
name: intel-device-plugins-operator
namespace: openshift-operators
spec:
channel: alpha
installPlanApproval: Automatic
name: intel-device-plugins-operator
source: certified-operators
sourceNamespace: openshift-marketplace
38 changes: 38 additions & 0 deletions playbooks/install_nfd_operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
- name: Create namespace for Node Feature Discovery
k8s:
state: present
definition:
apiVersion: v1
kind: Namespace
metadata:
name: openshift-nfd

- name: Create operator group for Node Feature Discovery
k8s:
state: present
definition:
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
generateName: openshift-nfd-
name: openshift-nfd
namespace: openshift-nfd
spec:
targetNamespaces:
- openshift-nfd

- name: Subscribe to Node Feature Discovery operator
k8s:
state: present
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: nfd
namespace: openshift-nfd
spec:
channel: "stable"
installPlanApproval: Automatic
name: nfd
source: redhat-operators
sourceNamespace: openshift-marketplace
78 changes: 78 additions & 0 deletions playbooks/intel_ocp_provisioning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
- hosts: localhost
gather_facts: no
vars:
kubeconfig_path: "~/.kube/mojave-config"
environment:
KUBECONFIG: "{{ kubeconfig_path }}"
vars_prompt:
- name: "install_operators"
prompt: "Do you want to install operators? 'Yes' to install NFD Operator and Intel Device Plugins Operator, or 'No' to skip"
private: no
- name: "validation_feature"
prompt: "Which Intel feature do you want to validate? Enter 1 for Intel SGX, 2 for Intel QAT, 3 for Intel DSA, 4 for Intel GPU"
private: no

tasks:
- name: Validate Inputs
block:
- name: Invalid Install Operators Input
fail:
msg: "Invalid input for Install Operators. Please enter a valid option for Install Operators (Yes/No)."
when: install_operators not in ["Yes", "No"]
- name: Invalid Validation Feature Input
fail:
msg: "Invalid input for validation feature. Please enter a valid option (1-4)."
when: validation_feature not in ["1", "2", "3", "4"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can user input something like 1,2 to test 1 and 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I have only added 1 or 2 not "and". I will check how we can add 'and'


- name: Install Operators
block:
- name: NFD - Install NFD Operator
include_tasks: install_nfd_operator.yaml
- name: IDPO - Install Intel Device Plugins Operator
include_tasks: install_device_plugins_operator.yaml
- name: NFD - Wait until the nfd-operator-controller Deployment is available
k8s_info:
kind: Deployment
wait: yes
name: nfd-controller-manager
label_selectors:
- operators.coreos.com/nfd.openshift-nfd
- control-plane=controller-manager
namespace: openshift-nfd
wait_condition:
type: Available
status: 'True'
- name: NFD - Configure NFD Operator
include_tasks: configure_nfd.yaml
- name: IDPO - Wait until the inteldeviceplugins-controller-manager Deployment is available
k8s_info:
kind: Deployment
name: inteldeviceplugins-controller-manager
namespace: openshift-operators
wait: yes
wait_condition:
type: Available
status: 'True'
reason: MinimumReplicasAvailable
when: install_operators == "Yes"

- name: Skip Operator Installation
debug:
msg: "Skipping operator installation as per user input."
when: install_operators == "No"

- name: Validate Intel SGX
include_tasks: validate_sgx.yaml
when: validation_feature == "1"

- name: Validate Intel QAT
include_tasks: validate_gpu.yaml
when: validation_feature == "2"

- name: Validate Intel DSA
include_tasks: validate_qat.yaml
when: validation_feature == "3"

- name: Validate Intel GPU
include_tasks: validate_dsa.yaml
when: validation_feature == "4"