Skip to content

Commit 1a5f852

Browse files
authored
Merge pull request #1 from SoftcatMS/linux
Add linux attachment sub module
2 parents 98f43cf + 3f097bd commit 1a5f852

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
# Module name using following format (<provider>-terraform-<description>, example: azure-terraform-vnet)
1+
# terraform-azure-vm-initialize-disks
22

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

5-
It supports creating:
6-
7-
- list resources created by module
8-
9-
<Describe any submodules>
106

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

40-
AWS
41-
- [Terraform Provider for AWS](https://github.com/hashicorp/terraform-provider-aws)
42-
- CLI Tool [aws-cli](https://aws.amazon.com/cli/)
43-
44-
GCP
45-
- [Terraform Provider for GCP](https://github.com/hashicorp/terraform-provider-google)
46-
- [Terraform Provider for GCP Beta](https://github.com/terraform-providers/terraform-provider-google-beta)
47-
- CLI Tool [gcloud](https://cloud.google.com/sdk/gcloud/)
48-
4936

50-
<Any configuration needed on cloud plartform such as:>
51-
- Service Principals
52-
- IAM Roles
53-
- Service Accounts
5437

5538

5639
## Contributing

modules/linux/main.tf

Whitespace-only changes.

modules/linux/outputs.tf

Whitespace-only changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
# Provision data disks
4+
cd /dev/disk/azure/scsi1/ || exit
5+
6+
for LUN in *
7+
do
8+
NUM=$(echo "$LUN" | grep -o -E "[0-9]+")
9+
if [ -d "/mnt/data$NUM" ]; then
10+
echo "Disk Exists";
11+
else
12+
echo "y" | mkfs.ext4 /dev/disk/azure/scsi1/"$LUN";
13+
mkdir /mnt/data"$NUM";
14+
echo "/dev/disk/azure/scsi1/$LUN /mnt/data$NUM ext4 defaults,nofail 0 0" >>/etc/fstab;
15+
fi
16+
done
17+
18+
mount -a
19+
20+
# Add Softcatadmin user
21+
if id -u "softcatadmin" >/dev/null 2>&1; then
22+
echo "softcatadmin exists";
23+
else
24+
useradd -md /home/softcatadmin softcatadmin;
25+
usermod -aG sudo softcatadmin;
26+
echo softcatadmin:"${password}" | chpasswd;
27+
fi

modules/linux/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Linux
2+
3+
variable "vm_password" {
4+
description = "Password to connect to VM"
5+
type = string
6+
}
7+
8+
variable "virtual_machine_id" {
9+
description = "The virtual machine ID disks are attached to"
10+
type = string
11+
}

0 commit comments

Comments
 (0)