Created
February 23, 2022 09:05
-
-
Save jaybrueder/52288526a85a15b0596199922609f0dc to your computer and use it in GitHub Desktop.
Ansible HAProxy Playbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: webservers | |
become_user: root | |
become: yes | |
tasks: | |
- name: gather facts from web servers | |
amazon.aws.ec2_metadata_facts: | |
- hosts: loadbalancers | |
become_user: root | |
become: yes | |
pre_tasks: | |
- name: update package list | |
ansible.builtin.apt: | |
update_cache: yes | |
roles: | |
- role: geerlingguy.haproxy | |
haproxy_version: "{{ '1.4' if '1.4.' in haproxy_version_result.stdout else '1.5' }}" | |
haproxy_backend_servers: | |
- name: web1 | |
address: "{{ hostvars['host1']['ansible_ec2_public_ipv4'] }}:80" | |
- name: web2 | |
address: "{{ hostvars['host2']['ansible_ec2_public_ipv4'] }}:80" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment