0

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
nam
  • 21,967
  • 37
  • 158
  • 332

1 Answers1

0

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
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • I ran your script in `playbook.yaml` file and got the following error - any suggestion? `ERROR! A malformed block was encountered while loading tasks: {u'azure_rm_resourcegroup': None, u'name': u'rg-cs-ansible', u'location': u'eastus'} should be a list or None but is The error appears to be in '/home/myaccount/clouddrive/MyTestDir/createrg.yaml': line 1, column 3, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - name: Create resource group ^ here` – nam Oct 26 '20 at 04:16
  • 1
    probably fixed it, haven't used ansible in 3 years or something – 4c74356b41 Oct 26 '20 at 04:35
  • Your fixed suggestion worked (thank you). Author of the article did not mention how to run his/her code block. Are there other ways one can run his/her block? – nam Oct 26 '20 at 04:50