问题
first of all: I am still an Ansible newbie and I am just getting used to it.
i want to write a playbook that calls up a different playbook depending on the location of the client.
For example:
i have 3 different playbooks specifically for certain regions, usaclient.yml, euclient.yml and asiaclient.yml
these playbooks should be executed automatically via a "master playbook".
if the "master playbook" is executed on a european client, the playbook "euclient.yml" should be started.
does anyone know how to assign playbooks automatically to a region or has an idea how to solve this by bash script?
best regards
D1Ck3n
回答1:
Q: "If the "master playbook" is executed on a European client, the playbook euclient.yml
should be started."
A: In Ansible it's not possible to start a playbook conditionally. See import_playbook.
There are 2 options only. Start the playbook conditionally by an external tool or test the condition inside the playbook. Try ansible-runner.
来源:https://stackoverflow.com/questions/61592342/run-ansible-playbooks-by-region