从广告资源中调用自定义变量

时间:2019-12-03 17:30:29

标签: ansible

我的清单文件中有一些自定义变量。我想在我的剧本中称呼他们,但不确定如何做到。

-------------------------------- INV -------------- ------------------

global $conn;
$res_groups = array();
$stmt = $conn->prepare("
    SELECT * FROM groups
");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
while ($group = $stmt->fetch()){
    $groups = array();
    $groups['id'] = $group['id'];
    $groups['name'] = $group['name'];
    $groups['type'] = $group['type'];
    $groups['description'] = $group['description'];
    $groups['sort'] = $group['sort'];
    $groups['status'] = $group['status'];
    $groups['listing_reg_type'] = $group['listing_reg_type'];
    $groups['listing_per_page'] = $group['listing_per_page'];
    $groups['listing_fee'] = $group['listing_fee'];
    $groups['listing_reinvest__fee'] = $group['listing_reinvest_fee'];

    $programs = array();
    $stmts = $conn->prepare('
        SELECT * FROM listings WHERE group_id = "'.$groups['id'].'"
    ');
    $stmts->execute();
    $stmts->setFetchMode(PDO::FETCH_ASSOC);
    while ($program = $stmts->fetch()){
        $programs[] = $program;
    }
    $groups['listings'] = $programs;
    $res_groups[] = $groups;
}

-------------------------------- PLAYBOOK -------------- ------------------

[testA]
namgw01a
namgw02a

[testB]
namgw01b
namgw02b

[nam:children]
testA
testB

[testA:vars]
file=file_a.conf

[testB:vars]
file=file_b.conf

--------------------------------结果-------------- ------------------

vars:
  - file: "{{ file }}"

- name: "show variable"
  debug:
    var: file

0 个答案:

没有答案