0
votes

We have these 3 ansible-playbooks and Jenkins jobs:

  • web/deploy_app
  • app/deploy_app
  • db/deploy_app

Each playbook runs on only 2 nodes, the web-playbook has an inventory of only 2 hosts, web01 and web02, the app-playbook has an inventory of only app01/app02.

Now we want to build "no-downtime deployments", which means a service on app01 must be shut down before the deployment of db01.

How can I run a play on app01 in Ansible when app01 is not even in the Ansible inventory for the db01/deploy_app playbook?

1

1 Answers

2
votes

How can I run a play on app01 in Ansible when app01 is not even in the Ansible inventory for the db01/deploy_app playbook?

Why do you have multiple inventories? You should be able to merge all your inventories into a single inventory file, something akin to this:

[databases]
db01
db02

[webservers]
web01
web02

[appservers]
app01
app02

then you just specify multiple plays in your playbook:

- hosts: app01
  tasks: 
    - name: Some task...

- hosts: webservers
  tasks:
    - name: Some other task...