oliverdavies.uk/content/node.1f3f5a8f-412f-4da1-8e7a-4303962079d1.yml

81 lines
4.5 KiB
YAML
Raw Normal View History

2025-07-10 00:14:12 +01:00
uuid:
- value: 1f3f5a8f-412f-4da1-8e7a-4303962079d1
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: 'Using Ansible for server configuration'
created:
- value: '2022-09-04T00: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/04/using-ansible-for-server-configuration
langcode: en
body:
- value: |
<p><a href="/archives/2022/09/03/creating-infrastructure-with-ansible">In yesterday's email</a>, I described how to set up a blank server with Ansible.</p>
<p>Now that we've done that, it needs to be configured.</p>
<p>Once the servers IP address or hostname has been added to a <code>hosts.ini</code> file, you can run ad-hoc commands against it - such as <code>ansible all -i hosts.ini -m ping</code> to run Ansible's <code>ping</code> module on all of the hosts in your inventory and check that you can connect to them.</p>
<p>Another useful one that you can use is the <code>shell</code> module, that runs ad-hoc run commands on each host. If you need to check the uptime of each of your servers, run <code>ansible all -i hosts.ini -m shell -a uptime</code>. You can replace the last argument with any other shell command that you need to run, like <code>df</code> or <code>free</code>.</p>
<p>Running commands in this way is great for getting started, for routine maintenance, or an emergency free disk space check, but for more complex tasks like configuration management, using playbooks is the better option. They are YAML files that contain lists of tasks that Ansible will run through and execute in order.</p>
<p>If you have a group of related tasks, such as for installing a piece of software, then you can combine them into roles. In fact, Ansible Galaxy has thousands of pre-built collections and roles that you can download, include in your playbooks, configure, and run.</p>
<p>Very quickly, you can get a full stack installed and configured - ready to serve your application.</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: |
2025-07-16 12:00:00 +01:00
<p><a href="/archives/2022/09/03/creating-infrastructure-with-ansible">In yesterday's email</a>, I described how to set up a blank server with Ansible.</p>
2025-07-10 00:14:12 +01:00
<p>Now that we've done that, it needs to be configured.</p>
<p>Once the servers IP address or hostname has been added to a <code>hosts.ini</code> file, you can run ad-hoc commands against it - such as <code>ansible all -i hosts.ini -m ping</code> to run Ansible's <code>ping</code> module on all of the hosts in your inventory and check that you can connect to them.</p>
<p>Another useful one that you can use is the <code>shell</code> module, that runs ad-hoc run commands on each host. If you need to check the uptime of each of your servers, run <code>ansible all -i hosts.ini -m shell -a uptime</code>. You can replace the last argument with any other shell command that you need to run, like <code>df</code> or <code>free</code>.</p>
<p>Running commands in this way is great for getting started, for routine maintenance, or an emergency free disk space check, but for more complex tasks like configuration management, using playbooks is the better option. They are YAML files that contain lists of tasks that Ansible will run through and execute in order.</p>
<p>If you have a group of related tasks, such as for installing a piece of software, then you can combine them into roles. In fact, Ansible Galaxy has thousands of pre-built collections and roles that you can download, include in your playbooks, configure, and run.</p>
<p>Very quickly, you can get a full stack installed and configured - ready to serve your application.</p>
<hr>
2025-07-16 12:00:00 +01:00
<p>Want to learn more about how I use Ansible? <a href="/ansible-course">Register for my upcoming free email course</a>.</p>
2025-07-10 00:14:12 +01:00
summary: null
field_daily_email_cta: { }