ap-application-load-balancer

AP-ALB Application Rules (The “Load Balancer listener” standard)

GitHub: fititnt/ap-application-load-balancer Website: ap-application-load-balancer.etica.ai

TL;DR:

Table of Contents

Overview of Applications Variables on servers using AP-ALB standard

Variables prefixed with app_ are used by Apps and Sysapps and have some extra customization via ALB Strategies.

These are key elements that form a single dictionary (think object) for the alb_apps (list of dictionaries) and alb_sysapps (list of dictionaries).

Quick example:

    alb_apps:

      - app_uid: "static-files"
        app_domain: "assets.example.org"
        app_root: "/var/www/html"
        app_alb_strategy: "files-local"

      - app_uid: "minio"
        app_domain: "minio.example.org"
        app_alb_proxy: "http://localhost:9091"
        app_alb_strategy: "proxy"

    alb_sysapps:

      - app_uid: "consul"
        app_domain: "consul..nip.io"
        app_alb_strategy: "proxy"
        app_alb_proxy: "http://127.0.0.1:8500"

New on v0.8.6-alpha: internally ALB will merge alb_sysapps_alb + alb_sysapps_always + alb_sysapps and alb_app_always + alb_apps. Ansible default behavior when the same variable is defined default and then some hosts also specify the variable is override. To make it easier for who want some apps/sysapps be on all nodes on a datacenter (and to avoid you use advanced features like hash_behaviour or implement plugins like leapfrogonline/ansible-merge-vars) we suggest use as convention alb_sysapps_always and alb_app_always.

Applications variables

app_*

Note: as v0.8.x, this section still maybe not reflex all implementation, but as here as a plan of action (fititnt, 2019-12-04 17:27 BRT)

app_uid

Internaly, AP-ALB use app_uid common name for configutation files (like /opt/alb/apps/.conf), default logs directory, default data diretory, internal aliases for which load balance and more.

app_state

app_state defaults to present, so you did not need to define. If you want remove one app, it’s configurations rules, log files, etc, you should at least once re-run one time with the same app_uid and app_state: absent for each node. After this, you can remove referentes to the old app/sysapp.

Note: implementators should not automaticaly remove backups based only on this configutation.

app_domain

Most app_type expect at least one main domain so the the AP-ALB will know what to do when a request comes in.

app_domain_extras

Use this to add extra domains to app_domain.

app_debug

Mark one app in special to show more information, useful for debug. The information depends on the app_type implementation.

app_forcehttps

If true, acessing HTTP port will redirect 301 to the app_domain.

This option is one alternative to not use Ansible Host vars or Ansible Group Vars to define what Application run where. So you could have only one alb_apps alb_sysapps for the entire cluster (or more than one cluster if using more than one datacenter).

@TODO: implement this feature (fititnt, 2019-12-04 22:43 BRT)

app_index

app_root

app_tags

# Empty app_tags
app_domain_extras: []
# Please avoid using 'app_tags: ' without defined itens and ': []' at the end
# List with 3 extra domains
app_tags:
  - "my-tag-1"
  - "another-tag"
  - ""

app_data_*

app_data_* are one way to document specific applications that you care about make backups, or export/import from one node to another. The typical scenario is you document, at App/Sysapp level, what a different AP-ALB node should have to be fully operational.

As AP-ALB v0.8.2, this Role alone does not implement the full logistics of how to make the import/export/backup but you are encoraged to use these variables as one way to document or reuse future implementations.

Also keep in mind that even if AP-ALB implement these features, is likely that you would still need configure external services to store backups, since the priority here would be sincronize 2 nodes that, for example, do not have a shared (and often sloooow) filesystem.

app_data_directories

app_data_files

app_data_hook_export_after

app_data_hook_export_before

app_data_hook_import_after

app_data_hook_import_before

app_healthcheck_*

app_healthcheck_extras (draft)

