Skip to content

Commit

Permalink
sap_vm_provision: sample for test run
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-freeman committed Apr 5, 2024
1 parent dbf6119 commit 2e5e771
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 7 deletions.
39 changes: 39 additions & 0 deletions playbooks/sample-sap-vm-provision-aws-ec2-vs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---

# This sample Ansible Playbook is not a full example,
# which would pass additional variables onto other
# Ansible Roles such as sap_storage_setup.
# It is only to test the provisioning process
# of a small Virtual Machine.

- name: Ansible Play to include_vars
hosts: all
become: true
pre_tasks:

# Alternative to executing ansible-playbook with -e for Ansible Extravars file
- name: Include sample variables for AWS EC2
ansible.builtin.include_vars: ./vars/sample-variables-sap-vm-provision-aws-ec2-vs.yml


- name: Ansible Play to create dynamic inventory group for provisioning
hosts: localhost
gather_facts: false
tasks:

- name: Create dynamic inventory group for Ansible Role sap_vm_provision
ansible.builtin.add_host:
name: "{{ item }}"
group: sap_vm_provision_target_inventory_group
loop: "{{ sap_vm_provision_ibmcloud_vs_host_specifications_dictionary[sap_vm_provision_host_specification_plan].keys() }}"


- name: Ansible Play to provision hosts 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
tasks:

- name: Execute Ansible Role sap_vm_provision
ansible.builtin.include_role:
name: community.sap_infrastructure.sap_vm_provision
when: sap_vm_provision_iac_type == "ansible" or sap_vm_provision_iac_type == "ansible_to_terraform"
70 changes: 70 additions & 0 deletions playbooks/vars/sample-variables-sap-vm-provision-aws-ec2-vs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---

# This sample Ansible Playbook is not a full example,
# which would pass additional variables onto other
# Ansible Roles such as sap_storage_setup.
# It is only to test the provisioning process
# of a small Virtual Machine.

####
# Infrastructure Provisioning selection
####

sap_vm_provision_iac_type: "ansible" # ansible , ansible_to_terraform , existing_hosts
sap_vm_provision_iac_platform: "aws_ec2_vs" # aws_ec2_vs , gcp_ce_vm , ibmcloud_vs , ibmcloud_powervs , msazure_vm , ibmpowervm_vm , kubevirt_vm , ovirt_vm , vmware_vm

sap_vm_provision_host_specification_plan: "test_plan_16gb"
sap_vm_provision_dns_root_domain: "poc.cloud"


####
# Infrastructure Provisioning selection
# AWS
#
# Only for use when 'aws_ec2_vs' is value provided for variable sap_vm_provision_iac_platform
####

sap_vm_provision_aws_access_key: "ENTER_STRING_VALUE_HERE"
sap_vm_provision_aws_secret_access_key: "ENTER_STRING_VALUE_HERE"
sap_vm_provision_aws_region: "{{ sap_vm_provision_aws_vpc_availability_zone[:-1] }}"
sap_vm_provision_aws_vpc_availability_zone: "eu-west-2c"
sap_vm_provision_aws_vpc_subnet_create_boolean: "{{ true | default(false) if aws_vpc_subnet_id == 'new' else false }}"
sap_vm_provision_aws_vpc_subnet_id: "ENTER_STRING_VALUE_HERE" # if ansible_to_terraform, use "new"
sap_vm_provision_aws_ec2_vs_host_os_image: "ENTER_STRING_VALUE_HERE"
sap_vm_provision_bastion_user: "ENTER_STRING_VALUE_HERE"
sap_vm_provision_bastion_ssh_port: "ENTER_STRING_VALUE_HERE"

