如何编写动态变量,以terraform

时间:2018-01-09 11:04:07

标签: terraform

我想要一个用于配置动态变量和请求体的代码。我试过这个代码,但它仅用于ansible,但我需要terraform

- name         : Test var
  hosts        : all
  gather_facts : no
  vars:
    myvariable : false
  tasks:
    - name: param1
      set_fact:
        myvariable: "{{param1}}"
      when: param1 is defined

- name: param2
  set_fact:
    myvariable: "{{ param2 if not myvariable else myvariable + ',' + param2 }}"
  when: param2 is defined

- name: param3
  set_fact:
    myvariable: "{{ param3 if not myvariable else myvariable + ',' + param3 }}"
  when: param3 is defined

- name: default
  set_fact:
    myvariable: "default"
  when: not myvariable

- debug:
   var=myvariable

0 个答案:

没有答案