In this blog I will be running remote commands from the ansible control box to my test ubtuno virtual machine.

sudo nano /etc/ansible/hosts
# add the below to the bottom of the hosts file, this is your managed node
[hosts]
test ansible_host=192.168.1.128 ansible_user=user

# This will copy the fingerprint of your ansible box to the remote vm
ssh-copy-id user@192.168.1.128
yes
user@192.168.1.128's password:

# This will run everything in the hosts file /etc/ansible/hosts
ansible all -m shell -a "ifconfig"

#This will only run anything under [hosts] in the /etc/ansible/hosts
ansible hosts -m shell -a "ifconfig"

ansible hosts -m shell -a "cat /etc/hosts"

Screen shots below

By Kad