Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] 配置模板支持主机动态渲染 #1466

Closed
ZhuoZhuoCrayon opened this issue Feb 27, 2023 · 0 comments
Closed

[FEATURE] 配置模板支持主机动态渲染 #1466

ZhuoZhuoCrayon opened this issue Feb 27, 2023 · 0 comments
Assignees
Labels

Comments

@ZhuoZhuoCrayon
Copy link
Member

ZhuoZhuoCrayon commented Feb 27, 2023

你想要什么功能
配置模板支持主机动态渲染

为什么需要
根据拓扑节点 / 模板等信息,在模板渲染时解析出相应的 IP,获取的主机信息按 IP 保证有序

建议如何实现

协议

接口:get_hosts_by_node

接口协议

// 动态拓扑
[{"bk_biz_id": 2, "bk_inst_id": 2, "bk_obj_id": "set"}]
// 集群模板
[{"bk_biz_id": 2, "bk_inst_id": 11, "bk_obj_id": "SET_TEMPLATE"}]
// 服务模板
[{"bk_biz_id": 2, "bk_inst_id": 111, "bk_obj_id": "SERVICE_TEMPLATE"}]

支持属性

企业微信截图_b8be17f2-754a-49d4-9c37-79a3e42b569b

调用方法

示例模板

# 获取拨测目标信息
{% set instances = get_hosts_by_node(nodes) %}
tasks:
  - task_id: {{ task_id }}
    bk_biz_id: {{ bk_biz_id }}
    {% if instances %}ips:
    {% for instance in instances %}- {{ instance["bk_host_innerip"] }}
    {% endfor %}
    {% endif %}

渲染结果

tasks:
  - task_id: 1
     bk_biz_id: 2
     ips:
     - 127.0.0.1
     - 127.0.0.2
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant