Comment 9 for bug 1939932

Revision history for this message
Lucas Albuquerque Medeiros de Moura (lamoura) wrote :

Azure bug verified with the following script:
-----------------------------------
import logging
import os

from pycloudlib.azure.cloud import Azure

api = Azure(
    tag="test-azure",
    client_id=os.getenv("UACLIENT_BEHAVE_AZ_CLIENT_ID"),
    client_secret=os.getenv("UACLIENT_BEHAVE_AZ_CLIENT_SECRET"),
    tenant_id=os.getenv("UACLIENT_BEHAVE_AZ_TENANT_ID"),
    subscription_id=os.getenv("UACLIENT_BEHAVE_AZ_SUBSCRIPTION_ID")
)

image_id = "Canonical:0001-com-ubuntu-pro-focal:pro-20_04-lts" # Focal pro image
key_name = "test-key"
private_key_path = "azure-priv-{}.pem".format(key_name)
pub_key_path = "azure-pub-{}.txt".format(key_name)

pub_key, priv_key = api.create_key_pair(
    key_name=key_name
)

with open(pub_key_path, "w") as stream:
    stream.write(pub_key)

with open(private_key_path, "w") as stream:
    stream.write(priv_key)

os.chmod(pub_key_path, 0o600)
os.chmod(private_key_path, 0o600)

api.use_key(pub_key_path, private_key_path, key_name)
instance = api.launch(image_id)

print("--- Creating base instance")
print(instance.execute("lsb_release -a"))
instance.execute("sh -c 'sudo apt-get update > /dev/null'")
instance.execute("sh -c 'sudo apt-get install ubuntu-advantage-tools > /dev/null'")
print(instance.execute("ua version"))
print(instance.execute("sudo ua enable fips --assume-yes"))
print("------------------")

print("--- Updating ua package")
cmd = "sudo sh -c \"echo 'deb http://archive.ubuntu.com/ubuntu/ {}-proposed restricted main multiverse universe' >> /etc/apt/sources.list.d/proposed-repositories.list\""
instance.execute(cmd.format("focal"))
instance.execute("sh -c 'sudo apt-get update > /dev/null'")
instance.execute("sh -c 'sudo apt-get install ubuntu-advantage-tools > /dev/null'")
print(instance.execute("ua version"))
print(instance.execute("sudo ua enable fips --assume-yes"))
print("------------------")
instance.delete()
-------------------------------------

Test output:

--- Creating base instance
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
27.2.2~20.04.1
One moment, checking your subscription first
Updating package lists
Installing FIPS packages
Updating package lists
Could not enable FIPS.
------------------
--- Updating ua package
27.3~20.04.1
One moment, checking your subscription first
Ubuntu Focal does not provide an Azure optimized FIPS kernel
For help see: https://ubuntu.com/advantage.
------------------