Creating a playbook to perform system configuration tasks

Changing a system's configuration with Ansible isn't much more difficult than provisioning a new system.

Getting ready

For this recipe, we will need the following facts for the new host:

  • ntp_servers
  • dns_servers
  • dns_search

We'll also need to have a couple of templates to provision the following files:

  • /etc/logrotate.d/syslog
  • /etc/ntp.conf
  • /etc/ntp/step-tickers
  • /etc/resolv.conf

How to do it…

Now, we'll create the playbook to configure the system. Perform the following steps:

  1. Create a ~/playbooks/config.yml playbook with the following content:
    - name: Configure system hosts: all handlers: - include: networking.handlers.yml - include: ntp-client.handlers.yml tasks: - include: networking.tasks.yml - include: ...

Get Red Hat Enterprise Linux Server Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.