【问题标题】:ansible - unable to create Azure network security groupansible - 无法创建 Azure 网络安全组
【发布时间】:2020-10-29 18:04:50
【问题描述】:

尽管我正确地遵循了YAML tutorial(用于格式化 YAML 文件)和来自官方 ansible 文档的ansible example,使用以下ansible playbook 创建了Azure Network Security Group。但是当我在Azure Cloud Shell 中运行剧本时,我得到如下所示的错误:

Create_network_security_group.yaml

---
- hosts: localhost

  tasks:
  - azure_rm_securitygroup:
      resource_group: rg-cs-ansible
      name: nsg-cs-web
      rules:
          - name: 'allow_rdp'
            protocol: TCP
            destination_port_range: 3389
            access: Allow
            priority: 1001
            direction: Inbound
          - name: 'allow_web_traffic'
            protocol: TCP
            destination_port_range:
              - 80
              - 443
            access: Allow
            priority: 1002
            direction: Inbound
          - name: 'allow_powershell_remoting'
            protocol: TCP
            destination_port_range:
              - 5985
              - 5986

错误

[本地主机]:失败! => {"changed": false, "msg": "协议的值必须是以下之一:Udp, Tcp, *, got: TCP found in rules"}

【问题讨论】:

    标签: ansible azure-cloud-shell


    【解决方案1】:

    基于this URL 上的官方和“最新”文档。注意例子,协议的大小写是“Tcp”,而不是“TCP

    此外,您分享的错误消息还建议使用TcpUdp* 作为可能的输入,它得到了TCP

    [localhost]: FAILED! => {"changed": false, "msg": "value of protocol must be one of: Udp, Tcp, *, got: TCP found in rules"}
    

    【讨论】:

    • 我改成了Tcp。但是现在我收到了类似的错误,但出现了不同的消息,尽管我确实将 priority 分别定义为 priority: 1001priority: 1002[localhost]: FAILED! => {"changed": false, "msg": "missing required arguments: priority found in rules"}
    • 第三条规则不存在,这是预期的吗?我不期待,所以问
    • 第三条规则 allow_powershell_remotin 没有定义优先级
    • 不,这不是预期的。另外,我已经发布了一个单独的帖子here,因为我认为您回答了上面发布的问题。
    • 我认为这是必要的和强制性的,见docs.ansible.com/ansible/latest/collections/azure/azcollection/…
    猜你喜欢
    • 2022-07-26
    • 1970-01-01
    • 1970-01-01
    • 2021-01-19
    • 1970-01-01
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 2021-04-25
    相关资源
    最近更新 更多