【问题标题】:Ansible - How to run YAML code in Azure Cloud ShellAnsible - 如何在 Azure Cloud Shell 中运行 YAML 代码
【发布时间】:2020-10-26 03:50:22
【问题描述】:

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

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

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

【问题讨论】:

    标签: azure ansible azure-cloud-shell


    【解决方案1】:

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

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

    【讨论】:

    • 我在playbook.yaml 文件中运行了您的脚本并收到以下错误 - 有什么建议吗? 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 <class 'ansible.parsing.yaml.objects.AnsibleMapping'> 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
    • 可能已经修好了,3年没用过ansible了
    • 您的固定建议有效(谢谢)。文章的作者没有提到如何运行他/她的代码块。还有其他方法可以运行他/她的块吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-15
    • 2011-03-04
    • 1970-01-01
    • 2017-02-10
    相关资源
    最近更新 更多