Skip to content
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

[sap_vm_provision] add support for Red Hat Openshift Virtualization #35

Closed
wants to merge 0 commits into from

Conversation

newkit
Copy link
Contributor

@newkit newkit commented Jun 13, 2024

[sap_vm_provision] add support for Red Hat Openshift Virtualization

There has been added support to create VMs on Red Hat OpenShift Virtualization platform. Simultaneous deployment of multiple VMs is supported. Further configuration of the VM other than basic OS install and configuration through cloud-init is out of scope and should be handled by other roles.

[sap_hypervisor_node_preconfigure] Removed oc binary dependency
Included and tested the oc wait improvements by @geetikakay from this PR

Copy link

@0xFelix 0xFelix left a comment

Choose a reason for hiding this comment

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

Added some comments

kubeconfig: "{{ sap_hypervisor_node_preconfigure_ocp_kubeconfig }}"
kind: Node
register: __sap_hypervisor_node_preconfigure_register_nodes
until: __sap_hypervisor_node_preconfigure_register_nodes.resources | json_query('[?status.conditions[?type==`Ready` && status==`True`]].metadata.name') |\
Copy link

Choose a reason for hiding this comment

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

Maybe this can be expressed in wait_condition too?

Copy link
Contributor Author

@newkit newkit Jun 20, 2024

Choose a reason for hiding this comment

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

Unfortunately, k8s_info does not provide wait_condition.

Copy link

Choose a reason for hiding this comment

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

Comment on lines 15 to 16
api_key: "{{ __sap_hypervisor_node_preconfigure_register_openshift_auth_results.openshift_auth.api_key }}"
kubeconfig: "{{ sap_hypervisor_node_preconfigure_ocp_kubeconfig }}"
Copy link

Choose a reason for hiding this comment

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

Isn't setting host + ca_cert + api_key and kubeconfig redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the same, but the k8s module is unhappy if either of them is not set. This might be a bug there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting all in enviroment though is possible and is kind of a workaround for that, too.

@@ -1,6 +1,10 @@
---
- name: Create SAP bridge NodeNetworkConfigurationPolicy
kubernetes.core.k8s:
host: "{{ sap_hypervisor_node_preconfigure_ocp_endpoint }}"
Copy link

Choose a reason for hiding this comment

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

Might be easier to export the auth settings in env variables, to avoid adding them to every single invocation of a module?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, agreed. I've solved it via delegate_to and setting the environment there but you seem not to be too happy with that (comment below).

until: __sap_hypervisor_node_preconfigure_register_cnv_subscription_install_plan_name.stdout != ""
changed_when: __sap_hypervisor_node_preconfigure_register_cnv_subscription_install_plan_name.stdout != ""
until: __sap_hypervisor_node_preconfigure_register_cnv_subscription_install_plan_name.resources[0].status.installPlanRef.name is defined
changed_when: __sap_hypervisor_node_preconfigure_register_cnv_subscription_install_plan_name.resources[0].status.installPlanRef.name is defined
Copy link

Choose a reason for hiding this comment

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

That means essentially changed_when: True considering the until above?

delay: 5
ignore_errors: true

- name: Fail if Install Plan is not Complete after waiting
Copy link

Choose a reason for hiding this comment

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

Could this be avoided by adding a failed_when above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

failed_when is not a generic attribute, moreover, it's not available for kubernetes.core.k8s_info

@@ -71,6 +72,7 @@ For a list of requirements and recommended authorizations on each Infrastructure
- `openstacksdk` for IBM PowerVM
- `ovirt-engine-sdk-python` for OVirt
- `aiohttp` for VMware
- `kubernetes` for Kubernetes based platforms such as Red Hat Openshift Virtualization
Copy link

Choose a reason for hiding this comment

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

Suggested change
- `kubernetes` for Kubernetes based platforms such as Red Hat Openshift Virtualization
- `kubernetes` for Kubernetes based platforms such as Red Hat OpenShift Virtualization

sap_vm_provision_ocp_os_user: minion

# Password for the above user
sap_vm_provision_ocp_os_user_password: banana
Copy link

Choose a reason for hiding this comment

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

It would be safer to not provide defaults for passwords. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, should be removed.

---
- name: Ansible Task block for looped provisioning of KubeVirt Virtual Machines
any_errors_fatal: true
# Using environment, no_log is ineffective and log will show 'EXEC /bin/sh -c 'ENV_VAR=value python3 /AnsiballZ_ansible_module_name.py && sleep 0'
Copy link

Choose a reason for hiding this comment

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

I wonder if that could be avoided by setting env vars outside of the playbook?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? The way I could make it work is by setting up the environment in a delegate_to statement. How would you set the environment inside the playbook? The other option I had was setting it explicitly on every call, which you didn't like either (above).

'spec' : {
'source' : {
'registry' : {
'url': __sap_vm_provision_register_vm_config.os_image.url,
Copy link

Choose a reason for hiding this comment

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

Could this use ImageStreams provided by OCP instead of using URLs?

interfaces: "{{ __sap_vm_provision_register_network_interfaces }}"

cpu:
cores: "{{ __sap_vm_provision_register_vm_config.kubevirt_vm_cpu_cores | int }}"
Copy link

Choose a reason for hiding this comment

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

Could these resource allocations be expressed in an instancetype instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants