50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
---
|
|
- name: Deploy Nginx with load testing features on App1
|
|
hosts: 192.168.0.110
|
|
become: yes
|
|
gather_facts: yes
|
|
|
|
roles:
|
|
- role: nginx
|
|
|
|
tasks:
|
|
- name: Verify Nginx installation
|
|
uri:
|
|
url: "http://{{ ansible_default_ipv4.address }}"
|
|
status_code: 200
|
|
timeout: 10
|
|
register: nginx_check
|
|
until: nginx_check.status == 200
|
|
retries: 5
|
|
delay: 5
|
|
ignore_errors: yes
|
|
|
|
- name: Test API endpoints
|
|
uri:
|
|
url: "http://{{ ansible_default_ipv4.address }}{{ item }}"
|
|
status_code: 200
|
|
timeout: 5
|
|
loop:
|
|
- /api/test
|
|
- /api/metrics
|
|
register: api_test
|
|
ignore_errors: yes
|
|
|
|
- name: Display deployment result
|
|
debug:
|
|
msg: |
|
|
✅ Nginx with load testing deployed on {{ inventory_hostname }}!
|
|
🌐 Main page: http://{{ ansible_default_ipv4.address }}
|
|
📊 Status page: http://{{ ansible_default_ipv4.address }}/status
|
|
🔧 Test APIs:
|
|
- http://{{ ansible_default_ipv4.address }}/api/test
|
|
- http://{{ ansible_default_ipv4.address }}/api/slow
|
|
- http://{{ ansible_default_ipv4.address }}/api/error
|
|
- http://{{ ansible_default_ipv4.address }}/api/metrics
|
|
📈 Monitoring:
|
|
- Node metrics: http://{{ ansible_default_ipv4.address }}:9100/metrics
|
|
- Prometheus: http://192.168.0.105:9090
|
|
- Grafana: http://192.168.0.106:3000
|
|
|
|
🎯 Load testing interface ready with JavaScript controls!
|