Skip to content

kolosovpetro/ansible-control-node

Repository files navigation

Azure Application Gateway with Ansible managed backend pools

Windows and Linux backend servers under Azure Application gateway, provisioned using Terraform. Ansible is used to manage backend servers. DNS records are created using Cloudflare Terraform provider.

Azure Application gateway diagram

ansible_concept

Azure Application Gateway components

  • Frontend IP Configuration — Defines the private or public IP address that receives requests to the application gateway.

  • Frontend Port — Defines a port that accepts incoming requests to the application gateway.

  • Backend Pool — A list of IP addresses or FQDNs where traffic is forwarded.

  • HTTP Settings — Defines how the application gateway sends incoming traffic to backend servers by setting up a protocol, backend port, and timeout interval.

  • HTTP Listener — Binds the Frontend IP Configuration, Frontend Port, and protocol together to listen for incoming requests.

  • SSL Certificate — Used in HTTPS listeners to secure communication between the gateway and clients by enabling traffic encryption.

  • Routing Rules — Binds HTTP Listener, Backend Pool, and HTTP Settings to define how traffic is routed to backend servers.

  • Health Probe — Ensures that traffic is delivered only to healthy backend servers.

  • Gateway IP Configuration — Binds an application gateway to a specific subnet, ensuring proper internal communication.

Steps to configure Azure Application Gateway

  • Deploy virtual network
  • Deploy application gateway subnet
  • Deploy application gateway public IP
  • Associate gateway with subnet using gateway_ip_configuration block
  • Define app gateway frontend ports (80, 443) by using frontend_port block
  • Associate app gateway with public IP using frontend_ip_configuration block
  • Define backend pools with app services FQDNs by using backend_address_pool block
  • Define the way gateway communicates with backend via http_settings block
  • Add http and https listeners to the app gateway using http_listener block
  • Define routing rules to handle requests based on headers CN
  • Create a Cloudflare DNS record for the app gateway public IP and test connection

Related repositories

Infrastructure

  • Control node (SSH key authentication)
  • DB server (Password authentication -> then copy id to be executed)
  • Web server (Password authentication -> then copy id to be executed)
  • Windows DB server (RDP)
  • Windows Web server (RDP)

DNS

Servers

App gateway

DEV

QA

SSH configuration for Linux managed nodes

From control node execute:

Control node initial configuration (Linux)

  • Copy SSH key and configure permissions
  • Validate Python installation
    • git clone [email protected]:kolosovpetro/ansible-control-node.git
    • cd ansible-control-node
    • Run install_python.sh
  • Install Ansible
    • Run install_ansible.sh
  • Copy Ansible global configuration file ansible.cfg
  • Copy Ansible inventory file inventory/inventory.yaml
    • sudo cp inventory/inventory.ini /etc/ansible/inventory.ini
    • scp "inventory/inventory.ini" [email protected]:~/inventory.ini
    • ssh [email protected] "sudo cp ~/inventory.ini /etc/ansible/inventory.ini"
  • Update inventory file inventory/inventory.yaml if necessary
  • Check connection to Linux managed nodes
    • ansible-playbook ping.yml
  • Windows nodes require additional configuration

Managed nodes initial configuration (Windows)

  • Login to your Windows machines via RDP
  • Open PowerShell as Administrator
  • Copy script contents from Configure-Ansible-Host.ps1 to the terminal
  • Check connection to Windows managed nodes
    • ansible windows_servers -m win_ping

SSH connection commands (Linux managed nodes)

Ansible for Windows Docs

Links