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

release: v1.1.0 #72

Merged
merged 130 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
6d0f9fa
make cluster master nodes unschedulable
Apr 10, 2024
c8f0eaa
ammend
Apr 11, 2024
e5d86cf
added '---' at the beginning of patch-cluster-masters-unschedulable.yml
Apr 15, 2024
d281f53
fixed typo
Apr 15, 2024
76f4de3
Allow setting ethernet IF on worker nodes
Apr 22, 2024
0a77f1d
fix: aws register_os, etc hosts pas, netcat
marcelmamula May 7, 2024
803b0b5
fix: etc host conditional updatd, linting fixed
marcelmamula May 7, 2024
a83b8e9
sap_vm_provision: hotfix for changed output error
sean-freeman May 7, 2024
4a455c1
Merge pull request #21 from newkit/feature_allow_setting_ethernet_dev…
sean-freeman May 7, 2024
4760b3a
Merge pull request #11 from newkit/feature_patch_masters_unschedulable
sean-freeman May 7, 2024
144dc98
Remove proxy for AWS
marcelmamula May 9, 2024
9865a40
Merge pull request #24 from marcelmamula/os_register
sean-freeman May 9, 2024
ce104ae
Merge pull request #25 from sean-freeman/dev
sean-freeman May 9, 2024
ebc6e81
sap_vm_provision: append byos to all cloud targets
sean-freeman May 9, 2024
68c0fa3
sap_vm_provision: fix missing auth
sean-freeman May 9, 2024
7a85e53
Merge pull request #26 from sean-freeman/dev
sean-freeman May 9, 2024
1f40100
sap_vm_provision: resolve when condition for new byos registration
sean-freeman May 10, 2024
8f9dfd4
Merge pull request #27 from sean-freeman/dev
sean-freeman May 10, 2024
c33e03f
sap_vm_provision: fix when condition for byos
sean-freeman May 20, 2024
db8fe35
sap_vm_provision: add var to change lb name for az gcp ibm
sean-freeman May 21, 2024
4232c75
Merge pull request #31 from sean-freeman/dev
sean-freeman May 21, 2024
e6af154
sap_vm_provision: amend var handling for storage and ha on ibmcloud
sean-freeman May 29, 2024
ad93f2f
Merge pull request #32 from sean-freeman/dev
sean-freeman May 29, 2024
a205d1d
sap_vm_provision: resolve anydb ha missing declarations
sean-freeman Jun 12, 2024
fae9d36
sap_vm_provision: missing scale-out logic for ibm platforms
sean-freeman Jun 12, 2024
71b4847
sap_vm_provision: fix var declare structure
sean-freeman Jun 12, 2024
637d236
sap_vm_provision: initial placement group logic
sean-freeman Jun 12, 2024
4152049
sap_vm_provision: fix lint whitespace
sean-freeman Jun 12, 2024
a3dc936
ssh-ed25519 support, typos, retries, azure auth
marcelmamula Jun 14, 2024
4cef47c
typo correction
marcelmamula Jun 14, 2024
b6ec291
Merge pull request #36 from marcelmamula/azure
sean-freeman Jun 19, 2024
5525ac7
sap_vm_provision: amend defaults file with placement vars
sean-freeman Jun 19, 2024
d4486a1
Merge pull request #34 from sean-freeman/structure_fixes
sean-freeman Jun 19, 2024
2d8a4b1
sap_vm_provision: add missing port to ibmcloud lb
sean-freeman Jun 20, 2024
abb6f35
sap_vm_provision: fix missing port ref
sean-freeman Jun 20, 2024
1316b94
Merge pull request #38 from sean-freeman/structure_fixes
sean-freeman Jun 21, 2024
80b91b1
sap_vm_provision: further placement strategy for platforms
sean-freeman Jun 24, 2024
6f0f302
Merge pull request #39 from sean-freeman/placement_groups
sean-freeman Jun 24, 2024
de859f8
sap_vm_provision: replace virtual ip defaults
sean-freeman Jun 24, 2024
fb20638
sap_vm_provision: set vars from new vip var
sean-freeman Jun 24, 2024
db820a4
Merge pull request #40 from sean-freeman/placement_groups
sean-freeman Jun 24, 2024
3df65d8
sap_vm_provision: fix when logic for vip changes
sean-freeman Jun 24, 2024
79ab44d
Merge pull request #41 from sean-freeman/placement_groups
sean-freeman Jun 24, 2024
6fa7f82
sap_vm_temp_vip: expand logic to cover more situations
sean-freeman Jun 25, 2024
a180137
Merge pull request #42 from sean-freeman/placement_groups
sean-freeman Jun 25, 2024
6212993
sap_vm_provision: fix aws placement group logic
sean-freeman Jun 26, 2024
a9b299c
sap_vm_temp_vip: fix syntax and change temp listener to 12h
sean-freeman Jun 26, 2024
7ecf68e
Merge pull request #43 from sean-freeman/placement_groups
sean-freeman Jun 26, 2024
7b77269
sap_vm_provision: update software path var to sap_install_media_detec…
sean-freeman Jun 26, 2024
589e3af
sap_vm_provision: remove sap_hana_install_software_directory
sean-freeman Jun 28, 2024
3cb76e9
Merge pull request #45 from sean-freeman/placement_groups
sean-freeman Jun 28, 2024
fad0fbd
sap_vm_provision: fixes for anydb ha
sean-freeman Jun 28, 2024
9f6e070
Merge pull request #48 from sean-freeman/placement_groups
sean-freeman Jun 28, 2024
0520f0e
sap_vm_temp_vip: force aws and gcp to use 32 cidr
sean-freeman Jul 1, 2024
d68aa33
/sap_vm_temp_vip: append noprefixroute param
sean-freeman Jul 1, 2024
28d7a06
Merge pull request #49 from sean-freeman/placement_groups
sean-freeman Jul 1, 2024
377f526
scaleout etc hosts fix
marcelmamula Jul 10, 2024
5a3f604
Added OCP Auth, replaced oc wait with k8s native function
Jun 24, 2024
3bfe334
aws fence fix, iam improved, parallel clusters
marcelmamula Jul 26, 2024
02dc95c
doc: AWS documentation links provided to explain
marcelmamula Jul 31, 2024
b26f267
Merge pull request #52 from marcelmamula/scaleout
sean-freeman Jul 31, 2024
d2bc0a5
feat: gcp improvements
marcelmamula Aug 12, 2024
57019f6
feat: Add optional AWS DNS overwrite
marcelmamula Aug 12, 2024
f44ece9
sap_vm_provision: add support for Red Hat OpenShift Virtualization
Jun 26, 2024
1b210b2
fix: added missing disk_type into module input
marcelmamula Aug 21, 2024
1f3f68d
Merge pull request #55 from marcelmamula/awsdns
marcelmamula Aug 22, 2024
797cf9f
fix: removed ha typo, comments update
marcelmamula Aug 22, 2024
0cbdec8
Merge pull request #44 from newkit/feature_sap_hypervisor_node_precon…
sean-freeman Aug 22, 2024
afe682f
Merge pull request #54 from marcelmamula/gcp
marcelmamula Aug 23, 2024
eafdf4a
feat: wait_for_connection 300 added
marcelmamula Aug 23, 2024
2a74d3e
fix: combined both tasks into block for parity
marcelmamula Aug 23, 2024
0d9c414
Merge branch 'dev' into feature_sap_vm_provision_add_ocpv
newkit Aug 26, 2024
2ea0f39
Merge pull request #47 from newkit/feature_sap_vm_provision_add_ocpv
rhmk Aug 26, 2024
ed17a55
Merge pull request #57 from marcelmamula/sshwait
rhmk Aug 27, 2024
360768f
sap_vm_temp_vip: enclose var
sean-freeman Aug 30, 2024
a451df4
sap_vm_provision: remove old dependencies
sean-freeman Aug 30, 2024
fe9633d
sap_vm_provision: add missing passthrough var for ibm db2 hadr
sean-freeman Aug 30, 2024
21562c6
sap_vm_provision: improve proxy logic
sean-freeman Aug 30, 2024
c64bea5
sap_vm_provision: improve ha exec flow and fix placement group missin…
sean-freeman Aug 30, 2024
ff60ad1
sap_vm_provision: improve exec flow and storage tier logic
sean-freeman Aug 30, 2024
18d2631
sap_vm_provision: minor msazure exec flow change
sean-freeman Aug 30, 2024
f7b3fcb
sap_vm_provision: fix var reference to var lookup
ja9fuchs Sep 3, 2024
d90c358
Merge pull request #59 from ja9fuchs/fix-var-lookup
berndfinger Sep 4, 2024
314e2c5
Minor indentation fix for hpp workload field
geetikakay Sep 8, 2024
3faf1af
Merge pull request #60 from geetikakay/minor_fix_hpp_workload
newkit Sep 10, 2024
811dc27
fix: ascs typo in ers frontend
marcelmamula Sep 10, 2024
3ba7939
Merge pull request #61 from marcelmamula/gcp-ha
marcelmamula Sep 11, 2024
fb1c353
Update roles/sap_vm_provision/tasks/platform_ansible/ibmcloud_powervs…
berndfinger Sep 13, 2024
da4b895
Update roles/sap_vm_provision/tasks/platform_ansible/ibmcloud_vs/exec…
berndfinger Sep 13, 2024
74862b2
Merge pull request #58 from sean-freeman/placement_groups
berndfinger Sep 13, 2024
e1763a1
feat: GCP HA improvements, VIP fix
marcelmamula Sep 13, 2024
eef145f
Merge pull request #64 from marcelmamula/gcp
marcelmamula Sep 16, 2024
278602f
feat: Replaced shell with ansible tasks
marcelmamula Sep 23, 2024
a24ff8d
fix: dependent typos
marcelmamula Sep 23, 2024
f01c5e9
fix: correction of readme
marcelmamula Sep 23, 2024
dc0121d
fix: Typo in markdown block
marcelmamula Sep 24, 2024
be49fdd
sap_hypervisor_node_preconfigure: Checks to wait for right conditions…
geetikakay Sep 12, 2024
eeb08fb
sap_hypervisor_node_preconfigure: Include resource creation for Sriov…
geetikakay Sep 12, 2024
24f132c
Merge pull request #62 from geetikakay/dev_sriov_fixes
newkit Sep 24, 2024
c2699a9
fix: default 32 for AWS and GCP
marcelmamula Sep 25, 2024
ee0d67a
Update variable names for simpler understanding
marcelmamula Sep 26, 2024
fa058db
Remove prereq and add setup task to get facts instead
marcelmamula Sep 26, 2024
362901d
fix: remove gather_facts assert memo
marcelmamula Sep 26, 2024
4b4bc57
Merge pull request #63 from geetikakay/dev_pause_fixes
newkit Oct 7, 2024
9c6c800
Merge pull request #66 from marcelmamula/vip
marcelmamula Oct 18, 2024
b967b16
Remove enabled: true from storagebridge
geetikakay Nov 11, 2024
fac7bc8
Added support for selecting the subscription channel in kubevirt-hype…
geetikakay Nov 15, 2024
897787b
Merge pull request #67 from geetikakay/minor_bridge_config_fix
newkit Nov 19, 2024
7a3996a
Merge pull request #68 from geetikakay/add_subscription_channel
newkit Nov 19, 2024
f28c7f3
sap_vm_provision: update ibm powervs locations
sean-freeman Nov 22, 2024
c9dc0f1
sap_vm_provision: update os image defaults
sean-freeman Nov 22, 2024
53768a2
sap_vm_provision: append ibmcloud vni feature
sean-freeman Nov 23, 2024
b3b487f
sap_vm_provision: add private dns custom resolver to ibm powervs
sean-freeman Nov 23, 2024
e543da1
sap_vm_provision: update default map for os images
sean-freeman Nov 24, 2024
6037511
sap_vm_provision: add run once for ansible to terraform
sean-freeman Nov 24, 2024
a9ded53
sap_vm_provision: update terraform exec logic
sean-freeman Nov 25, 2024
4752945
Remove machineconfig label
geetikakay Nov 26, 2024
e869f92
sap_vm_provision: logic fixes to tf for ibm powervs
sean-freeman Nov 27, 2024
94ea71a
sap_vm_provision: append tf vars to ibm powervs
sean-freeman Nov 27, 2024
cd27851
sap_vm_provision: fix aws ec2 root auth keys entries
sean-freeman Nov 28, 2024
43b2e77
sap_vm_provision: fix incorrect var name
sean-freeman Nov 28, 2024
a401c5a
sap_vm_provision: different data response on rerun
sean-freeman Nov 28, 2024
cc67a3b
sap_vm_provision: fix web proxy http prefix
sean-freeman Nov 29, 2024
3f08b30
Merge pull request #70 from geetikakay/remove_machineconfig_label
sean-freeman Nov 30, 2024
bbbf906
sap_vm_provision: update byol os images
sean-freeman Nov 30, 2024
1be2fa4
Merge pull request #69 from sean-freeman/dev
sean-freeman Nov 30, 2024
083a42c
collection: update requirements
sean-freeman Nov 30, 2024
0e3524b
Merge pull request #71 from sean-freeman/dev
sean-freeman Nov 30, 2024
a3e262f
collection: changelog and version update
sean-freeman Dec 1, 2024
2e3d145
Merge pull request #73 from sean-freeman/dev
sean-freeman Dec 1, 2024
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
37 changes: 37 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@ community.sap_infrastructure Release Notes

