Skip to content

Instantly share code, notes, and snippets.

@Linuxpizi
Last active April 25, 2020 00:58
Show Gist options
  • Select an option

  • Save Linuxpizi/c399a414b7406d3ae95e3583a2c9a14a to your computer and use it in GitHub Desktop.

Select an option

Save Linuxpizi/c399a414b7406d3ae95e3583a2c9a14a to your computer and use it in GitHub Desktop.
Ansible Variable

关于ansible变量的定义

  1. 直接在host内定义
  2. 在/roles/x/vars/main.yml内定义
  3. 在role vars内定义

示例

  1. 在文件内定义 /roles/x/vars/main.yml
---

job: engine
hobby: look

使用

- hosts: slave
  gather_facts: no
  roles:
    - role: test
      vars_files:
        - main.yml
  1. 在role定义
- hosts: slave
  gather_facts: no
  vars:
    name: tsong
    age: 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment