Add OCP-CNV patching demo (#140)
This commit is contained in:
committed by
GitHub
parent
65936930c0
commit
40807f1eab
101
openshift/cnv/install.yml
Normal file
101
openshift/cnv/install.yml
Normal 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
37
openshift/cnv/patch.yml
Normal 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
|
||||
76
openshift/cnv/provision.yml
Normal file
76
openshift/cnv/provision.yml
Normal 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
|
||||
96
openshift/cnv/provision_rhel.yml
Normal file
96
openshift/cnv/provision_rhel.yml
Normal 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
14
openshift/cnv/wait.yml
Normal 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
|
||||
@@ -1,2 +1,2 @@
|
||||
---
|
||||
gitlab_chart_version: "8.0.1"
|
||||
gitlab_chart_version: "8.0.1"
|
||||
|
||||
23
openshift/inventory.kubevirt.yml
Normal file
23
openshift/inventory.kubevirt.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
plugin: redhat.openshift_virtualization.kubevirt
|
||||
strict: true
|
||||
connections:
|
||||
- namespaces:
|
||||
- openshift-cnv
|
||||
compose:
|
||||
ansible_user: "'cloud-user' if 'rhel' in annotations['vm.kubevirt.io/os']"
|
||||
annotations: "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: "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: annotations.os
|
||||
prefix: "cnv"
|
||||
separator: "_"
|
||||
@@ -1,4 +1,35 @@
|
||||
---
|
||||
controller_components:
|
||||
- execution_environments
|
||||
- credential_types
|
||||
- credentials
|
||||
- inventory_sources
|
||||
- job_templates
|
||||
- workflow_job_templates
|
||||
|
||||
controller_credential_types:
|
||||
# Ideally, we would not need to use this and could just re-use the OCP credential for the inventory plugin
|
||||
- name: OCPV inventory credential
|
||||
kind: cloud
|
||||
inputs:
|
||||
fields:
|
||||
- id: host
|
||||
type: string
|
||||
label: OpenShift or Kubernetes API Endpoint
|
||||
secret: false
|
||||
- id: bearer_token
|
||||
type: string
|
||||
label: API authentication bearer token
|
||||
secret: true
|
||||
- id: verify_ssl
|
||||
type: boolean
|
||||
label: Verify SSL
|
||||
injectors:
|
||||
env:
|
||||
K8S_AUTH_HOST: "{% raw %}{ { host }}{% endraw %}"
|
||||
K8S_AUTH_API_KEY: "{% raw %}{ { bearer_token }}{% endraw %}"
|
||||
K8S_AUTH_VERIFY_SSL: "{% raw %}{ { verify_ssl }}{% endraw %}"
|
||||
|
||||
controller_credentials:
|
||||
- name: OpenShift Credential
|
||||
organization: Default
|
||||
@@ -9,7 +40,149 @@ controller_credentials:
|
||||
bearer_token: CHANGEME
|
||||
verify_ssl: false
|
||||
|
||||
- name: OCP-V Inventory Credential
|
||||
organization: Default
|
||||
credential_type: OCPV inventory credential
|
||||
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: OCP-V Inventory Credential
|
||||
update_on_launch: true
|
||||
|
||||
controller_templates:
|
||||
- name: OpenShift / CNV / Install
|
||||
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:
|
||||
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"
|
||||
@@ -31,3 +204,53 @@ controller_templates:
|
||||
notification_templates_error: Telemetry
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user