首页 > 解决方案 > 根据变量更改 ansible 库存

问题描述

剧本可以从变量中加载库存列表吗?所以我可以根据选择的环境轻松自定义运行?

  tasks:
  - name: include environment config variables
    include_vars:
      file: "{{ item }}"
    with_items:
      - "../../environments/default.yml"
      - "../../environments/{{ env_name }}.yml"

- name: set inventory
  set_fact:
     inventory.docker_host = " {{ env_docker_host }}"

标签: ansible

解决方案



推荐阅读