Search code examples
azureansibleazure-cloud-shell

Ansible - How to run YAML code in Azure Cloud Shell


Question: How do I run the following YAML in Azure Cloud Shell?

In step 1 of this Ansible tutorial, the author is asking to run the following YAML - to create a resource group. I'm using PowerShell in Azure Cloud Shell (where Ansible is pre-installed).

- name: Create resource group
    azure_rm_resourcegroup:
    name: rg-cs-ansible
    location: eastus

Solution

  • Save it to a playbook.yaml text file and run it with ansible-playbook playbook.yaml, but you also need to have a proper structure to the playbook file. something like this:

    ---
    - hosts: localhost
      tasks:
      - name: Create resource groupf
        azure_rm_resourcegroup:
          name: rg-cs-ansible
          location: eastus