diff --git a/ansible/webserver-automation/playbooks/site.yml b/ansible/webserver-automation/playbooks/site.yml new file mode 100644 index 0000000..d294c6c --- /dev/null +++ b/ansible/webserver-automation/playbooks/site.yml @@ -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 }}