Merge branch 'main' into usr_app

This commit is contained in:
willtome
2024-08-27 07:47:24 -04:00
committed by GitHub
162 changed files with 15439 additions and 1998 deletions

View File

@@ -14,7 +14,7 @@ This category of demos shows examples of openshift operations and management wit
- [**OpenShift / Dev Spaces**](devspaces.yml) - Install and deploy dev spaces on OCP cluster. After this job has run successfully, login to your OCP cluster, click the application icon (to the left of the bell icon in the top right) to access Dev Spaces
## Pre Setup
This demo requires an OpenShift cluster to deploy to. If you do not have a cluster to use, one can be requested from [demo.redhat.com](https://demo.redhat.com).
This demo requires an OpenShift cluster to deploy to. If you do not have a cluster to use, one can be requested from [demo.redhat.com](https://demo.redhat.com).
- Search for the [Red Hat OpenShift Container Platform 4.12 Workshop](https://demo.redhat.com/catalog?item=babylon-catalog-prod/sandboxes-gpte.ocp412-wksp.prod&utm_source=webapp&utm_medium=share-link) item in the catalog and request with the number of users you would like for Dev Spaces.
- Login using the admin credentials provided. Click the `admin` username at the top right and select `Copy login command`.
- Authenticate and click `Display Token`. This information will be used to populate the OpenShift Credential after you run the setup.

101
openshift/cnv/install.yml Normal file
View File

@@ -0,0 +1,101 @@
---
- name: Deploy OpenShift CNV Operator and create the Hyperconverged object, provision VM to prove funciontality
hosts: localhost
gather_facts: false
vars:
vm_name: ocpvtest
vm_namespace: openshift-cnv
tasks:
- name: Include role
ansible.builtin.include_role:
name: demo.openshift.cluster_config
- name: Attempt to Provision a VM
kubernetes.core.k8s:
wait: true
state: "{{ instance_state | default('present') }}"
definition:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: "{{ vm_name }}"
namespace: "{{ vm_namespace }}"
labels:
app: "{{ vm_name }}"
vm.kubevirt.io/name: "{{ vm_name }}"
spec:
dataVolumeTemplates:
- apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
creationTimestamp: null
name: "{{ vm_name }}"
spec:
sourceRef:
kind: DataSource
name: "{{ os_version | default('fedora') }}"
namespace: openshift-virtualization-os-images
storage:
resources:
requests:
storage: 30Gi
running: true
template:
metadata:
annotations:
vm.kubevirt.io/flavor: small
vm.kubevirt.io/os: "{{ os_version | default('fedora') }}"
vm.kubevirt.io/workload: server
creationTimestamp: null
labels:
kubevirt.io/domain: "{{ vm_name }}"
kubevirt.io/size: small
spec:
domain:
cpu:
cores: 4
sockets: 1
threads: 1
devices:
disks:
- disk:
bus: virtio
name: rootdisk
interfaces:
- masquerade: {}
model: virtio
name: default
networkInterfaceMultiqueue: true
rng: {}
machine:
type: pc-q35-rhel9.2.0
resources:
requests:
memory: 8Gi
evictionStrategy: LiveMigrate
networks:
- name: default
pod: {}
terminationGracePeriodSeconds: 180
volumes:
- dataVolume:
name: "{{ vm_name }}"
name: rootdisk
retries: 60
delay: 5
register: provision
until: provision.changed
- name: Clean up test VM
kubernetes.core.k8s:
wait: true
state: absent
definition:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: "{{ vm_name }}"
namespace: "{{ vm_namespace }}"
labels:
app: "{{ vm_name }}"
vm.kubevirt.io/name: "{{ vm_name }}"

37
openshift/cnv/patch.yml Normal file
View File

@@ -0,0 +1,37 @@
---
- name: Linux server patching for OpenShift Virtalized Hosts
hosts: "{{ _hosts | default(omit) }}"
become: true
tasks:
# Install yum-utils if it's not there
- name: Install yum-utils
ansible.builtin.yum:
name: yum-utils
state: installed
- name: Include patching role
ansible.builtin.include_role:
name: demo.patching.patch_linux
- name: Tell user when Insights Client is not configured
ansible.builtin.debug:
msg: "Insights client does not appear to be configured. Scan will be skipped"
when:
- ansible_local.insights.system_id is not defined
- name: Run the Insights Client Scan # noqa: no-changed-when
ansible.builtin.command: insights-client
when:
- not ansible_check_mode
- ansible_local.insights.system_id is defined
- name: Create nginx container
when: not ansible_check_mode
delegate_to: localhost
become: false
connection: local
run_once: true # noqa: run-once[task]
block:
- name: Publish landing page
ansible.builtin.include_role:
name: demo.patching.report_ocp_patching

View File

@@ -0,0 +1,76 @@
---
- name: De-Provision OCP-CNV VM
hosts: localhost
tasks:
- name: Define resources
kubernetes.core.k8s:
wait: true
state: "{{ instance_state | default('present') }}"
definition:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: "{{ vm_name }}"
namespace: "{{ vm_namespace }}"
labels:
app: "{{ vm_name }}"
os.template.kubevirt.io/fedora36: 'true'
vm.kubevirt.io/name: "{{ vm_name }}"
spec:
dataVolumeTemplates:
- apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
creationTimestamp: null
name: "{{ vm_name }}"
spec:
sourceRef:
kind: DataSource
name: "{{ os_version |default('rhel9') }}"
namespace: openshift-virtualization-os-images
storage:
resources:
requests:
storage: 30Gi
running: true
template:
metadata:
annotations:
vm.kubevirt.io/flavor: small
vm.kubevirt.io/os: "{{ os_version | default('rhel9') }}"
vm.kubevirt.io/workload: server
creationTimestamp: null
labels:
kubevirt.io/domain: "{{ vm_name }}"
kubevirt.io/size: small
spec:
domain:
cpu:
cores: 4
sockets: 1
threads: 1
devices:
disks:
- disk:
bus: virtio
name: rootdisk
interfaces:
- masquerade: {}
model: virtio
name: default
networkInterfaceMultiqueue: true
rng: {}
machine:
type: pc-q35-rhel9.2.0
resources:
requests:
memory: 8Gi
evictionStrategy: LiveMigrate
networks:
- name: default
pod: {}
terminationGracePeriodSeconds: 180
volumes:
- dataVolume:
name: "{{ vm_name }}"
name: rootdisk

View File

@@ -0,0 +1,96 @@
---
- name: Provision OCP-CNV RHEL VM
hosts: localhost
tasks:
- name: Define resources
redhat.openshift.k8s:
wait: true
state: "{{ instance_state | default('present') }}"
definition:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: "{{ vm_name }}"
namespace: "{{ vm_namespace }}"
labels:
app: "{{ vm_name }}"
os.template.kubevirt.io/fedora36: 'true'
vm.kubevirt.io/name: "{{ vm_name }}"
spec:
dataVolumeTemplates:
- apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
creationTimestamp: null
name: "{{ vm_name }}"
spec:
sourceRef:
kind: DataSource
name: "{{ os_version }}"
namespace: openshift-virtualization-os-images
storage:
resources:
requests:
storage: 30Gi
running: true
template:
metadata:
annotations:
vm.kubevirt.io/flavor: small
vm.kubevirt.io/os: "{{ os_version }}"
vm.kubevirt.io/workload: server
creationTimestamp: null
labels:
kubevirt.io/domain: "{{ vm_name }}"
kubevirt.io/size: small
spec:
domain:
cpu:
cores: 4
sockets: 1
threads: 1
devices:
disks:
- disk:
bus: virtio
name: rootdisk
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- masquerade: {}
model: virtio
name: default
networkInterfaceMultiqueue: true
rng: {}
machine:
type: pc-q35-rhel9.2.0
resources:
requests:
memory: 8Gi
evictionStrategy: LiveMigrate
networks:
- name: default
pod: {}
terminationGracePeriodSeconds: 180
volumes:
- dataVolume:
name: "{{ vm_name }}"
name: rootdisk
- name: cloudinitdisk
cloudInitNoCloud:
userData: |-
#cloud-config
chpasswd: { expire: False }
ssh_pwauth: False
ssh_authorized_keys:
- "{{ ssh_authorized_key }}"
rh_subscription:
activation-key: "{{ rh_subscription_key }}"
org: "{{ rh_subscription_org }}"
- name: Wait for VM to be running
redhat.openshift_virtualization.kubevirt_vm_info:
name: "{{ vm_name }}"
namespace: "{{ vm_namespace }}"
wait: true

14
openshift/cnv/wait.yml Normal file
View File

@@ -0,0 +1,14 @@
---
- name: Wait for VMs to start and become ready
hosts: "{{ _hosts | default(omit) }}"
gather_facts: false
tasks:
- name: Wait for
ansible.builtin.wait_for:
port: 22
host: '{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}'
search_regex: OpenSSH
delay: 10
retries: 10
vars:
ansible_connection: local

View File

@@ -0,0 +1,8 @@
---
- name: Deploy EDA Controller attached to the same AAP
hosts: localhost
gather_facts: false
tasks:
- name: Include role
ansible.builtin.include_role:
name: demo.openshift.eda_controller

View File

@@ -4,14 +4,14 @@
gather_facts: false
tasks:
- name: create cert-manager-operator namespace
- name: Create cert-manager-operator namespace
redhat.openshift.k8s:
name: cert-manager-operator
api_version: v1
kind: Namespace
state: present
- name: create OperatorGroup object for cert-manager-operator
- name: Create OperatorGroup object for cert-manager-operator
redhat.openshift.k8s:
state: present
definition:
@@ -22,9 +22,9 @@
namespace: cert-manager-operator
spec:
targetNamespaces:
- cert-manager-operator
- cert-manager-operator
- name: create cert-manager-operator subscription
- name: Create cert-manager-operator subscription
redhat.openshift.k8s:
state: present
definition:
@@ -42,14 +42,14 @@
source: redhat-operators
sourceNamespace: openshift-marketplace
- name: create gitlab-system namespace
- name: Create gitlab-system namespace
redhat.openshift.k8s:
name: gitlab-system
api_version: v1
kind: Namespace
state: present
- name: create OperatorGroup object for gitlab-operator-kubernetes
- name: Create OperatorGroup object for gitlab-operator-kubernetes
redhat.openshift.k8s:
state: present
definition:
@@ -60,9 +60,9 @@
namespace: gitlab-system
spec:
targetNamespaces:
- gitlab-system
- gitlab-system
- name: create gitlab subscription
- name: Create gitlab subscription
redhat.openshift.k8s:
state: present
definition:
@@ -80,8 +80,8 @@
source: community-operators
sourceNamespace: openshift-marketplace
- name: wait for gitlab operator to install
k8s_info:
- name: Wait for gitlab operator to install
kubernetes.core.k8s_info:
api_version: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
name: gitlabs.apps.gitlab.com
@@ -91,7 +91,7 @@
delay: 30
- name: Wait until gitlab-operator is up
k8s_info:
kubernetes.core.k8s_info:
api_version: v1
kind: Deployment
name: gitlab-controller-manager
@@ -117,7 +117,7 @@
namespace: gitlab-system
spec:
chart:
version: "6.11.0"
version: "{{ gitlab_chart_version }}"
values:
nginx-ingress:
enabled: false
@@ -125,7 +125,7 @@
install: false
global:
hosts:
domain: "{{ cluster_domain }}" # apps.cluster-9xrlv.9xrlv.sandbox644.opentlc.com
domain: "{{ cluster_domain }}" # apps.cluster-9xrlv.9xrlv.sandbox644.opentlc.com
ingress:
class: none
configureCertmanager: true

View File

@@ -0,0 +1,2 @@
---
gitlab_chart_version: "8.0.1"

View File

@@ -0,0 +1,23 @@
---
plugin: redhat.openshift_virtualization.kubevirt
strict: true
connections:
- namespaces:
- openshift-cnv
compose:
ansible_user: "'cloud-user' if 'rhel' in vmi_annotations['vm.kubevirt.io/os']"
vmi_annotations: "vmi_annotations | ansible.utils.replace_keys(target=[
{'before':'vm.kubevirt.io/os', 'after':'os'},
{'before':'vm.kubevirt.io/flavor', 'after':'flavor'},
{'before':'vm.kubevirt.io/workload', 'after':'workload'},
{'before':'kubevirt.io/vm-generation', 'after':'vm-generation'},
{'before':'kubevirt.io/latest-observed-api-version', 'after':'latest-observed-api-version'},
{'before':'kubevirt.io/storage-observed-api-version', 'after':'storage-observed-api-version' }] )"
labels: "vmi_labels | ansible.utils.replace_keys(target=[
{'before':'kubevirt.io/nodeName', 'after':'nodeName'},
{'before':'kubevirt.io/size', 'after':'size'},
{'before':'kubevirt.io/domain', 'after':'domain' }] )"
keyed_groups:
- key: vmi_annotations.os
prefix: "cnv"
separator: "_"

