Skip to content

Commit ff3e674

Browse files
committed
Initial issue #12 commit
1 parent 11cbf3f commit ff3e674

File tree

1 file changed

+228
-0
lines changed

1 file changed

+228
-0
lines changed
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# How to install Landscape Server on Microsoft Azure
2+
3+
This guide provides an example of how to install and set up your Landscape server on Microsoft Azure with [cloud-init](https://cloudinit.readthedocs.io/en/latest/). The instructions here can be used for both FIPS-hardened or non-hardened systems.
4+
5+
> **For the most up-to-date documentation on Microsoft Azure, see [Microsoft Azure documentation](https://learn.microsoft.com/en-us/azure).
6+
7+
**Contents:**
8+
9+
- Install and set up Microsoft Azure CLI
10+
- Provision Azure resources and deploy
11+
- Deploy Landscape Server VM with cloud-init
12+
- Configure Landscape
13+
- (Optional) Perform a complete teardown
14+
15+
16+
## Install and set up Microsoft Azure CLI
17+
18+
### Install `Azure CLI`
19+
20+
Get packages needed for the installation process:
21+
```
22+
sudo apt update
23+
sudo apt install ca-certificates curl apt-transport-https lsb-release gnupg
24+
```
25+
26+
Download and install the Microsoft signing key:
27+
```
28+
sudo mkdir -p /etc/apt/keyrings
29+
curl -sLS https://packages.microsoft.com/keys/microsoft.asc |
30+
gpg --dearmor |
31+
sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null
32+
sudo chmod go+r /etc/apt/keyrings/microsoft.gpg
33+
```
34+
35+
Add the Azure CLI software repository:
36+
```
37+
AZ_DIST=$(lsb_release -cs)
38+
echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $AZ_DIST main" |
39+
sudo tee /etc/apt/sources.list.d/azure-cli.list
40+
```
41+
42+
Update repository information and install the `azure-cli` package:
43+
```
44+
sudo apt update
45+
sudo apt install azure-cli
46+
```
47+
48+
### Connect `Azure` with your Microsoft Azure account
49+
50+
The Azure CLI's default authentication method for logins uses a web browser and access token to sign in.
51+
52+
Run the `az login` command:
53+
```
54+
az login
55+
```
56+
57+
If the Azure CLI can open your default browser, it initiates authorisation code flow and opens the default browser to load an Azure sign-in page.
58+
59+
Sign in with your account credentials in the browser.
60+
61+
62+
## Provision Azure resources and deploy
63+
64+
### Create a resource group
65+
66+
Create a resource group to contain all the Azure resources for deploying the VM. The following command creates a resource group named `Landscape-rg` in the `eastus` location:
67+
```
68+
az group create --name Landscape-rg --location eastus
69+
```
70+
71+
Output will be displayed in JSON format:
72+
```
73+
{
74+
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Landscape-rg",
75+
"location": "eastus",
76+
"managedBy": null,
77+
"name": "Landscape-rg",
78+
"properties": {
79+
"provisioningState": "Succeeded"
80+
},
81+
"tags": null,
82+
"type": "Microsoft.Resources/resourceGroups"
83+
}
84+
```
85+
86+
### Create public-ip address resource
87+
88+
Create static IP address in the `Landscape-rg` resource group:
89+
```
90+
az network public-ip create \
91+
--resource-group Landscape-rg \
92+
--name LandscapePublicIP \
93+
--location eastus \
94+
--allocation-method Static
95+
```
96+
97+
Output will be displayed in JSON format and will show static IP address (extract below):
98+
```
99+
"ipAddress": "34.139.255.120",
100+
"ipTags": [],
101+
"location": "eastus",
102+
"name": "LandscapePublicIP",
103+
"provisioningState": "Succeeded",
104+
"publicIPAddressVersion": "IPv4",
105+
"publicIPAllocationMethod": "Static",
106+
"resourceGroup": "Landscape-rg",
107+
```
108+
109+
Copy the IP address and set it as the A record value for the domain or subdomain that will serve as the FQDN. You set the A record in your DNS service. You can also use Azure DNS zone to host your DNS domain and manage your DNS records.
110+
111+
Verify the A record using `nslookup`. Replace `{landscape.domain.com}` with your FQDN:
112+
113+
```
114+
nslookup {landscape.domain.com}
115+
```
116+
117+
You’ll receive output similar to:
118+
```
119+
Server: 127.0.0.53
120+
Address: 127.0.0.53#53
121+
122+
Non-authoritative answer:
123+
Name: landscape.domain.com
124+
Address: 34.139.255.120
125+
```
126+
127+
If the address value in the `nslookup` output matches the value of the `LandscapePublicIP` static IP address, the LetsEncrypt SSL provisioning step defined in the cloud-init configuration automation template will succeed.
128+
129+
130+
## Deploy Landscape Server VM with cloud-init
131+
132+
Before beginning the deployment process with cloud-init, you must choose which of the two cloud-init configuration automation templates you want to use. In the [Landscape Scripts](https://github.com/canonical/landscape-scripts) Github repository, there are two Landscape Quickstart cloud-init configuration templates: [`cloud-init-quickstart.yaml`](https://github.com/canonical/landscape-scripts/blob/main/provisioning/cloud-init-quickstart.yaml) and [`cloud-init-quickstart-fips.yaml`](https://github.com/canonical/landscape-scripts/blob/main/provisioning/cloud-init-quickstart-fips.yaml).
133+
134+
The `cloud-init-quickstart.yaml` template is designed for anyone, and the `cloud-init-quickstart-fips.yaml` is designed for FIPS compliant deployments of Landscape Server. For more information, see [how to install FIPS hardened Landscape Server](https://ubuntu.com/landscape/docs/install-fips-hardened-landscape-server).
135+
136+
Once you’ve chosen your configuration template, complete the following steps.
137+
138+
1. Set the `IMAGE_FAMILY` environment variable based on the cloud-init configuration you chose.
139+
140+
- If you’re using `cloud-init-quickstart.yaml`, run:
141+
```
142+
curl -s https://raw.githubusercontent.com/canonical/landscape-scripts/main/provisioning/cloud-init-quickstart.yaml -o cloud-init.yaml
143+
IMAGE_FAMILY=Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest
144+
```
145+
146+
- If you’re using `cloud-init-quickstart-fips.yaml`, run:
147+
```
148+
curl -s https://raw.githubusercontent.com/canonical/landscape-scripts/main/provisioning/cloud-init-quickstart-fips.yaml -o cloud-init.yaml
149+
IMAGE_FAMILY=Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:latest
150+
```
151+
152+
2. Open the downloaded cloud-init YAML file in an editor, determine which configuration parameters need to be changed between lines 4 and 32 and change these parameters.
153+
154+
The `HOSTNAME` on line 16 and `DOMAIN` on line 19 must be changed. Updating `EMAIL` on line 9, and adding your SendGrid API key on line 29 as the `SMTP_PASSWORD` are optional, but strongly recommended.
155+
156+
157+
### Create VM
158+
159+
Run the following commands to create a VM and add a security rule to the network security group (NSG) to open port 80 and 443. These ports are required to be open to allow the LetsEncrypt SSL provisioning step defined in the cloud-init to succeed. The `--generate-ssh-keys` parameter causes the CLI to look for an available ssh key in `~/.ssh`. If one is found, that key is used. If not, one is generated and stored in `~/.ssh`. The `--custom-data` parameter to pass in the cloud-init config file. Provide the full path to the `cloud-init.yaml` config if you saved the file outside of your present working directory:
160+
```
161+
az vm create \
162+
--resource-group Landscape-rg \
163+
--name LandscapeVM \
164+
--image $IMAGE_FAMILY \
165+
--size Standard_D2s_v3 \
166+
--admin-username azureuser \
167+
--assign-identity \
168+
--generate-ssh-keys \
169+
--public-ip-address LandscapePublicIP \
170+
--custom-data cloud-init.yaml
171+
az vm open-port \
172+
--resource-group Landscape-rg \
173+
--name LandscapeVM \
174+
--port 80,443 \
175+
--priority 100
176+
```
177+
178+
It takes a few minutes to create the VM and supporting resources.
179+
180+
Observe the process by tailing the `cloud-init-output.log` file. Replace `{landscape.domain.com}` with your FQDN or static IP address:
181+
```
182+
ssh azureuser@{landscape.domain.com} 'tail -f /var/log/cloud-init-output.log'
183+
```
184+
185+
A reboot may be required during the cloud-init process. If a reboot is required, you’ll receive the following output:
186+
```
187+
2023-08-20 17:30:04,721 - cc_package_update_upgrade_install.py[WARNING]: Rebooting after upgrade or install per /var/run/reboot-required
188+
```
189+
190+
If the `IMAGE_FAMILY` specified earlier contained all the security patches, this reboot step may not occur.
191+
192+
Repeat the following code if a reboot was necessary to continue observing the log file:
193+
```
194+
ssh azureuser@{landscape.domain.com} 'tail -f /var/log/cloud-init-output.log'
195+
```
196+
197+
Wait until the cloud-init process is complete. When it’s complete, you’ll receive the following line similar to this:
198+
```
199+
cloud-init v. 23.2.2-0ubuntu0~22.04.1 finished at Sun, 20 Aug 2023 17:30:56 +0000. Datasource DataSourceAzure [seed=/dev/sr0]. Up 37.35 seconds
200+
```
201+
202+
Press `CTRL + C` to terminate the tail process in your terminal window.
203+
204+
205+
## Configure Landscape
206+
207+
1. Navigate to the Landscape dashboard by entering the FQDN of the Landscape VM into a browser window
208+
209+
2. Provide a name, email address, and password for the first global administrator on the machine.
210+
211+
If the email address Landscape sends emails from should not be a subdomain based on the machine’s hostname, remove the hostname, or make the appropriate correction.
212+
213+
Alerts and administrator invitations sent via email are less likely to fail SPF or DMARC checks if the system email address is configured in a way the email service provider expects. If the email service provider sends emails which fail SPF and DMARC checks, mail delivery can be delayed or miscategorized as spam.
214+
215+
216+
## (Optional) Perform a complete teardown
217+
218+
When no longer needed, you can delete the resource group to remove all the related resources used to create the Landscape Server VM.
219+
220+
To check the resources in the `Landscape-rg` resource group, run:
221+
```
222+
az resource list --resource-group Landscape-rg --output table
223+
```
224+
225+
To delete the resource group, run:
226+
```
227+
az group delete --name Landscape-rg
228+
```

0 commit comments

Comments
 (0)