Skip to content

Commit

Permalink
Install Azure CLI
Browse files Browse the repository at this point in the history
- Installed the Azure CLI for later usage in provisioning
- Formatted the README
- Bumped the changelog to 1.1.0
  • Loading branch information
mihailradkov committed Nov 6, 2023
1 parent 9074b04 commit 6fc7a6b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

All notable changes to the Packer template for creating GraphDB Azure VM images will be documented in this file.

## [1.0.0]
## 1.1.0

- Installed Azure CLI

## 1.0.0

- Initial release of the Packer template.
- Added configuration to create GraphDB VM image on Azure.
Expand Down
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Packer Configuration for Creating GraphDB Azure VM
This guide explains how to use Packer to create Azure VM Image for GraphDB.
# Packer Configuration for Creating GraphDB Azure VM

This guide explains how to use Packer to create Azure VM Image for GraphDB.
The Packer configuration in this repository automates the process of installing and configuring GraphDB on an Ubuntu-based VM instance.

## Prerequisites

Before you begin, make sure you have the following prerequisites in place:

1. **Packer**: Ensure that you have Packer installed on your local machine.
Expand All @@ -11,9 +13,10 @@ Before you begin, make sure you have the following prerequisites in place:
3. **Azure Resource group**: You should create a Resource group.
4. **Azure compute gallery**: You should create an Azure compute gallery
5. **VM image definition**: You should create an Azure Image definition in the Azure compute gallery.
6. **AAD Service Principal**: You should create an Azure Active Directory Service Principal.
6. **AAD Service Principal**: You should create an Azure Active Directory Service Principal.

## Usage

Follow these steps to build an AMI for GraphDB using Packer:

1. **Clone the Repository**:
Expand All @@ -27,12 +30,12 @@ Follow these steps to build an AMI for GraphDB using Packer:

3. **Edit Variables**:

The Packer configuration allows you to customize various parameters, such as the GraphDB version, Azure build and
The Packer configuration allows you to customize various parameters, such as the GraphDB version, Azure build and
replication regions, subscription, client and tennat IDs. To do so, create a variables file `variables.pkrvars.hcl`,
example file:
example file:
```bash
subscription_id = "<your_azure_subscription_id>"
client_id = "<your_azure_service_principal_id>"\
client_id = "<your_azure_service_principal_id>"
client_secret = "<your_azure_service_principal_secret>"
tenant_id = "<your_azure_tenant_id>"
primary_location = "East US"
Expand All @@ -50,11 +53,11 @@ Follow these steps to build an AMI for GraphDB using Packer:
```bash
packer build -var-file="variables.pkrvars.hcl" .
```
This command will initiate the Packer build process. Packer will launch an VM instance, install GraphDB,
This command will initiate the Packer build process. Packer will launch an VM instance, install GraphDB,
and create an image based on the instance.

Please note that the image definition you specify in `image_definition_name` must exist in the SIG.
To automate this process you can use the `create_image_definition.sh` script, which will read the variables in
Please note that the image definition you specify in `image_definition_name` must exist in the SIG.
To automate this process you can use the `create_image_definition.sh` script, which will read the variables in
`variables.pkrvars.hcl` and create the image definition in the gallery.
This script utilizes the Azure CLI, so you need to install and configure it beforehand.
The image definition will be built with the following settings:
Expand All @@ -75,48 +78,56 @@ Follow these steps to build an AMI for GraphDB using Packer:
```

## Customization
You can customize the Packer configuration and provisioning scripts to suit your specific requirements.

You can customize the Packer configuration and provisioning scripts to suit your specific requirements.

The following points can be customized in a packer variables file `variables.pkrvars.hcl`:

**Subscription Configuration**

* subscription_id (string): Your Azure subscription ID.
* tenant_id (string): Your Azure Active Directory tenant ID.
* client_id (string): The client ID (Service Principal ID) used for authentication.
* client_secret (string): The client secret (Service Principal Secret) used for authentication.
* primary_location (string): The primary Azure location you want to use.

**Image Configuration**

* image_definition_name (string): The name of the x86_64 image to use.
* gdb_version (string): The version of GraphDB to install.
* replication_regions (list(string)): A list of Azure regions for replication of the created image.

**Gallery Configuration**

* gallery_resource_group (string): The resource group where the image gallery is located.
* gallery_name (string): The name of the image gallery.
* image_replica_count (number): The number of replicas of the Image Version to be created per region. (default is 1).

**Networking Configuration**

* my_ip_address (string): Your IP address for network security settings.

**OS and Image Defaults**

* os_type (string): The operating system type (default is "Linux").
* image_offer (string): The offer for the base image (default is "0001-com-ubuntu-server-jammy").
* image_publisher (string): The publisher for the base image (default is "canonical").
* image_sku (string): The SKU for the base image (default is "22_04-lts-gen2").
* vm_size (string): The Azure VM size (default is "Standard_B1ls").
* shared_gallery_image_version_exclude_from_latest (bool): If set to true, Virtual Machines deployed from the latest
* shared_gallery_image_version_exclude_from_latest (bool): If set to true, Virtual Machines deployed from the latest
version of the Image Definition won't use this Image Version (default is false)
* os_disk_size_gb (number): size of the OS disk in GB (default is 30). Depends on base VM image limitation,
* os_disk_size_gb (number): size of the OS disk in GB (default is 30). Depends on base VM image limitation,
e.g., Ubuntu Server image has `os_disk_size_gb = 30`.
**Provisioning Scripts**: You can replace or modify the provisioning scripts located in the `./files/` directory.
These scripts and files are copied and executed during the AMI creation process.
## Limitations
Timestamp is used for `image_version`, therefore if you want to build more than a single image per day, you should either
delete the previously created image version or change the `image_version` property in `shared_image_gallery_destination`
to something else.
delete the previously created image version or change the `image_version` property in `shared_image_gallery_destination`
to something else.
## Support
For questions or issues related to this Packer configuration, please [submit an issue](https://github.com/Ontotext-AD/packer-aws-graphdb/issues).
6 changes: 3 additions & 3 deletions files/install_graphdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ done

timedatectl set-timezone UTC

# Shred authorized_keys
shred -u /root/.ssh/authorized_keys /home/ubuntu/.ssh/authorized_keys || true

# Install Tools
apt-get -o DPkg::Lock::Timeout=300 update -y
apt-get -o DPkg::Lock::Timeout=300 install -y bash-completion jq nvme-cli openjdk-11-jdk unzip

# Install Azure CLI
curl -sL https://aka.ms/InstallAzureCLIDeb | bash

# Create the GraphDB user
useradd --comment "GraphDB Service User" --create-home --system --shell /bin/bash --user-group graphdb

Expand Down

0 comments on commit 6fc7a6b

Please sign in to comment.