Ansible YAML属性读取

时间:2018-07-16 17:56:08

标签: ansible yaml

如何在Ansible Playbook中选择云。 Cloud nforce现在是静态定义的。如您在剧本的最后一个任务中所见。但是如何实现变量target_cloud来指定我想要的云?

Ansible Playbook

---
- name: Get credentials from target Cloud
  hosts: localhost
  connection: local
  become: no
  gather_facts: no
  vars:
    target_cloud: nfanthonydev
  tasks:

    - name: Load Clouds from file
      include_vars: clouds.yaml

    - name: Set credentials of target cloud in memory
      set_fact:
        os_auth:
          auth_url: "{{ clouds.nforce.auth.auth_url }}"

clouds.yml

clouds:
  nfbeheer:
    auth:
      auth_url: https://nforce-it.nl:5000/v3
      user_domain_name: Default
      username: kees
      password: kees_pass
      project_domain_name: Default
      project_name: nforce-beheer
    region_name: Steenwijk
  nfanthonydev:
    auth:
      auth_url: https://nforce-it.nl:5000/v3
      user_domain_name: Default
      username: anthony
      password: anthony_pass
      project_domain_name: Default
      project_name: nforce-anthonydev
    region_name: Groningen
  nforce:
    auth:
      auth_url: https://nforce-it.nl:5000/v3
      user_domain_name: Default
      username: piet
      password: piet_pass
      project_domain_name: Default
      project_name: nforce
    region_name: Groningen

0 个答案:

没有答案