Hi All,
I’m using the bellow config in order to deploy Ansible in AWS with no problem , the db servers are actually RDS instances and the rest is all EC2 instances.
inventory hosts file:
[db]
db1.example.com ansible_connection=local
[web]
web1.example.com
[app]
app1.example.com
db.yml
-
hosts: db
connection: local
gather_facts: false
roles: -
{ role : db , tags: [ ‘db-role’ ] }
web.yml
-
hosts: web
roles: -
{ role : common , tags: [ ‘common-role’ ] }
-
{ role : web, tags: [ ‘web-role’ ] }
app.yml
-
hosts: app
roles: -
{ role : common , tags: [ ‘common-role’ ] }
-
{ role : app, tags: [ ‘app-role’ ] }
site.yml
-
include: db.yml
-
include: web.yml
-
include: app.yml
Unfortunately with this approach the common role will be executed in two runs “serialised”, one for the web playbook and one for the app playbook. Because I have many servers and various kind of roles, in order to improve the deployment time I have removed the common role from the web and app playbooks and created a common.yml playbook included in the site.yml file so ALL servers will execute the common role at the same time in parallel :
common.yml
-
hosts: all
roles: -
{ role : common , tags: [ ‘common-role’ ] }
site.yml
-
include: common.yml
-
include: db.yml
-
include: web.yml
-
include: app.yml
Unfortunately this results in a strange behaviour, when the common role will be executed it will also try to run on the RDS server which is not possible since RDS instances have only mysql access and no ssh. This end up running the common role in the local controller system where I’m running Ansible from… I guess this happens because of the connection: local I have defined in the db.yml playbook.
How can I avoid the common role from running locally ?
Regards,
N.