oliverdavies.uk/content/node.8a88f79c-3593-4316-8308-8bbc9622d0ec.yml

84 lines
4.5 KiB
YAML

uuid:
- value: 8a88f79c-3593-4316-8308-8bbc9622d0ec
langcode:
- value: en
type:
- target_id: daily_email
target_type: node_type
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
revision_timestamp:
- value: '2025-05-11T09:00:55+00:00'
revision_uid:
- target_type: user
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
revision_log: { }
status:
- value: true
uid:
- target_type: user
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
title:
- value: 'Deploying applications with Ansible'
created:
- value: '2022-09-06T00:00:00+00:00'
changed:
- value: '2025-05-11T09:00:55+00:00'
promote:
- value: false
sticky:
- value: false
default_langcode:
- value: true
revision_translation_affected:
- value: true
path:
- alias: /daily/2022/09/06/deploying-applications-with-ansible
langcode: en
body:
- value: |
<p>The last few days' emails have been about using Ansible to create and configure infrastructure, but it can also be used to deploy application code.</p>
<p>The simplest way being that an artifact is built locally - e.g. a directory of static HTML pages from a static site generator - and uploaded onto the server, and for this you could use Ansible's <code>synchronize</code> module.</p>
<p>It's a wrapper around the <code>rsync</code> command and makes it as simple as specifying <code>src</code> and <code>dest</code> values for the local and remote paths.</p>
<p>For more complicated deployments, I like to use a tool called Ansistrano - an Ansible port of a deployment tool called Capistrano.</p>
<p>It creates a new directory for each release and updates a <code>current</code> symlink to identify and serve the current release, and can share files and directories between releases.</p>
<p>As well as being able to configure settings such as the deployment strategy, how many old releases to keep, and even the directory and symlink names, there are a number of hooks that you can listen for an add your own steps as playbooks so you can install dependencies, generate assets, run migrations, or rebuild a cache as part of each deployment.</p>
<p>If you're running your applications in Docker, you could use Ansible to pull the latest images and restart your applications.</p>
<p>For more information and examples, I've given a talk on Ansible at various PHP events, which covers some Ansible basics before moving on to <a href="/talks/deploying-php-ansible-ansistrano">deploying applications with Ansistrano</a>.</p>
<hr />
<p>Want to learn more about how I use Ansible? <a href="/ansible-course">Register for my upcoming free email course</a>.</p>
format: full_html
processed: |
<p>The last few days' emails have been about using Ansible to create and configure infrastructure, but it can also be used to deploy application code.</p>
<p>The simplest way being that an artifact is built locally - e.g. a directory of static HTML pages from a static site generator - and uploaded onto the server, and for this you could use Ansible's <code>synchronize</code> module.</p>
<p>It's a wrapper around the <code>rsync</code> command and makes it as simple as specifying <code>src</code> and <code>dest</code> values for the local and remote paths.</p>
<p>For more complicated deployments, I like to use a tool called Ansistrano - an Ansible port of a deployment tool called Capistrano.</p>
<p>It creates a new directory for each release and updates a <code>current</code> symlink to identify and serve the current release, and can share files and directories between releases.</p>
<p>As well as being able to configure settings such as the deployment strategy, how many old releases to keep, and even the directory and symlink names, there are a number of hooks that you can listen for an add your own steps as playbooks so you can install dependencies, generate assets, run migrations, or rebuild a cache as part of each deployment.</p>
<p>If you're running your applications in Docker, you could use Ansible to pull the latest images and restart your applications.</p>
<p>For more information and examples, I've given a talk on Ansible at various PHP events, which covers some Ansible basics before moving on to <a href="/talks/deploying-php-ansible-ansistrano">deploying applications with Ansistrano</a>.</p>
<hr>
<p>Want to learn more about how I use Ansible? <a href="/ansible-course">Register for my upcoming free email course</a>.</p>
summary: null
field_daily_email_cta: { }