Your submission was sent successfully! Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

How to install and configure Landscape Server in a single LXD container

Contents:

  1. Install and configure cloud-init
  2. Install and configure LXD
  3. Configure network settings
  4. Install and configure Landscape Quickstart

You can also use this guide to test Landscape inside a single LXD container.

Install and configure cloud-init

Download the cloud-init configuration file

To download the cloud-init configuration file and save it as cloud-init.yaml, run:

curl -o cloud-init.yaml https://raw.githubusercontent.com/canonical/landscape-scripts/main/provisioning/cloud-init-quickstart.yaml

Set cloud-init variables

To set the variables needed by the cloud-init configuration file, run:

declare -A VARIABLES=(
  [EMAIL]='{EMAIL_ADDRESS}'
  [TOKEN]='{PRO_TOKEN}'
  [HOSTNAME]='{HOST_NAME}'
  [DOMAIN]='{DOMAIN}'
  [TIMEZONE]='{TIME_ZONE}'
  [SMTP_HOST]='{SMTP_HOST}'
  [SMTP_PORT]='{SMTP_PORT}'
  [SMTP_USERNAME]='{SMTP_USERNAME}'
  [SMTP_PASSWORD]='{SMTP_PASSWORD}'
  [LANDSCAPE_VERSION]='{LANDSCAPE_VERSION}'
)

This code block includes the following values that must be changed:

{EMAIL_ADDRESS}: The email address that you’ll share with LetsEncrypt for your SSL certificate.

{PRO_TOKEN}: Your Ubuntu Pro token from https://myasnchisdf.eu.org/pro/dashboard. If you’re running an Ubuntu Pro instance on Azure, AWS, or Google Cloud, leave this as an empty string.

{HOST_NAME}: The hostname from your FQDN. For example, server from server.domain.com.

{DOMAIN}: The top-level domain (TLD) for your FQDN. For example, domain.com from server.domain.com.

{TIME_ZONE}: Your timezone as represented in /usr/share/zoneinfo. If you leave this as an empty string, UTC time will be used.

{SMTP_HOST}: The hostname or IP address of the SMTP server provided by your email service provider. If you’re using SendGrid, enter smtp.sendgrid.net.

{SMTP_PORT}: The port number on which the SMTP server is listening for incoming connections. If you’re using SendGrid, enter 587 for port 587.

{SMTP_USERNAME}: The username required to authenticate with the SMTP server. This is provided by your email service provider. If you’re using SendGrid, enter apikey.

{SMTP_PASSWORD}: The password or API key associated with the SMTP username. If you’re using SendGrid, use an API Key from https://app.sendgrid.com/settings/api_keys

{LANDSCAPE_VERSION}: The version of Landscape you will install. Enter beta or 24.04 (stable LTS).

Populate the cloud-init configuration file with your variables

To populate cloud-init.yaml with your variables, run:

for VALUE in "${!VARIABLES[@]}"; do sed -i "s|{% set $VALUE = '.*' %}|{% set $VALUE = '${VARIABLES[$VALUE]}' %}|" cloud-init.yaml; done

Install and configure LXD

Install or update LXD

To install or update the LXD snap, run:

snap list lxd &> /dev/null && sudo snap refresh lxd --channel latest/stable || sudo snap install lxd --channel latest/stable

This command checks if the LXD snap is installed. If it’s already installed, this command updates it to the latest version. If it’s not installed, this command installs the latest version.

Configure LXD

To configure LXD with predefined settings without requiring user input, run:

lxd init --auto

Configure network settings

Identify the default network adapter and check MTU configuration

To identify the default network adapter on the machine and check the MTU configuration on this adapter, run:

read -r INTERFACE < <(ip route | awk '$1=="default"{print $5; exit}')

Adjust LXD network MTU settings

If your network uses jumbo frames (e.g., MTU 9000) or an MTU smaller than 1500, you’ll need to use a matching MTU on lxdbr0. Note that Google Cloud VMs use MTUs smaller than 1500.

To change the LXD bridge MTU to match the network’s configuration, run:

lxc network set lxdbr0 bridge.mtu=$(ip link show $INTERFACE | awk '/mtu/ {print $5}')

Install and configure Landscape Quickstart

It’s recommended to install Landscape on the latest Ubuntu LTS, but you can also use 20.04 if you require that version.

You can configure ports 6554, 443 and 80 to allow for connections to the Landscape instance inside the LXD container.

Step 1: Install Landscape Quickstart inside a LXD container using cloud-init.yaml, run:

lxc launch ubuntu:24.04 landscape --config=user.user-data="$(cat cloud-init.yaml)" 

Step 2: Capture the IP address of the “landscape” LXD container:

LANDSCAPE_IP=$(lxc list landscape --format csv -c 4 | awk '{print $1}')

Step 3: Configure port forwarding for Port 6554, 443, and 80:

for PORT in 6554 443 80; do lxc config device add landscape tcp${PORT}proxyv4 proxy listen=tcp:0.0.0.0:${PORT} connect=tcp:${LANDSCAPE_IP}:${PORT}; done

Allowing TCP traffic on these ports in the host machine’s firewall settings and the network router configuration or enterprise firewall configuration enables the Landscape Quickstart instance to be accessible to the public Internet. This allows certbot to obtain a valid SSL certificate if a DNS record exists with the FQDN pointing to your host machine’s public IP address.

Step 4: To observe the progress, run:

lxc exec landscape -- bash -c "tail -f /var/log/cloud-init-output.log"

When the cloud-init process is complete, you’ll receive two lines similar to this:

cloud-init v. 23.2.2-0ubuntu0~20.04.1 running 'modules:final' at Sun, 20 Aug 2023 17:30:43 +0000. 
Up 25.14 seconds.
cloud-init v. 23.2.2-0ubuntu0~20.04.1 finished at Sun, 20 Aug 2023 17:30:56 +0000. Datasource 
DataSourceGCELocal.  Up 37.35 seconds

Step 5: Press CTRL + C to terminate the tail process in your terminal window.

This page was last modified 5 months ago. Help improve this document in the forum.