:special/inventory
とdefault/inventory
両方の内側に、私はこのグループを持っているので、私はローカルホストのホストに対してそれをちょうどテストしている。この例では
.
|-- default
| |-- group_vars
| | `-- server.yml
| `-- inventory
|-- site.yml
|-- special
| |-- group_vars
| | `-- server.yml
| `-- inventory
を私の場合、それはです。重要なことは、グループ名である
[server]
localhost
、それはdefault/group_vars
とspecial/group_vars
ファイル名で一致する必要があります(:、しかし、あなたは何でもあなたの必要性ごとに置くことができますしかし、あなたのケースでは、何もすることができます):
のでdefault/group_vars
で、私が置かれています:
---
the_var: default
をしてspecial/group_vars
で、私が置かれています:
---
the_var: not_default
私のテストプレイブックで(この場合のsite.yml
)は、以下を有する。
---
- hosts: all
gather_facts: no
tasks:
- debug:
msg: "{{ the_var }}"
私はデフォルトのインベントリに対する脚本を呼び出すとき210は今、この値を得た:私は特別な在庫に対する脚本を呼び出すときに、この値だ
anansible-playbook -i default site.yml -c local
PLAY [all] *********************************************************************
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "default"
}
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
:
ansible-playbook -i special site.yml -c local
PLAY [all] *********************************************************************
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "not_default"
}
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
-c local
は、ローカルホストの接続用ですがいますあなたのライブ環境では必要ありませんが、私はあなたがデフォルトであるssh接続でリモートホストで作業していると確信しています。それがあなたを助けることを願っています