How to use Ansible with Azure Bastion

Thakee Nathees 20 Reputation points
2023-10-10T20:23:14.1066667+00:00

Without azure bastion, I create my own vm named 'bastion' and install ansible within the bastion host to provision my vms in that vnet. However, I tried to use Azure bastion service but confused on where to run ansible and there is no way for me to install ansible on that bastion host. In that case where do I install ansible and how the connection works. What is the best practice here? A little example would be helpfull.

Azure Bastion
Azure Bastion
An Azure service that provides private and fully managed Remote Desktop Protocol (RDP) and Secure Shell (SSH) access to virtual machines.
247 questions
{count} votes

Accepted answer
  1. KapilAnanth-MSFT 39,461 Reputation points Microsoft Employee
    2023-10-11T05:00:54.27+00:00

    @Thakee Nathees

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    I understand that you would like to know the best practices for using Ansible for deploying resources in Azure.

    Azure Bastion Service is a PaaS Service, that is used to provide SSH or RDP Connectivity to VMs in Azure via Browser

    • Let's not confuse this with the VM you have created and named as bastion.
    • So, we shall call this VM as "vmNamedBastion"

    Now,

    Point to Note:

    • Just because you have installed Ansible on an Azure VM, does not mean you can use Ansible and deploy resources directly in Azure.
    • You still have to authenticate your requests like you would do in a regular server.
    • Because Azure VM only provides you Data plane connectivity to Azure and not Control Plane connectivity.
      • i.e., Just like you should sign in to use Azure Portal even if you are inside an Azure VM.
    • To configure authentication, refer Create Azure credentials
    • From here, you should be able to Write and run Ansible playbooks

    To Summarize:

    #1 "confused on where to run ansible and there is no way for me to install ansible on that bastion host"

    • You can refer to this for installation guide

    #2 "how the connection works"

    • The connection is via Public Internet
    • The authentication can be done Service Principal or using Azure Active Directory Username/Password

    These documents may come in handy:

    Thanks,

    Kapil.


    Please Accept an answer if correct.

    Original posters help the community find answers faster by identifying the correct answer.

    0 comments No comments

0 additional answers

Sort by: Most helpful