.. contents:: Topics

v1.1.0
======

Release Summary
---------------

| Release Date: 2024-12-01
| sap_hypervisor_node_preconfigure: OCPv improve auth and add namespace targets
| sap_hypervisor_node_preconfigure: OCPv update default vars and var prefixes
| sap_hypervisor_node_preconfigure: OCPv add waits for resource readiness
| sap_hypervisor_node_preconfigure: OCPv improve SR-IOV handling
| sap_vm_provision: update platform guidance document
| sap_vm_provision: remove AWS CLI and GCloud CLI dependency
| sap_vm_provision: add spread placement strategy for AWS, GCP, IBM Cloud, MS Azure, IBM PowerVM
| sap_vm_provision: add AWS Route53 record overwrite
| sap_vm_provision: add IBM Cloud Private DNS Custom Resolver for IBM Power VS
| sap_vm_provision: add var for Virtual IP handling across multiple roles
| sap_vm_provision: fix /etc/hosts for Virtual IPs
| sap_vm_provision: add var for Load Balancer naming on GCP, IBM Cloud, MS Azure
| sap_vm_provision: update OS Images for AWS, GCP, IBM Cloud, MS Azure
| sap_vm_provision: add vars for Kubevirt VM
| sap_vm_provision: fix OS Subscription registration logic and BYOL/BYOS
| sap_vm_provision: improve Web Proxy logic
| sap_vm_provision: fix handling of nested variables within host_specifications_dictionary
| sap_vm_provision: fix handling of custom IOPS on AWS, GCP, IBM Cloud
| sap_vm_provision: fix handling of AWS IAM Policy for HA
| sap_vm_provision: fix handling of MS Azure IAM Role for HA
| sap_vm_provision: add google-guest-agent service for load balancer config
| sap_vm_provision: add readiness for AnyDB HA (e.g. IBM Db2 HADR)
| sap_vm_provision: update IBM Power VS locations lookup list
| sap_vm_provision: update logic for IBM Power VS Workspace with latest backend routing (PER)
| sap_vm_provision: update logic for IBM Cloud Virtual Network Interfaces (VNI)
| sap_vm_provision: fix Ansible to Terraform copy to working directory logic and note
| sap_vm_provision: update embedded Terraform Template with updated var names for imported Terraform Modules
| sap_vm_temp_vip: overhaul replace all shell logic with Ansible Modules and use special vars to determine OS network devices reliably
| sap_vm_temp_vip: overhaul documentation

