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

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.
  www.xyz.com -> APP01, APP02
  Www.abc.com -> APP03, APP04
And the keepalived is load balancing the request based on the virtual ip
and port e. g.
  z.x.c.v:80 -> nginx01, nginx02
  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?

  Best regards
    Peter Hudec

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