ansible Getting started with ansible Hello, World

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Create a directory called ansible-helloworld-playbook

mkdir ansible-helloworld-playbook

Create a file hosts and add remote systems how want to manage. As ansible relies on ssh to connect the machines, you should make sure they are already accessible to you in ssh from your computer.

192.168.1.1
192.168.1.2

Test connection to your remote systems using the Ansible ping module.

ansible all -m ping -k

In case of success it should return something like that

192.168.1.1| SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
192.168.1.2| SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

In case of error it should return

192.168.1.1| UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh.", 
    "unreachable": true
}

Test sudo access with

ansible all -m ping -k -b


Got any ansible Question?