# Only for use when 'ansible' is value provided for variable sap_vm_provision_iac_type
####
sap_vm_provision_bastion_public_ip: "ENTER_STRING_VALUE_HERE"
sap_vm_provision_ssh_bastion_private_key_file_path: "./bastion_rsa"
sap_vm_provision_ssh_host_private_key_file_path: "./hosts_rsa"
sap_vm_provision_aws_key_pair_name_ssh_host_public_key: "ENTER_STRING_VALUE_HERE"
sap_vm_provision_aws_vpc_sg_names: "ENTER_STRING_VALUE_HERE"


####
# Infrastructure Definitions
# AWS
####

sap_vm_provision_aws_ec2_vs_host_os_image_dictionary:
rhel-8-6: "*RHEL-8.6*_HVM*x86_64*"
rhel-8-6-sap-ha: "*RHEL-SAP-8.6.0*"
sles-15-4: "*suse-sles-15-sp4-v202*-hvm-ssd-x86_64*"
sles-15-4-sap-ha: "*suse-sles-sap-15-sp4-v202*-hvm-ssd-x86_64*"

sap_vm_provision_aws_ec2_vs_host_specifications_dictionary:
test_plan_16gb:
test-ec2-vs: # Hostname, must be 13 characters or less
sap_host_type: hana_primary # hana_primary, hana_secondary, nwas_ascs, nwas_ers, nwas_pas, nwas_aas
virtual_machine_profile: r7i.large
disable_ip_anti_spoofing: true
storage_definition:
- name: hana_data
mountpoint: /hana/data
#disk_count: 1 # default: 1, if more then then LVM logical volume will be striped across the defined disks
disk_size: 384 # size in GB, integer
#disk_type: gp3 # default: gp3, for AWS EBS disk type
#disk_iops: # default: null, for AWS EBS with custom IOPS
filesystem_type: xfs # default: xfs
14 changes: 7 additions & 7 deletions roles/sap_vm_provision/tasks/common/set_ansible_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
sap_vm_provision_host_specification_plan: "{{ sap_vm_provision_host_specification_plan }}"
sap_vm_provision_nfs_mount_point: "{{ sap_vm_provision_nfs_mount_point | default('') }}"
sap_vm_provision_nfs_mount_point_separate_sap_transport_dir: "{{ sap_vm_provision_nfs_mount_point_separate_sap_transport_dir | default('') }}"
sap_id_user: "{{ sap_id_user }}"
sap_id_user_password: "{{ sap_id_user_password }}"
sap_software_download_directory: "{{ sap_software_download_directory }}"
sap_install_media_detect_source_directory: "{{ sap_software_download_directory }}"
sap_id_user: "{{ sap_id_user | default('') }}"
sap_id_user_password: "{{ sap_id_user_password | default('') }}"
sap_software_download_directory: "{{ sap_software_download_directory | default('/software') }}"
sap_install_media_detect_source_directory: "{{ sap_software_download_directory | default('/software') }}"

- name: Set facts for all hosts - use facts from localhost - Ansible only
ansible.builtin.set_fact:
Expand All @@ -21,9 +21,9 @@
ansible.builtin.set_fact:
sap_hana_sid: "{{ sap_hana_sid | default(sap_system_hana_db_sid) }}"
sap_hana_install_instance_nr: "{{ sap_hana_install_instance_nr | default(sap_system_hana_db_instance_nr) }}"
sap_hana_install_use_master_password: "y"
sap_hana_install_master_password: "{{ sap_hana_install_master_password }}"
sap_hana_install_software_directory: "{{ sap_software_download_directory }}"
sap_hana_install_use_master_password: "{{ sap_hana_install_use_master_password | default('y') }}"
sap_hana_install_master_password: "{{ sap_hana_install_master_password | default('') }}"
sap_hana_install_software_directory: "{{ sap_software_download_directory | default('/software') }}"
when:
- (sap_hana_sid is defined or sap_system_hana_db_sid is defined) or (hostvars[inventory_hostname].vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][inventory_hostname].sap_system_hana_db_sid is defined)

Expand Down

0 comments on commit 2e5e771

Please sign in to comment.