Skip to content

Example 3

hosts.yml

centos:
  hosts:
    provisioner:
      ansible_connection: local
    centos1:
      ansible_host: '192.168.77.22'
      ansible_port: 2345
ubuntu:
  hosts:
    ubuntu1:
      ansible_host: '192.168.77.23'

Tip

The copy module enables the user to copy files from the provisioner to the remotes. Check out the module's official documentation or run

ansible-doc copy

Create an empty file and copy it to the remote hosts home directories

touch test.txt
ansible all -m copy -a 'src="test.txt" dest="/home/vagrant/"'

Bonus round

Create a message of the day (MOTD) for the SSH server on centos1. The contents of the message should be located in /etc/motd.