View File

@@ -2,7 +2,9 @@
controller_components:
- projects
- credentials
- inventory_sources
- job_templates
- workflow_job_templates
controller_projects:
- name: USR App
@@ -15,12 +17,159 @@ controller_credentials:
- name: OpenShift Credential
organization: Default
credential_type: OpenShift or Kubernetes API Bearer Token
state: exists
inputs:
host: CHANGEME
bearer_token: CHANGEME
verify_ssl: false
controller_inventory_sources:
- name: OpenShift CNV Inventory
inventory: Demo Inventory
source: scm
source_project: Ansible official demo project
source_path: openshift/inventory.kubevirt.yml
credential: OpenShift Credential
update_on_launch: false
controller_templates:
- name: OpenShift / EDA / Install Controller
job_type: run
inventory: "Demo Inventory"
project: "Ansible official demo project"
playbook: "openshift/eda/install.yml"
notification_templates_started: Telemetry
notification_templates_success: Telemetry
notification_templates_error: Telemetry
survey_enabled: true
credentials:
- "OpenShift Credential"
- "Controller Credential"
- name: OpenShift / CNV / Install Operator
job_type: run
inventory: "Demo Inventory"
project: "Ansible official demo project"
playbook: "openshift/cnv/install.yml"
notification_templates_started: Telemetry
notification_templates_success: Telemetry
notification_templates_error: Telemetry
survey_enabled: true
credentials:
- "OpenShift Credential"
- name: OpenShift / CNV / Create RHEL VM
job_type: run
inventory: "Demo Inventory"
project: "Ansible official demo project"
playbook: "openshift/cnv/provision_rhel.yml"
notification_templates_started: Telemetry
notification_templates_success: Telemetry
notification_templates_error: Telemetry
survey_enabled: true
allow_simultaneous: true
survey:
name: ''
description: ''
spec:
- question_name: VM name
type: text
variable: vm_name
default: rhel9
required: true
- question_name: VM NameSpace
type: text
variable: vm_namespace
default: openshift-cnv
required: true
- question_name: SSH Authorized Key
type: textarea
variable: ssh_authorized_key
required: true
- question_name: OS Version
type: text
variable: os_version
default: rhel9
required: true
- question_name: RHEL Activation Key
type: text
variable: rh_subscription_key
required: true
- question_name: RHEL Organization ID
type: text
variable: rh_subscription_org
required: true
credentials:
- "OpenShift Credential"
- name: OpenShift / CNV / Delete VM
job_type: run
inventory: "Demo Inventory"
project: "Ansible official demo project"
playbook: "openshift/cnv/provision.yml"
notification_templates_started: Telemetry
notification_templates_success: Telemetry
notification_templates_error: Telemetry
survey_enabled: true
extra_vars:
instance_state: absent
survey:
name: ''
description: ''
spec:
- question_name: VM name
type: text
variable: vm_name
required: true
- question_name: VM NameSpace
type: text
variable: vm_namespace
default: openshift-cnv
required: true
credentials:
- "OpenShift Credential"
- name: OpenShift / CNV / Patching
job_type: check
inventory: "Demo Inventory"
project: "Ansible official demo project"
playbook: "openshift/cnv/patch.yml"
notification_templates_started: Telemetry
notification_templates_success: Telemetry
notification_templates_error: Telemetry
ask_job_type_on_launch: true
credentials:
- "OpenShift Credential"
- "Demo Credential"
survey_enabled: true
survey:
name: ''
description: ''
spec:
- question_name: Server Name or Pattern
type: text
variable: _hosts
default: "openshift-cnv-rhel*"
required: true
- name: OpenShift / CNV / Wait Hosts
inventory: "Demo Inventory"
project: "Ansible official demo project"
playbook: "openshift/cnv/wait.yml"
notification_templates_started: Telemetry
notification_templates_success: Telemetry
notification_templates_error: Telemetry
survey_enabled: true
survey:
name: ''
description: ''
spec:
- question_name: Wait hosts
type: text
variable: _hosts
default: "openshift-cnv-rhel*"
required: true
- name: OpenShift / Dev Spaces
job_type: run
inventory: "Demo Inventory"
@@ -54,3 +203,53 @@ controller_templates:
credentials:
- "OpenShift Credential"
controller_workflows:
- name: OpenShift / CNV / Infra Stack
description: A workflow to deploy Virtualized infra in OCP Virtalization
organization: Default
notification_templates_started: Telemetry
notification_templates_success: Telemetry
notification_templates_error: Telemetry
survey_enabled: true
survey:
name: ''
description: ''
spec:
- question_name: SSH Authorized Key
type: textarea
variable: ssh_authorized_key
required: true
- question_name: RHEL Activation Key
type: text
variable: rh_subscription_key
required: true
- question_name: RHEL Organization ID
type: text
variable: rh_subscription_org
required: true
simplified_workflow_nodes:
- identifier: Deploy RHEL8 VM
unified_job_template: OpenShift / CNV / Create RHEL VM
extra_data:
vm_name: rhel8
os_version: rhel8
success_nodes:
- Update Inventory
failure_nodes:
- Ticket - Instance Failed
- identifier: Deploy RHEL9 VM
unified_job_template: OpenShift / CNV / Create RHEL VM
extra_data:
vm_name: rhel9
os_version: rhel9
success_nodes:
- Update Inventory
failure_nodes:
- Ticket - Instance Failed
- identifier: Update Inventory
unified_job_template: OpenShift CNV Inventory
- identifier: Ticket - Instance Failed
unified_job_template: 'SUBMIT FEEDBACK'
extra_data:
feedback: Failed to create CNV instance