# Setup Nginx load balancer
Ansible config for settting up Nginx load balancer hosts and configuration for load balancer services. There are two layers of load balancers, one for the presentation virtual servers and one for backend application virtual servers.

Detailed instruction on setting up LB services can be found on Confluence:
https://confluence.bisnode.net/display/AO/Playbook%3A+load_balancer.yaml

## Inventories for different environments

There are separate inventories for different environments under *inventories* catalog:
- **dev**: inventories/dev/file_inventory.yaml
- **noprod**: inventories/noprod/file_inventory.yaml
- **prod**: inventories/prod/file_inventory.yaml
- **qa**: inventories/qa/file_inventory.yaml
- **stage**: inventories/stage/file_inventory.yaml

To use each inventory use *-i* option in ansible-playbook command.

## Troubleshooting Nginx load balancer

To dry-run playbook use -C option. For example to dry-run on noprod environment:
```
ansible-playbook -i inventories/noprod/file_inventory.yaml --diff load_balancer.yaml -C
```
To restrict running playbook only to one LB, use -l option. E.g. to restrict only to lbif-02:
```
ansible-playbook -i inventories/noprod/file_inventory.yaml --diff load_balancer.yaml -l ~lbif-02
```
To check if routing is correctly configured:
- Login to LBIF node
- Check routing configuration under /etc/netplan/ansible-config.yaml file
- Check that the config matches ip rules:
```root@lbif-01:~$ sudo ip rule ```
- If the rules don't match apply the rules again:
```root@lbif-01:~$ sudo netplan apply ```

