如何将变量传递给 Azure yaml 管道中的 ansible 剧本

问题描述 投票:0回答:0

我需要将名为“required_location”的变量传递到 Azure 管道中的 ansible 剧本。我尝试了 extraVars & '$[variables.variable]' 方法。但它没有用。

trigger:
 - none

parameters:
  - name: NASlocation
    displayName: location
    default: A
    type: string
    values:
      - A
      - B

variables:
  - group: Xyz.Coesd.VariableGroup.GlobalVars
  - group: nas
  - name: required_location
    value: ${{ parameters.NASlocation}}


resources:
  repositories:
    - repository: pipetemplates
      type: git
      name: XYZ0002357/pita-pipeline-templates
      ref: 'refs/heads/iib-changes'


stages:
- stage: COTS_CI
  jobs:
  - template: flows/cos-ci.yml@pipetemplates


- stage: CD_DEV
  dependsOn:
  - COTS_CI
  jobs:
  - template: flows/cos-at.yml@pipetemplates
    parameters:
      deployment_environment: 'DEV'
      target_platform: 'XYZ'
      vault_password: $(ansible_vault_password)
      playbook_name: 'create_nfs'
      inputs:
        required_location: $[variables.required_location]

我在执行剧本时遇到的错误是“'required_location' is undefined”。 在我名为 create_nfs 的 ansible 剧本中,我期望使用 jinja 模板 '{{ required_location }}' 将名为 required_location 的变量的值捕获为 'A' 或 'B'

azure-devops ansible-2.x azure-pipelines-yaml
© www.soinside.com 2019 - 2024. All rights reserved.