v1.0.1
======

Expand Down
7 changes: 6 additions & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace: community
name: sap_infrastructure

# The version of the collection. Must be compatible with semantic versioning
version: 1.0.1
version: 1.1.0

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand All @@ -20,6 +20,7 @@ authors:
- Sean Freeman <sean.freeman(at)uk.ibm.com>
- Janine Fuchs <jfuchs(at)redhat.com>
- Nils Koenig <nkoenig(at)redhat.com>
- Marcel Mamula <marcel.mamula(at)suse.com>

### OPTIONAL but strongly recommended
# A short summary description of the collection
Expand All @@ -40,6 +41,10 @@ tags:
- database
- application
- sap
- infrastructure
- provision
- cloud
- hypervisor

# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
# collection label 'namespace.name'. The value is a version range
Expand Down
114 changes: 100 additions & 14 deletions playbooks/sample-sap-hypervisor-redhat-ocp-virt-preconfigure.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,105 @@
---

- name: Ansible Play to run sap_hypervisor_node_preconfigure Ansible Role
- name: Ansible Play to run sap_hypervisor_node_preconfigure Ansible Role for Red Hat OpenShift
hosts: all
gather_facts: true
serial: 1

gather_facts: false
vars:
sap_hypervisor_node_platform: redhat_ocp_virt
sap_hypervisor_node_kubeconfig: "{{ lookup( 'ansible.builtin.env', 'KUBECONFIG') }}"
sap_hypervisor_node_preconfigure_platform: redhat_ocp_virt
tasks:

