变量可以引用vars文件中的另一个变量吗?

时间:2019-05-03 13:50:03

标签: ansible

我想在vars文件本身内部建立路径(我知道我可以从task文件中做到这一点)。那怎么办?

这就是我现在拥有的:

backup-location: /mnt/cassandra-backup/
schemas-location: schemas/
tokens-location: tokens/ 

我正在从任务文件中构建路径:

- name: Create schemas location
  file:
    path: "{{ backup-location }}{{ schemas-location }}"
    state: directory

我想要这样的东西:

backup-location: /mnt/cassandra-backup/
schemas-location: "{{ backup-location }}"schemas/
tokens-location: "{{ backup-location }}"tokens/

任务文件将具有以下内容:

- name: Create schemas location
  file:
    path: "{{ schemas-location }}"
    state: directory

1 个答案:

答案 0 :(得分:2)

它会像这样工作:

schemas-location: "{{ backup-location }}schemas/"
tokens-location: "{{ backup-location }}tokens/"