feat(ansible): Add main playbook
This commit is contained in:
57
ansible/webserver-automation/playbooks/site.yml
Normal file
57
ansible/webserver-automation/playbooks/site.yml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
---
|
||||||
|
# Main playbook - Complete server setup
|
||||||
|
# Usage: ansible-playbook -i inventory/production playbooks/site.yml
|
||||||
|
|
||||||
|
- name: Setup all servers
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
gather_facts: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Display deployment information
|
||||||
|
debug:
|
||||||
|
msg: |
|
||||||
|
Deploying to: {{ inventory_hostname }}
|
||||||
|
Environment: {{ environment }}
|
||||||
|
Date: {{ ansible_date_time.iso8601 }}
|
||||||
|
|
||||||
|
- name: Configure common settings
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- role: common
|
||||||
|
tags: ['common', 'base']
|
||||||
|
|
||||||
|
- name: Setup web servers
|
||||||
|
hosts: webservers
|
||||||
|
become: true
|
||||||
|
serial: 1
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: firewall
|
||||||
|
tags: ['firewall', 'security']
|
||||||
|
|
||||||
|
- role: nginx
|
||||||
|
tags: ['nginx', 'webserver']
|
||||||
|
|
||||||
|
post_tasks:
|
||||||
|
- name: Verify web server is running
|
||||||
|
uri:
|
||||||
|
url: "http://{{ ansible_host }}"
|
||||||
|
status_code: 200
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
tags: ['verify']
|
||||||
|
|
||||||
|
- name: Final summary
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Display completion message
|
||||||
|
debug:
|
||||||
|
msg: |
|
||||||
|
✅ Deployment completed!
|
||||||
|
|
||||||
|
Servers: {{ ansible_play_hosts | length }}
|
||||||
|
Environment: {{ environment }}
|
||||||
Reference in New Issue
Block a user