environment:
KUBECONFIG: "{{ sap_hypervisor_node_kubeconfig }}"
K8S_AUTH_KUBECONFIG: "{{ sap_hypervisor_node_kubeconfig }}"
- name: Use kubeconfig file specified in environment variable K8S_AUTH_KUBECONFIG if sap_hypervisor_node_preconfigure_ocp_kubeconfig_path is not defined
when: >
sap_hypervisor_node_preconfigure_ocp_kubeconfig_path is not defined or
sap_hypervisor_node_preconfigure_ocp_kubeconfig_path == None or
sap_hypervisor_node_preconfigure_ocp_kubeconfig_path == ''
ansible.builtin.set_fact:
sap_hypervisor_node_preconfigure_ocp_kubeconfig_path: "{{ lookup('env', 'K8S_AUTH_KUBECONFIG') | default(None) }}"

tasks:
- name: Include sap_hypervisor_node_preconfigure Ansible Role
ansible.builtin.include_role:
name: sap_hypervisor_node_preconfigure
- name: Create Tempdir on jumphost
ansible.builtin.tempfile:
state: directory
suffix: "_sap_hypervisor_node_preconfigure"
register: __sap_hypervisor_node_preconfigure_register_tmpdir_jumphost

- name: Set kubeconfig file variable
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_kubeconfig: "{{ __sap_hypervisor_node_preconfigure_register_tmpdir_jumphost.path }}/kubeconfig"

