Options

Ansible Playbook Examples for ADC Features

gokulpokurigokulpokuri Member, Administrator admin
edited December 2020 in DevOps

This article provides some Ansible playbook examples for application acceleration and optimization features for Thunder ADC shown below. Each playbook uses the respective acos_axapi module for that feature. A10 acos_axapi module set consists of more than 1,600 modules. Module set can be downloaded from GitHub Repository: https://github.com/a10networks/a10-acos-axapi.

  • RAM Caching
  • HTTP Compression
  • Connection Reuse
  • Source IP Persistence
  • Cookie Persistence
  • Connection Rate Limiting

Note: This article uses each module as a separate playbook, but you can consolidate them as you need.   

In the playbook examples, the Host value vthunder2 points to the Thunder ADC  host variables ansible_host, ansible_port, ansible_username, ansible_password defined in the inventory file inventory.txt.

For example:

vthunder ansible_host=10.64.4.160 ansible_port=443 ansible_username=admin ansible_password=a10

To learn more about A10 Ansible module parameters, refer to module documentation by running the command ansible-doc <modulename> on the Ansible server.

RAM Caching

The RAM cache is a high-performance, in-memory web cache that by default caches HTTP responses (RFC 2616 compliant). The RAM cache can store a variety of static and dynamic content and serve this content instantly and efficiently to many users. Caching HTTP content reduces web server transactions, and hence the server loads.

Caching also reduces page download time and bandwidth utilization. Caching is useful for high-demand objects on a website, for static content such as images, and when used in conjunction with compression to store compressed responses, eliminating unnecessary overhead.

Module used: a10.acos_axapi.a10_slb_template_cache

Use the playbook below to configure RAM caching

- name: RAM caching example playbook
  connection: local
  hosts: vthunder2
  tasks:
 - name: "Create RAM caching config"
   a10.acos_axapi.a10_slb_template_cache:
     ansible_host: "{{ ansible_host }}"
     ansible_port: "{{ ansible_port }}"
     ansible_username: "{{ ansible_username }}"
     ansible_password: "{{ ansible_password }}"
     state: present
     disable_insert_age: yes
     disable_insert_via: yes
     max_cache_size: 80
     max_content_size: 81920
     min_content_size: 512     
     verify_host: yes
     name: test-ram-caching

Let’s say the name of the playbook file is RAMcaching_config.yaml. Run the following command to execute the playbook.

ansible-playbook RAMcaching_config.yaml -i inventory.txt

Below is the sample output

HTTP Compression

HTTP Compression reduces the amount of bandwidth required to send content to clients. Although compression optimizes bandwidth, compression can sometimes actually hinder overall website performance, if the real servers spend a lot of their CPU resources performing the compression.

To maximize the benefits of content compression, you can enable the ACOS device to perform compression for the real servers. If HTTP compression is enabled on the servers, ACOS transparently offloads this task from servers.

Module used: a10.acos_axapi.a10_slb_template_http

Use the playbook below to configure HTTP Compression

- name:  HTTP Compression example playbook
  connection: local
  hosts: vthunder2
  tasks:
 - name: "Compression config"
   a10.acos_axapi.a10_slb_template_http:
     ansible_host: "{{ ansible_host }}"
     ansible_port: "{{ ansible_port }}"
     ansible_username: "{{ ansible_username }}"
     ansible_password: "{{ ansible_password }}"
     state: present
     compression_auto_disable_on_high_cpu: 80
     compression_enable: yes
     compression_content_type:
     - content_type: text
     - content_type: image
     - content_type: application
     compression_exclude_content_type:
     - exclude_content_type: application/zip
     compression_minimum_content_length: 120
     compression_level: 6
     name: test-compression

Let’s say the name of the playbook file is Compression_config.yaml. Run the following command to execute the playbook.

ansible-playbook Compression_config.yaml -i inventory.txt

Below is the sample output

Connection Reuse

Connection reuse enables you to reuse TCP connections between the ACOS device and real servers for multiple client sessions. When you enable this feature, the ACOS device does not tear down a TCP connection with the real server each time a client ends its session. Instead, the ACOS device leaves the TCP connection established and reuses the connection for the next client that uses the real server. This option provides faster server response time and higher server scalability.

