Wie man eine Ansible Rolle der Variablen Datei relativ zu dem host?

Hier ist das detail von meinem playbook:

Playbook Baum

├─ devops
|  ├─ roles
|  |  ├─ mongodb
|  |  ├─ haproxy
|  |  ├─ monit
|  |  |  ├─ vars
|  |  |  |  └─ main.yml
|  |  |  └─ ...
|  |  └─ ...
|  ├─ hosts
|  ├─ play1.yml
|  └─ play2.yml

hosts

[play1]
...instructions...

[play2]
...instructions...

spielen1.yml

---
- hosts: play1
  user: root
  roles:
    - haproxy
    - monit

play2.yml

---
- hosts: play2
  user: root
  roles:
    - mongodb
    - monit

Frage

Ich würde gerne auf einen anderen Variablen-Datei für monit je nach host (spielen1.yml oder play2.yml). Wie ich kann den trick tun?

Vielen Dank

  • Das ist AFAIK nicht möglich. Eine Rolle ist komplett unabhängig von deinem Inventar. Wenn Sie möchten, dass host-spezifische Variablen, die Sie erstellen müssen, vars in host_vars oder group_vars. Dieser Ordner kann entweder relativ zu Ihrem playbook oder relativ zur Inventar-Datei.
InformationsquelleAutor | 2015-02-25
Schreibe einen Kommentar