- name: Read content of kubeconfig file
ansible.builtin.set_fact:
sap_hypervisor_node_preconfigure_ocp_kubeconfig_data:
"{{ lookup('file', sap_hypervisor_node_preconfigure_ocp_kubeconfig_path) | from_yaml }}"

- name: Read cluster endpoint and CA certificate from kubeconfig if either is not defined
when: sap_hypervisor_node_preconfigure_ocp_extract_kubeconfig
block:

- name: Set sap_hypervisor_node_preconfigure_ocp_endpoint from kubeconfig
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_ocp_endpoint:
"{{ sap_hypervisor_node_preconfigure_ocp_kubeconfig_data['clusters'][0]['cluster']['server'] }}"

- name: Write the certificate-authority-data to temp dir on jumphost
ansible.builtin.copy:
content: "{{ sap_hypervisor_node_preconfigure_ocp_kubeconfig_data['clusters'][0]['cluster']['certificate-authority-data'] | b64decode }}"
dest: "{{ __sap_hypervisor_node_preconfigure_register_tmpdir_jumphost.path }}/cluster-ca-cert.pem"
mode: "0666"

- name: Set CA file variable
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_ca_cert: "{{ __sap_hypervisor_node_preconfigure_register_tmpdir_jumphost.path }}/cluster-ca-cert.pem"


- name: Use predefined CA cert and API endpoint
when: not sap_hypervisor_node_preconfigure_ocp_extract_kubeconfig

block:
- name: Set predefined OCP API Endpoint
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_ocp_endpoint: "{{ sap_hypervisor_node_preconfigure_ocp_endpoint }}"

- name: Set predefined CA file
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_ca_cert: "{{ sap_hypervisor_node_preconfigure_ocp_ca_cert }}"


- name: Log into Red Hat OpenShift cluster (obtain access token)
community.okd.openshift_auth:
host: "{{ __sap_hypervisor_node_preconfigure_register_ocp_endpoint }}"
username: "{{ sap_hypervisor_node_preconfigure_ocp_admin_username }}"
password: "{{ sap_hypervisor_node_preconfigure_ocp_admin_password }}"
ca_cert: "{{ __sap_hypervisor_node_preconfigure_register_ca_cert }}"
register: __sap_vm_provision_register_ocp_auth_results

