--- # 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: |
Version: {{ app_version }}
Server: {{ inventory_hostname }}
Environment: {{ environment }}