@TODO: this is a draft (fititnt, 2020-01-05 09:33 BRT)

app_healthcheck_path (draft)

@TODO: this is a draft (fititnt, 2020-01-05 09:33 BRT)

app_healthcheck_value_ok (draft)

@TODO: this is a draft (fititnt, 2020-01-05 09:33 BRT)

app_hook_*

app_hook_after

You can execute custom tasks specific to one app after deployed.

app_hook_before

You can execute custom tasks specific to one app before deployed.

app_hook_onchange (draft)

Equivalent of app_hook_after, but will only run if the alb app was changed.

app_hook_[alb_play]_*

All options from app_hook_* are avalible to app_hook_[alb_play]_*. The main difference here is that [alb_play] act as one way to namespace your hooks.

The special variable alb_play could be hardcoded on your playbook or defined as command line variable (e.g. ansible-playbook -i hosts.yml my-playbook.yml -e="alb_play=infra") so only when this variable is defined, these hooks will be run.

@TODO: this explain some workarounds to archive this https://github.com/ansible/ansible/issues/17324

app_*_strategy

app_alb_strategy

This option define what base OpenResty/NGinx template will be used as base for process all other variables.

app_backup_strategy

As version v0.8.1-alpha, this app_backup_strategy still not implemented.

app_ha_strategy

As version v0.8.1-alpha, this app_ha_strategy still not implemented.

app_healthcheck_strategy

As version v0.8.7-beta, this app_healthcheck_strategy still not implemented.

app_nlb_strategy

As version v0.8.1-alpha, this app_nlb_strategy still not implemented.

app_alb_*

app_alb_hosts

@TODO consider implement this planned (but not fully usable) feature as additional alternative to Ansible Inventory (fititnt, 2019-12-05 19:17 BRT)

app_alb_proxy

app_alb_proxy_defaults

app_alb_proxy_defaults enable defaults inside the main proxy location block, like these ones:

location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    # ...
}

Disable if you is having issues or what to make full customization with app_alb_proxy_raw. If you are OK with the defaults, use app_alb_proxy_params to just append new values

app_alb_proxy_location

app_alb_proxy_params

app_alb_raw

You can use app_alb_raw_file as alternative.

app_alb_raw_file

Example of templates/example_app_alb_raw.conf.j2 content:

# File: github.com/fititnt/ansible-linux-ha-cluster/templates/example_app_alb_rawfile.conf.j2
# This file is just one example of using app_alb_raw_file instead of
# app_alb_raw template string

# With app_alb_raw you can't use item.app_uid variable, for example, but here
# you can

location / {
    content_by_lua_block {
       local cjson = require "cjson"
       ngx.status = ngx.HTTP_OK
       ngx.say(cjson.encode({
           msg = "Hello, ! (from app_alb_raw_file)",
           status = 200
       }))
    }
}

Deprecated app_* variables

app_raw_conf

Deprecated. Please use app_raw_alb and/or app_alb_raw_file

No default value for app_alb_strategy

Before AP-ALB v.0.8.x alb_apps[n]app_alb_strategy has default value of hello-word (and before that, files-local).

Now, value of app_alb_strategy is ommited, the alp_apps / alb_sysapps will be ignored by OpenResty.

The reason for this is allow on future have apps that can exist only for other reasons (for example, for NLB/HAProxy, or for Backup tasks). This also means that a same app group could have variables reused for different strategies

AP-ALB Application Rules compared to other load balancers

Azure Load balancer

@TODO write small paragraph about AP-ALB and Azure Load Balancer (fititnt, 2019-12-15 06:44 BRT)

AWS Application Load Balancers Listeners

@TODO write small paragraph about AP-ALB and AWS Application Load Balancers Listeners (fititnt, 2019-12-15 06:44 BRT)

Google Cloud Load Balancing

@TODO write small paragraph about AP-ALB and AWS Google Cloud Load Balancing (fititnt, 2019-12-15 06:44 BRT)