首页 > 解决方案 > 如何从文件中为 Ansible Tower 作业模板设置额外的变量?

问题描述

我正在寻找从文件加载额外变量的 Ansible Tower 等效方法。就像从带有 ...--extra-vars "@somefile.yml" 参数的 cli 中一样。这可以在 Ansible Tower 中完成吗?

标签: ansibleansible-tower

解决方案


From the Tower you have several options:

  1. Under Job Templates use the Extra Variables option. This is the --extra-vars equivalent to the cli (Take into account that Tower is not cli and you cannot pass a file but you can copy/paste your file there)
  2. Use Surveys
  3. Load the Var file from your playbook directly and make it "flexible" with a variable to be sent from a Survey like:

- name: Load a variable file based on Survey, or a default if not found.
  include_vars: "{{ item }}"
  with_first_found:
    - "{{ firts_option }}.yaml"
    - "{{ second_option }}.yaml"
    - default.yaml 

推荐阅读