Ansible-如何在Azure Cloud Shell中运行YAML代码

问题描述

问题:如何在YAML中运行以下Azure Cloud Shell

this Ansible tutorial的步骤1中,作者要求运行以下YAML-创建资源组。我在Azure Cloud Shell(预先安装Ansible)中使用PowerShell。

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

解决方法

将其保存到playbook.yaml文本文件中,然后使用ansible-playbook playbook.yaml运行它,但是您还需要对Playbook文件具有适当的结构。像这样的东西:

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