小编mur*_*ers的帖子

如何将 Ansible 剧本变量从主剧本传递到链接剧本?

我试图找出如何将“主”剧本中定义的 Ansible 剧本变量传递到我已经在我的主剧本中引用的其他剧本中。

例如,使用下面的“主”剧本,我想将sethostnamesetipaddress的值传递给我的任务部分中引用的剧本 [1-3].yml。这类似于调用其他编程语言中的函数。

---
- hosts: all
  become: yes

  vars_prompt:
   - name: "sethostname"
     prompt: "What will be the machine's hostname?"
     private: no

   - name: "setipaddress"
     prompt: "What will be the machine's IP address?"
     private: no

  tasks:
    - include: playbook1.yml
    - include: playbook2.yml
    - include: playbook3.yml
Run Code Online (Sandbox Code Playgroud)

ansible

2
推荐指数
1
解决办法
2623
查看次数

标签 统计

ansible ×1