Module used: a10.acos_axapi.a10_slb_template_connection_reuse

 Use the playbook below to configure Connection Reuse

- name: Connection reuse example playbook
  connection: local
  hosts: vthunder2
  tasks:
 - name: "Create Connection reuse config"
   a10.acos_axapi.a10_slb_template_connection_reuse:
     ansible_host: "{{ ansible_host }}"
     ansible_port: "{{ ansible_port }}"
     ansible_username: "{{ ansible_username }}"
     ansible_password: "{{ ansible_password }}"
     state: present
     limit_per_server: 1000
     timeout: 2400
     name: test-connection-reuse

Let’s say the name of the playbook file is Connection_reuse_config.yaml. Run the following command to execute the playbook.

ansible-playbook Connection_reuse_config.yaml. -i inventory.txt

Below is the sample output

Source IP Persistence

Source IP persistence must be used when clients must have their future connections/traffic terminated on the same server. This “sticky” behavior (or persistence) is helpful in situations where it is important to maintain a consistent connection between a client and a server, such as online shopping, where it may be desirable to track the client’s interaction with the website.

Module used: a10.acos_axapi.a10_slb_template_persist_source_ip

Use the playbook below to configure Source IP Persistence

- name: Source IP persistence example playbook
  connection: local
  hosts: vthunder2
  tasks:
 - name: "Source IP persistence config"
   a10.acos_axapi.a10_slb_template_persist_source_ip:
     ansible_host: "{{ ansible_host }}"
     ansible_port: "{{ ansible_port }}"
     ansible_username: "{{ ansible_username }}"
     ansible_password: "{{ ansible_password }}"
     state: present
     enforce_higher_priority: no
     match_type: yes
     server: yes
     name: test-source-ip-persistence

Let’s say the name of the playbook file is Sourceip-persistence_config.yaml. Run the following command to execute the playbook.

ansible-playbook Sourceip-persistence_config.yaml. -i inventory.txt

Below is the sample output

Cookie Persistence

Like Source IP Persistence, Cookie Persistence is used when HTTP/HTTPS clients must have their future connections/traffic terminated on the same server. But Cookie Persistence provides more granularity, since even different users coming from the same Proxy (same IP address) will get different persistence with Cookie Persistence.

Module used: a10.acos_axapi.a10_slb_template_persist_cookie

Use the playbook below to configure Cookie Persistence

- name: Cookie persistence example playbook
  connection: local
  hosts: vthunder2
  tasks:
 - name: "Cookie persistence config"
   a10.acos_axapi.a10_slb_template_persist_cookie:
     ansible_host: "{{ ansible_host }}"
     ansible_port: "{{ ansible_port }}"
     ansible_username: "{{ ansible_username }}"
     ansible_password: "{{ ansible_password }}"
     state: present
     expire: 31536000
     cookie_name: performance-cookie
     name: test-cookie-persistence

Let’s say the name of the playbook file is Cookie-persistence_config.yaml. Run the following command to execute the playbook.

ansible-playbook Cookie-persistence_config.yaml. -i inventory.txt

Below is the sample output

Connection Rate limiting

It limits the rate at which the ACOS device can send new connections to servers or service ports.

Module used : a10.acos_axapi.a10_slb_template_port

- name: Connection rate limit example playbook
  connection: local
  hosts: vthunder2
  tasks:
 - name: "Connection rate limit config"
   a10.acos_axapi.a10_slb_template_port:
     ansible_host: "{{ ansible_host }}"
     ansible_port: "{{ ansible_port }}"
     ansible_username: "{{ ansible_username }}"
     ansible_password: "{{ ansible_password }}"
     state: present
     conn_rate_limit: 50000
     rate_interval: 100ms
     name: connection-rate-limit

 Let’s say the name of the playbook file is Rate-limit_config.yaml. Run the following command to execute the playbook.

ansible-playbook Rate-limit_config.yaml. -i inventory.txt

Below is the sample output


 

Tagged:
Sign In or Register to comment.