- name: Set token in kubeconfig
ansible.builtin.set_fact:
sap_hypervisor_node_preconfigure_ocp_kubeconfig_data: >-
{{
sap_hypervisor_node_preconfigure_ocp_kubeconfig_data | combine({
'users': sap_hypervisor_node_preconfigure_ocp_kubeconfig_data.users | map('combine', [{'user': {'token': __sap_vm_provision_register_ocp_auth_results.openshift_auth.api_key }}] )
}, recursive=True)
}}

- name: Write the updated kubeconfig
ansible.builtin.copy:
content: "{{ sap_hypervisor_node_preconfigure_ocp_kubeconfig_data | to_nice_yaml }}"
dest: "{{ __sap_hypervisor_node_preconfigure_register_kubeconfig }}"
mode: "0600"

- name: Invoke role with credentials set as environment variables
delegate_to: "{{ inventory_hostname }}"
delegate_facts: true
environment:
KUBECONFIG: "{{ __sap_hypervisor_node_preconfigure_register_kubeconfig }}"
K8S_AUTH_KUBECONFIG: "{{ __sap_hypervisor_node_preconfigure_register_kubeconfig }}"
block:

- name: Include sap_hypervisor_node_preconfigure Ansible Role
ansible.builtin.include_role:
name: community.sap_infrastructure.sap_hypervisor_node_preconfigure

always:

- name: Remove temporary directory
ansible.builtin.file:
state: absent
path: "{{ __sap_hypervisor_node_preconfigure_register_tmpdir_jumphost.path }}"
128 changes: 128 additions & 0 deletions playbooks/sample-sap-vm-provision-redhat-ocpv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
- name: Preparation Ansible Play for SAP VM provisioning on Red Hat OpenShift Virtualization
hosts: all
gather_facts: false
serial: 1
vars:
sap_vm_provision_iac_type: ansible
sap_vm_provision_iac_platform: kubevirt_vm
pre_tasks:
# Alternative to executing ansible-playbook with -e for Ansible Extravars file
# - name: Include sample variables for Red Hat Openshift Virtualization
# ansible.builtin.include_vars: ./vars/sample-variables-sap-vm-provision-redhat-ocpv.yml
tasks:

- name: Save inventory_host as execution_host
ansible.builtin.set_fact:
sap_vm_provision_execution_host: "{{ inventory_hostname }}"

- name: Save ansible_user as execution_host user
ansible.builtin.set_fact:
__sap_vm_provision_kubevirt_vm_register_execution_host_user: "{{ ansible_user }}"

- name: Use kubeconfig file specified in environment variable K8S_AUTH_KUBECONFIG if sap_vm_provision_kubevirt_vm_kubeconfig_path is not defined
when: >
sap_vm_provision_kubevirt_vm_kubeconfig_path is not defined or
sap_vm_provision_kubevirt_vm_kubeconfig_path == None or
sap_vm_provision_kubevirt_vm_kubeconfig_path == ''
ansible.builtin.set_fact:
sap_vm_provision_kubevirt_vm_kubeconfig_path: "{{ lookup('env', 'K8S_AUTH_KUBECONFIG') | default(None) }}"

- name: Create Tempdir
ansible.builtin.tempfile:
state: directory
suffix: "_sap_vm_provision_kubevirt_vm"
register: __sap_vm_provision_kubevirt_vm_register_tmpdir

- name: Set kubeconfig file variable
ansible.builtin.set_fact:
__sap_vm_provision_kubevirt_vm_register_kubeconfig: "{{ __sap_vm_provision_kubevirt_vm_register_tmpdir.path }}/kubeconfig"

- name: Read content of kubeconfig file
ansible.builtin.set_fact:
__sap_vm_provision_kubevirt_vm_register_kubeconfig_data:
"{{ lookup('file', sap_vm_provision_kubevirt_vm_kubeconfig_path) | from_yaml }}"

- name: Read cluster endpoint and CA certificate from kubeconfig if either is not defined
when: sap_vm_provision_kubevirt_vm_extract_kubeconfig
block:

- name: Set sap_vm_provision_kubevirt_vm_api_endpoint from kubeconfig
ansible.builtin.set_fact:
__sap_vm_provision_kubevirt_vm_register_api_endpoint:
"{{ __sap_vm_provision_kubevirt_vm_register_kubeconfig_data['clusters'][0]['cluster']['server'] }}"

