Building the Apache and MySQL images using Packer and Ansible provisioners
We will now use Packer to create the Apache and MySQL images. Before defining the Packer configuration, we have a few prerequisites to allow Packer to build custom images.
Prerequisites
We must create an Azure service principal for Packer to interact with Azure and build the image.
First, log in to your Azure account using the Azure CLI with the following command:
$ az login
Now, set the subscription to the subscription ID we got in response to the az login
command to an environment variable using the following:
$ export SUBSCRIPTION_ID=<SUBSCRIPTION_ID>
Next, let’s set the subscription ID using the following command:
$ az account set --subscription="${SUBSCRIPTION_ID}"
Then, create the service principal with contributor access using the following command:
$ az ad sp create-for-rbac --role="Contributor" \ --scopes="/subscriptions/${SUBSCRIPTION_ID...