Deploying a sample application
We will now deploy a simple phonebook application in Azure Cloud. In this application, we will create a resource group (phonebook), a virtual network (phonebook-vnet01), a subnet (phonebook-net01), a security group (phonebook) allowing HTTP and SSH traffic, a network interface with a public IP, and finally a virtual machine.
How to do it...
Using recipes from this chapter, we can create and save our playbook as phonebook.yml
:
#Playbook for deploying phonebook application in Azure Cloud --- - hosts: tag_Name_first_vm gather_facts: no roles: - phonebook
We should note that the hosts in this playbook are set as tag_Name_first_vm
(Ansible dynamic inventory), which will create an inventory for our phonebook application at runtime. We can execute our playbook using the following command:
$ ansible-playbook -i azure-rm.py --become phonebook.yml
We used a command-line inventory argument for our playbook, since we are creating our resources in the playbook itself...