- name: Write the certificate-authority-data to temp dir
ansible.builtin.copy:
content: "{{ __sap_vm_provision_kubevirt_vm_register_kubeconfig_data['clusters'][0]['cluster']['certificate-authority-data'] | b64decode }}"
dest: "{{ __sap_vm_provision_kubevirt_vm_register_tmpdir.path }}/cluster-ca-cert.pem"
mode: "0600"

- name: Set CA file variable
ansible.builtin.set_fact:
__sap_vm_provision_kubevirt_vm_register_ca_cert: "{{ __sap_vm_provision_kubevirt_vm_register_tmpdir.path }}/cluster-ca-cert.pem"

- name: Use predefined CA cert and API endpoint
when: not sap_vm_provision_kubevirt_vm_extract_kubeconfig
block:
- name: Set predefined OCP API Endpoint
ansible.builtin.set_fact:
__sap_vm_provision_kubevirt_vm_register_api_endpoint: "{{ sap_vm_provision_kubevirt_vm_api_endpoint }}"

- name: Set predefined CA file
ansible.builtin.set_fact:
__sap_vm_provision_kubevirt_vm_register_ca_cert: "{{ sap_vm_provision_kubevirt_vm_ca_cert }}"

- name: Log into Red Hat OpenShift cluster (obtain access token)
community.okd.openshift_auth:
host: "{{ __sap_vm_provision_kubevirt_vm_register_api_endpoint }}"
username: "{{ sap_vm_provision_kubevirt_vm_admin_username }}"
password: "{{ sap_vm_provision_kubevirt_vm_admin_password }}"
ca_cert: "{{ __sap_vm_provision_kubevirt_vm_register_ca_cert }}"
register: __sap_vm_provision_kubevirt_vm_register_kubevirt_vm_auth_results

- name: Set token in kubeconfig
ansible.builtin.set_fact:
__sap_vm_provision_kubevirt_vm_register_kubeconfig_data: >-
{{
__sap_vm_provision_kubevirt_vm_register_kubeconfig_data | combine({
'users': __sap_vm_provision_kubevirt_vm_register_kubeconfig_data.users | map('combine', [{'user': {'token': __sap_vm_provision_kubevirt_vm_register_kubevirt_vm_auth_results.openshift_auth.api_key }}] )
}, recursive=True)
}}
- name: Write the updated kubeconfig
ansible.builtin.copy:
content: "{{ __sap_vm_provision_kubevirt_vm_register_kubeconfig_data | to_nice_yaml }}"
dest: "{{ __sap_vm_provision_kubevirt_vm_register_kubeconfig }}"
mode: "0600"

- name: Create dynamic inventory group for Ansible Role sap_vm_provision and provide execution_host and api token
ansible.builtin.add_host:
name: "{{ item }}"
group: sap_vm_provision_target_inventory_group
sap_vm_provision_execution_host: "{{ sap_vm_provision_execution_host }}"
__sap_vm_provision_kubevirt_vm_register_execution_host_user: "{{ __sap_vm_provision_kubevirt_vm_register_execution_host_user }}"
__sap_vm_provision_kubevirt_vm_register_tmpdir: "{{ __sap_vm_provision_kubevirt_vm_register_tmpdir }}"
__sap_vm_provision_kubevirt_vm_register_kubeconfig: "{{ __sap_vm_provision_kubevirt_vm_register_kubeconfig }}"
loop: "{{ sap_vm_provision_kubevirt_vm_host_specifications_dictionary[sap_vm_provision_host_specification_plan].keys() }}"

- name: Ansible Play to provision VMs for SAP
hosts: sap_vm_provision_target_inventory_group # Ansible Play target hosts pattern, use Inventory Group created by previous Ansible Task (add_host)
gather_facts: false
environment:
K8S_AUTH_KUBECONFIG: "{{ __sap_vm_provision_kubevirt_vm_register_kubeconfig }}"
tasks:

- name: Execute Ansible Role sap_vm_provision
when: sap_vm_provision_iac_type == "ansible" or sap_vm_provision_iac_type == "ansible_to_terraform"
block:
- name: Include sap_vm_provision Ansible Role
ansible.builtin.include_role:
name: community.sap_infrastructure.sap_vm_provision

always:
- name: Remove temporary directory on execution_host
delegate_to: "{{ sap_vm_provision_execution_host }}"
ansible.builtin.file:
state: absent
path: "{{ __sap_vm_provision_kubevirt_vm_register_tmpdir.path }}"
Loading
Loading