Chef Templates
-
Refer Here for the official documentation
-
Chef templates is an Embedded ruby template (ERB) so in files we can have dynamic content
-
Lets try to create a template

-
Dynamic expressions in embedded ruby should be
<%= %> -
When we try to copy the template using template resource, the file will evaluated all the expression in
<%= %>will be replaced by its dynamic values. Refer Here for the template resource -
Refer Here for the changeset

-
Now lets generate tomcat-users file template
-
Refer Here for the changeset containing all of the steps to install tomcat9 as per documentation Refer Here
-
Now lets also add support for centos 7
- Refer Here for the necessary changes done in the cookbook to make it work for centos 7
-
Lets try to use the test kitchen with Azure Refer Here for the documentation
-
Lets get image urn for centos 7

-
Search for ubuntu 20 urn by executing the following command in Azure CLI
az vm image list -f UbuntuServer --all --output table& the other command which we triedaz vm image list -p canonical -o table --all | grep 20_04-lts | grep -v gen2 -
Fix for the issue observed in the class add the ssh_key path in transport in kitchen.yml file

-
Now execute the kitchen commands

-
Azure Ubuntu 20.04 VM from test kitchen

-
Azure Centos 7 VM from test kitchen

-
In the changeset which i’m commiting i have removed subscription id for security reasons. Refer Here for the changeset
