automium.haproxy
Ansible Role: HAProxy
This role installs HAProxy on Ubuntu 16.04 (Xenial).
Requirements
You need Ansible version 2.4 or higher to use this role.
Role Variables
Most variables for this role are set in the file defaults/main.yml
.
Example Playbook
To use the default variables, your playbook should look like this:
- hosts: all
roles:
- role: automium.haproxy
haproxy_user: haproxyuser
haproxy_pass: haproxypass
haproxy_conf: |
listen web
mode http
bind *:80
default-server port 80
server web-0 1.1.1.1:80 check
Testing
You can test the role using Molecule.
To get started, you can install Molecule or run docker-compose run --rm molecule
to create a local Docker container from the enterclousuite/molecule project.
Here’s how to test your role:
- Run
molecule create
to create a Docker container for testing. - Use
molecule login
to access the running container. - Make changes to the role files as needed.
- If you need other roles, add them in the
molecule/default/requirements.yml
file. - Modify the
molecule/default/playbook.yml
as required. - Create infrastructure tests in the
molecule/default/tests
folder using the goos verifier. - When ready, run
molecule converge
to apply the playbook andmolecule verify
to check your tests. The converge process will also check the syntax of the role. - To remove the Docker container, use
molecule destroy
.
To run all steps in one command, simply execute molecule test
.
If you want to run the role on a virtual machine, use the playbook_deploy.yml
file with a command like this:
ansible-playbook ansible-haproxy/molecule/default/playbook_deploy.yml -i VM_IP_OR_FQDN, -u ubuntu --private-key private.pem
License
MIT