How Do You Run an Ansible Playbook?

Problem scenario
You want to run an Ansible playbook to push configuration changes down (e.g., transfer files to managed nodes). How do you do this?

Solution
Prerequisites
This assumes that you have set up Ansible. If you need directions for deploying an Ansible control server, see this posting. If you need directions for deploying a managed node after the central Ansible server has been set up, see this posting.

Procedures
1. Log into the Ansible control server.
2. Create a file called contint.yaml, and place this text inside it:

- hosts: all
  tasks:
  - copy:
      src: /tmp/good.txt
      dest: /tmp/foo.conf
      owner: ec2-user
      group: ec2-user
      mode: 0644

3. Run this command: ansible-playbook contint.yaml

Leave a comment

Your email address will not be published. Required fields are marked *