azure - 创建后找不到代理池
问题描述
我正在尝试在特定代理池上运行本地化构建。
这个想法是我分两个阶段运行管道。
第一阶段运行 Ansible playbook,在 Azure DevOps 中创建代理池,在 Azure 虚拟网络中预配 VM,安装代理,在这个新创建的池上注册代理,并授权所有管道使用该池。这是因为需要在不同的虚拟网络上运行 Ansible playbook,并且 VSTS 需要连接到正确的代理。
第二阶段使用新创建的池来查找代理并在实际所需的虚拟网络中运行另一个 Ansible Playbook。
问题是第二阶段失败并出现此错误:
“管道无效。找不到 ID 为 0 的池。该池不存在或未被授权使用。有关授权详情,请参阅https://aka.ms/yamlauthz。”
这基本上就是我正在做的事情:
阶段1:
displayName: Environment Preparation
jobs:
- job: Prepare_Customer_Environment
displayName: Prepare Target Environment
variables:
- group: Azure-Ansible-Variables
pool:
name: 'Infrastructure-Agents'
workspace:
clean: all
steps:
- task: Ansible@0
displayName: Prepare Target Environment for Deployment
inputs:
SUBSCRIPTION_ID: $(SUBSCRIPTION-ID)
failOnStderr: false
playbookPathOnAgentMachine: '$(Build.Repository.LocalPath)/ansible/playbooks/environment.yml'
第 2 阶段:
- stage: Environment_Provisioning
displayName: Environment Provisioning
jobs:
- job: Update_Customer_Environment
displayName: Update Target Environment
variables:
- group: Azure-Ansible-Variables
pool:
name: $(environment)-$(env_id)
workspace:
clean: all
steps:
池的名称是正确的,我已经检查了 10 次。
在 Ansible 中,我使用 REST API 调用创建池:
- name: VSTS Agent Specific Configuration | Create the Agent Pool
register: create_pool_result
uri:
url: "https://company.visualstudio.com/_apis/distributedtask/pools?api-version=5.0-preview.1"
method: POST
body_format: json
body: {"name": "{{ hostvars['localhost']['resource_group'] }}","autoProvision": true}
status_code:
- 200
- 409
headers:
Authorization: "Bearer {{ hostvars['localhost']['current_bearer_token_3'] }}"
我在这里授权使用它:
- name: VSTS Agent Specific Configuration | Authorise Agent Pool for all Pipelines
register: authorise_pool_result
uri:
url: "https://dev.azure.com/Company/Project/_apis/build/authorizedresources?api-version=5.0-preview"
method: PATCH
body_format: json
body: [{"name": "{{ hostvars['localhost']['resource_group'] }}","type": "queue","id": "{{ current_agent_pool_queue }}","authorized": true}]
status_code:
- 200
headers:
Authorization: "Bearer {{ hostvars['localhost']['current_bearer_token_3'] }}"
这一切都有效,但第二阶段找不到池。我认为这是因为 yaml 文件在创建池之前被加载,然后它试图找到它认为不存在的资源,我不确定。
有没有办法重新加载定义/构建文件?或者有什么方法可以让服务找到动态创建的资源?
提前致谢。
解决方案
推荐阅读
- machine-learning - 什么是负采样方法使用 - sigmoid 或 softmax?
- amazon-web-services - AWS - {lambda function} 可能没有定义授权
- python - Python 3(Linux 和 Windows)中的 CPU 温度
- javascript - 如何使用 ES6 语法导入 pg-promise?
- mysql - 只允许每个 id 列有一次 true 吗?
- java - 我如何在 AccessibilityService 类中获得退格(删除)单击键事件?
- python - 我收到 TypeError: 'NoneType' object is not subscriptable in tictactoe 但我尝试在线解决类似问题但没有用
- c - 错误:声明在全局范围内隐藏变量
- paypal - 如何从磁铁 2 中的 paypal pro 设置中获取信用卡的 paypal 合作伙伴名称和 vandor 名称
- xcode - 未能正确地将库复制到应用程序包