如何使用工头库存插件将工头主机参数传递给 ansible vars?

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

我正在尝试运行 Ansible 剧本而不从工头/卫星开始执行,原因有很多(丑陋的调度是一个)。相反,我想使用 GitLab CI。

为此,我正在使用工头库存插件 (

theforeman.foreman.foreman
),它允许 Ansible 从工头/卫星获取库存。

现在,我的角色正在使用工头/卫星中定义的变量作为主机参数,我找不到使用工头库存从我的剧本中访问这些参数的方法。

我的库存插件 yaml 配置中有这些设置:

plugin: theforeman.foreman.foreman
url: https://whatever.url...
user: rhs_inventory_reader
password: **********
host_filters: 'last_checkin > "12 hours ago" and hypervisor = false'
want_facts: true
want_hostcollections: true
want_params: true
legacy_hostvars: true

根据文档,参数

legacy_hostvars
这样做:

将 hostvars 放入字典中,键为

foreman
foreman_facts
foreman_params

我试过打印变量,但它们甚至没有在 Ansible 中定义:

  tasks:
    - debug:
        var: foreman

这种方法有什么问题,我如何使用工头清单从 Ansible 收集工头主机参数,而不触发工头内部的运行?

ansible ansible-inventory foreman satellite
© www.soinside.com 2019 - 2024. All rights reserved.