$ cat inventory
[dbservers]
DB1 ansible_host=10.252.22.163
[webservers]
WS1 ansible_host=10.252.22.163
[common]
CS1 ansible_host=10.252.22.163
$ cat pb.yml
- name: db and web
hosts:
- dbservers
- webservers
tasks:
- name: Run task
debug:
msg: 'Running on all dbservers and webserver'
$ cat common.yml
- name: common task should run on common host only(that too only once)
hosts:
- common
tasks:
- name: Run common task
debug:
msg: 'Running common task'
$ cat install.yml
- import_playbook: "pb.yml"
- import_playbook: "common.yml"
Is it possible to run common play (only once) on CS1 host, every time any of below commands are run?
> ansible-playbook -i inventory install.yml --limit 'DB1'
> ansible-playbook -i inventory install.yml --limit 'WS1'