# Introduction The code is intended as an example for deployment of a single instance virtual machine with Oracle Database Enterprise Edition 19c. The code is intended to be used as a starting point for your own deployment. The module for this deployment is located in the `terraform/bootstrap/single_instance` directory. ![Single VM](media/single_vm.png) ## Preparations - To use Terraform commands against your Azure subscription, you must first authenticate Terraform to that subscription. [This doc](https://learn.microsoft.com/en-us/azure/developer/terraform/authenticate-to-azure?tabs=bash) describes how to authenticate Terraform to your Azure subscription. ### SSH Key Before using this module, you have to create your own ssh key to deploy and connect the virtual machine you will create. To do this follow these steps on your compute source: ```bash ssh-keygen -f ~/.ssh/lza-oracle-single-instance ``` Verify that the key has been created: ```bash ls -lha ~/.ssh/ ``` The above command should result in output similar to the following: ```bash -rw------- 1 yourname staff 2.6K 8 17 2023 lza-oracle-single-instance -rw-r--r-- 1 yourname staff 589B 8 17 2023 lza-oracle-single-instance.pub ``` Run the following commands to include the public key in the fixtures.tfvars file where it will be used when deploying the virtual machine: ```bash pubkey="$HOME/.ssh/lza-oracle-single-instance.pub" key_content=$(awk -F= '{print $1 FS}' "$pubkey") fixtures="ssh_key = \"$key_content\"" echo $fixtures > terraform/bootstrap/single_instance/fixtures.tfvars ``` The fixtures.tfvars file should now contain the public key, see below for an example: ![fixtures](media/fixtures.jpg) ### Oracle binaries download To allow for Oracle software binaries download you will need to update information on the following parameters as well: - Resource Id of the user assigned managed identity you have created as described [here](./Introduction-to-deploying-oracle.md), should be gathered and added to the `/terraform/bootstrap/single_instance/fixtures.tfvars` file. To get the resource id , run the following command, replacing the values for $umi and $rg with the name of the user managed identity and the resource group it is in respectively: ```bash umi="" rg="" mi_id=$(az identity show --name $umi --resource-group $rg --query id --output tsv) miid_mod=$(echo "$mi_id" | sed 's/resourcegroups/resourceGroups/g') fixtures="vm_user_assigned_identity_id = \"$miid_mod\"" echo $fixtures >> terraform/bootstrap/single_instance/fixtures.tfvars ``` To further ensure that the Ansible workflow will run successfully, open the file ansible/bootstrap/oracle/group_vars/all/vars.yml and update the following parameters: - The value for storage_account should be updated with the name of the storage account where the Oracle binaries are stored. - The value for storage_container should be updated with the name of the container on the storage account where the Oracle binaries are stored. There are a number of optional settings which the module enables. Overall if you wish to modify one or more variables in the module, you can do so by modifying the `terraform/bootstrap/single_instance/variables_global.tf` or the `terraform/bootstrap/single_instance/variables_local.tf` file. Be mindful that the Oracle installation through Ansible does require a disk setup similar to the one specified, i.e. three disks, so changes to this may cause the Ansible playbook to fail. ### Deploy the virtual machine Perform the following steps to deploy the virtual machine: - Verify that you are in the `terraform/bootstrap/single_instance` directory. - Run the following commands to initialize Terraform state and deploy the virtual machine: > To avoid registering unnecessary providers, you have to export the environment variable `ARM_SKIP_PROVIDER_REGISTRATION` as `true`. ```bash export ARM_SKIP_PROVIDER_REGISTRATION=true terraform init terraform plan -var-file=fixtures.tfvars terraform apply -var-file=fixtures.tfvars ``` ### Connect to the virtual machine Finally, you can connect to the virtual machine with ssh private key. While deploying resources, a public ip address is generated and attached to the virtual machine, so that you can connect to the virtual machine with this IP address. The username is `oracle`, which is hardcoded in `terraform/bootstrap/single_instance/module.tf`. As the deployment enables Just-in-Time VM access, you will need to request access to the VM before you can connect to it as described [here](https://learn.microsoft.com/en-us/azure/defender-for-cloud/just-in-time-access-usage#enable-jit-on-your-vms-from-microsoft-defender-for-cloud). Once the VM is accessible, you can connect to it with the following command: ```bash ssh -i ~/.ssh/lza-oracle-single-instance oracle@ ``` Next step is to proceed with Ansible configuration to get the Oracle database operational. See the [Ansible single instance documentation](ANSIBLE-SI.md) for more details. ## Optional Settings There are a number of optional settings which the module enables. Overall if you wish to modify one or more variables in the module, you can do so by modifying the `terraform/bootstrap/single_instance/variables_global.tf` or the `terraform/bootstrap/single_instance/variables_local.tf` file.