feat(ansible): Add deployment playbook

This commit is contained in:
Claude AI
2026-01-06 14:42:59 +00:00
parent 6636fda5d2
commit 99e2a2daf0

View File

@@ -0,0 +1,83 @@
---
# Application deployment playbook
# Usage: ansible-playbook -i inventory/production playbooks/deploy.yml
- name: Deploy application
hosts: webservers
become: true
serial: 1
vars:
app_version: "{{ app_version | default('latest') }}"
tasks:
- name: Display deployment info
debug:
msg: |
Deploying {{ app_name }} version {{ app_version }}
To: {{ inventory_hostname }}
tags: ['always']
- name: Create application directory
file:
path: "{{ app_dir }}"
state: directory
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: '0755'
tags: ['setup']
- name: Deploy sample HTML
copy:
dest: "{{ app_dir }}/index.html"
content: |
<!DOCTYPE html>
<html>
<head>
<title>{{ app_name }}</title>
<style>
body {
font-family: Arial;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
padding: 50px;
background: rgba(255,255,255,0.1);
border-radius: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>🚀 {{ app_name }}</h1>
<p>Version: {{ app_version }}</p>
<p>Server: {{ inventory_hostname }}</p>
<p>Environment: {{ environment }}</p>
</div>
</body>
</html>
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: '0644'
tags: ['deploy']
- name: Restart Nginx
service:
name: nginx
state: restarted
tags: ['restart']
- name: Verify deployment
uri:
url: "http://{{ ansible_host }}"
status_code: 200
delegate_to: localhost
become: false
tags: ['verify']