https://github.com/alan-turing-institute/azure-sensible
A sensible starting point for deploying and configuring virtual machines on Azure
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 4 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.3%) to scientific vocabulary
Keywords
Repository
A sensible starting point for deploying and configuring virtual machines on Azure
Basic Info
Statistics
- Stars: 4
- Watchers: 5
- Forks: 1
- Open Issues: 4
- Releases: 0
Topics
Metadata Files
README.md
Azure Sensible
This repository provides a set of example, template Terraform and Ansible files for deploying and configuring Azure virtual machines.
Why might you want to use this
Through using and building upon these examples you will find that your deployment is
- 🚅 Fast (no forms or pointing and clicking in your browser required)
- 🔁 Reproducible (as long as you keep your configuration files you can tear down and redeploy your environment on demand)
- 🔐 Secure (public key authentication by default with optional two-factor authentication)
- 💻 Hackable (we aim to provide a good starting point for building the environment you need)
- 🤝 Permissively licensed (you are free to copy, use and modify this code as well as to merge it with your own)
What this is not
While we hope this repository will be useful it will not (and is not intended to) solve all cloud computing problems. In particular this template is not intended to expose all of the possibilities of Ansible and Terraform.
For more complicated architectures, such as those involving multiple hosts, it may be best to build your deployment from the ground up. Nevertheless, we hope that you can still find some inspiration and useful hints here.
How to use this repository
The repository is split into two directories terraform and ansible which contain the Terraform and Ansible files respectively. Terraform is used to deploy the Azure resources (virtual machines, disks, public IP address, etc.) and Ansible is used to configure the virtual machine.
🎁 Get the code
Download and unzip the latest release or clone this repository
$ git clone https://github.com/alan-turing-institute/azure-sensible.git
📦 Requirements
Before you start, you will need to install some dependencies,
Additionally for generating QR code images to be scanned with an authenticator app you will need,
- Python > 3.6
- qrencode (which you will likely be able to find on you distributions repositories or on brew)
🏞️ Terraform, provisioning your virtual machine
To use terraform to deploy infrastructure on Azure, you will first need to authenticate using the Azure CLI
$ az login
which will launch a browser prompting you to login.
Then you will need to enable the subscription you want to deploy the VM into. Terraform will use your enabled-by-default subscription.
$ az account set --subscription <Subscription Name or ID>
To see a list of subscriptions available to you, run: az account list --output table
Next you can configure your deployment by editing
terraform/terraform.tfvars. This file has
comments explaining the configuration options and their default values.
Initialise terraform
$ cd terraform
$ terraform init
Plan your changes
$ terraform plan
this will print a list of changes to your terminal so you can see what terraform will do. Run the terraform plan with
$ terraform apply
⚠️ Warning
The Terraform plan generates an SSH key for the Ansible admin account. The private key is stored unencrypted in the Terraform state file. This is not a secure if you intend on sharing the terraform state and should be replaced if you intend on doing so.
⚙️ Ansible, configuring your virtual machine
Ansible uses an inventory file to declare managed nodes and arrange them into
groups. The terraform plan will have created an inventory for you specifying
your virtual machine and how to connect to it in the ansible directory.
Similarly to terraform, there is a variables file with some options regarding
how Ansible will configure your virtual machine. Edit
ansible/ansible_vars.yaml, as before there are
comments to explain the options.
You can use scripts/generate_password.py to
create compatible password hashes for your users without displaying the password
as plain text. See the README
for instructions.
Install the required ansible modules from Ansible Galaxy
$ cd ../ansible
$ ansible-galaxy install -r requirements.yaml
Now run the playbook on the inventory generated by Terraform to configure your virtual machine
$ ansible-playbook -i inventory.yaml playbook.yaml
📱 Optional: generating QR code images
If the option totp was true in ansible_vars.yaml the Ansible play will
have created a file in the ansible directory called totp_hashes.txt. This file
contains the information needed to generate QR code images for each user.
To generate the QR code images run the included Python script
$ ./scripts/generate_qr_codes.py
There will now be a set of PNG files in your current directory, one for each
user, with file names in the format <username>.png. These can be distributed
to each user so that they may scan the QR code with their authenticator app.
🔗 Connect to your virtual machine
Both the Terraform plan and the Ansible playbook will finish by printing the public IPv4 address of your virtual machine. You can connect to the machine via SSH using this IP address and the credentials of a user your created
$ ssh <username>@<ip_address> -i <path_to_private_keyfile>
💣 Destroy the resources
When you are finished, you can destroy the resources using Terraform. From the terraform directory run
$ terraform destroy
This will delete all Azure resources and any data stored on these resources will be lost.
Next steps
See the examples directory README for some practical examples building on the base configuration files.
Owner
- Name: The Alan Turing Institute
- Login: alan-turing-institute
- Kind: organization
- Email: info@turing.ac.uk
- Website: https://turing.ac.uk
- Repositories: 477
- Profile: https://github.com/alan-turing-institute
The UK's national institute for data science and artificial intelligence.
GitHub Events
Total
Last Year
Committers
Last synced: about 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jim Madge | j****e@g****m | 144 |
| Sarah Gibson | s****n@t****k | 3 |
| Jim Madge | j****e@t****k | 2 |
| Sarah Gibson | 4****1 | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 10
- Total pull requests: 40
- Average time to close issues: 2 days
- Average time to close pull requests: about 6 hours
- Total issue authors: 3
- Total pull request authors: 2
- Average comments per issue: 2.6
- Average comments per pull request: 0.08
- Merged pull requests: 39
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- JimMadge (7)
- sgibson91 (2)
- edaub (1)
Pull Request Authors
- JimMadge (37)
- sgibson91 (3)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- passlib *