# nice way how to provision 3tier ha /keepalived, nginx, apache/

**URL:** <https://forum.ansible.com/t/nice-way-how-to-provision-3tier-ha-keepalived-nginx-apache/12909>\
**Category:** Ansible Project\
**Created:** [June 5, 2013, 2:36pm UTC](https://forum.ansible.com/t/nice-way-how-to-provision-3tier-ha-keepalived-nginx-apache/12909 "2013-06-05T14:36:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hudec\_Peter](https://avatars.discourse-cdn.com/v4/letter/h/a87d85/32.png) [@Hudec\_Peter](https://forum.ansible.com/u/Hudec_Peter)\
**Post date:** [June 5, 2013, 2:36pm UTC](https://forum.ansible.com/t/nice-way-how-to-provision-3tier-ha-keepalived-nginx-apache/12909/1 "2013-06-05T14:36:57Z")

</div>

Hi all,

I'm trying to find a nice way how to write playbook for automatic  
configuration for

LB: keepalived  
RP: nginx  
APP: apache

The setup is like LB \<-\> NGINX \<-\> APP  
The playbook should be able to change the configuration of the LB if nginx  
is added or change the nginx configuration if the backend servers added.

Of course the nginx is do the load balancing based on the domain is  
proxying, e.g.  
&nbsp;&nbsp;www.xyz.com -\> APP01, APP02  
&nbsp;&nbsp;Www.abc.com -\> APP03, APP04  
And the keepalived is load balancing the request based on the virtual ip  
and port e. g.  
&nbsp;&nbsp;z.x.c.v:80 -\> nginx01, nginx02  
&nbsp;&nbsp;q.w.e.r:80 -\> nginx03, nginx04

At this moment I have this setup written manually. One way is to  
distribute only the static configuration files, but it would be nice to  
have it a little bit more automated … The another way could be distribute  
static files generated by the external script

The problem I found is, that I'm not able to access facts for RP servers  
if I'm running the playbook in LB group /from inventory file/.

Any good idea how to do this task?

&nbsp;&nbsp;Best regards  
&nbsp;&nbsp;&nbsp;&nbsp;Peter Hudec

---

<div class="post-metadata">

**Author:** ![benno\_joy](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@benno\_joy](https://forum.ansible.com/u/benno_joy)\
**Post date:** [June 5, 2013, 2:57pm UTC](https://forum.ansible.com/t/nice-way-how-to-provision-3tier-ha-keepalived-nginx-apache/12909/2 "2013-06-05T14:57:34Z")

</div>

Hey Peter

In your playbook if you put an empty task for the RP server you should be able to get the facts of that machine.

- hosts: RP  
tasks:

- hosts:LB  
tasks:

- command: echo ‘{{ hostvars[‘RP’].xxx }}’

- Benno
