Only root writes files in /etc, and in this lesson Ansible logs in as student.
Without the rights the copy module answers FAILED! and “Destination /etc not writable”. The -b option (--become, in the Wiki) runs the module on the machine through sudo, as root. student has sudo without a password, so nothing else is needed:
The machine Ansible runs on can also be described without SSH. The ansible_connection=local variable on a machine's line tells Ansible to run the module right here. That is how localhost is usually written down — so the controlling machine is configured the same way as the others.
Configure this machine without SSH
Ansible has to configure the very machine it runs on, without SSH. In ~/ansible-lab add a local group to the inventory with the machine localhost that Ansible reaches without SSH, and with an Ansible ad-hoc command put the file /etc/lab-motd on it with one line “Managed by Ansible”. Run the command once more and look at the answer.
Goals · 0 of 2
- Describe this machine in the inventory without SSH not done yet
- Put the file into /etc with an Ansible ad-hoc command not done yet