我试图找出如何将“主”剧本中定义的 Ansible 剧本变量传递到我已经在我的主剧本中引用的其他剧本中。
例如,使用下面的“主”剧本,我想将sethostname和setipaddress的值传递给我的任务部分中引用的剧本 [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 ×1