Skip to content

Commit

Permalink
Merge pull request #1 from SoftcatMS/linux
Browse files Browse the repository at this point in the history
Add linux attachment sub module
  • Loading branch information
niven01 authored Sep 5, 2023
2 parents 98f43cf + 3f097bd commit 1a5f852
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
23 changes: 3 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Module name using following format (<provider>-terraform-<description>, example: azure-terraform-vnet)
# terraform-azure-vm-initialize-disks

<Module description>
Initializes and mounts data disks attached to an Azure VM
Adds user `softcatadmin` with existing default password.

It supports creating:

- list resources created by module

<Describe any submodules>

## Usage Examples
You can go to the tests folder, or review the examples folder: [examples](./examples)
Expand Down Expand Up @@ -37,20 +33,7 @@ Azure
- [Terraform Provider for Azure](https://github.com/hashicorp/terraform-provider-azurerm)
- CLI Tool [az](https://docs.microsoft.com/en-us/cli/azure/)

AWS
- [Terraform Provider for AWS](https://github.com/hashicorp/terraform-provider-aws)
- CLI Tool [aws-cli](https://aws.amazon.com/cli/)

GCP
- [Terraform Provider for GCP](https://github.com/hashicorp/terraform-provider-google)
- [Terraform Provider for GCP Beta](https://github.com/terraform-providers/terraform-provider-google-beta)
- CLI Tool [gcloud](https://cloud.google.com/sdk/gcloud/)


<Any configuration needed on cloud plartform such as:>
- Service Principals
- IAM Roles
- Service Accounts


## Contributing
Expand Down
Empty file added modules/linux/main.tf
Empty file.
Empty file added modules/linux/outputs.tf
Empty file.
27 changes: 27 additions & 0 deletions modules/linux/scripts/linux_provision_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# Provision data disks
cd /dev/disk/azure/scsi1/ || exit

for LUN in *
do
NUM=$(echo "$LUN" | grep -o -E "[0-9]+")
if [ -d "/mnt/data$NUM" ]; then
echo "Disk Exists";
else
echo "y" | mkfs.ext4 /dev/disk/azure/scsi1/"$LUN";
mkdir /mnt/data"$NUM";
echo "/dev/disk/azure/scsi1/$LUN /mnt/data$NUM ext4 defaults,nofail 0 0" >>/etc/fstab;
fi
done

mount -a

# Add Softcatadmin user
if id -u "softcatadmin" >/dev/null 2>&1; then
echo "softcatadmin exists";
else
useradd -md /home/softcatadmin softcatadmin;
usermod -aG sudo softcatadmin;
echo softcatadmin:"${password}" | chpasswd;
fi
11 changes: 11 additions & 0 deletions modules/linux/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Linux

variable "vm_password" {
description = "Password to connect to VM"
type = string
}

variable "virtual_machine_id" {
description = "The virtual machine ID disks are attached to"
type = string
}

0 comments on commit 1a5f852

Please sign in to comment.