You will see tutorial explaining that you need a host file located at /etc/ansible/hosts, that you need to connect with ssh.
But what do you really want to start with?
Experiment locally, on your local machine. And that is not described in these tutorials :(
Luckily, I found a blog @mechanicalfish which explains exactly how to start.
The Shortest Path To Using Ansible
A One-Line Configuration
$ ansible all -i 'localhost,' -c local -m ping
Let’s take our one-liner apart. Could we make it shorter or simpler?
- ansible is the command which runs one task at a time all tells Ansible to run this task on all the hosts in the inventory.
- -i localhost, …is a trick, to avoid the need to make an inventory file. -i means “here is the pathname of the inventory file”. But ansible has a poorly-documented bonus feature: Instead of a path, we can choose to provide a list of host names, each of which names a computer on the network. And our list can have just one entry, localhost. (The weird extra comma after localhost is vital; do not leave it out. It tells Ansible that this is a list of hosts and not a pathname.)
- -c local is shorthand for --connection=local. It tells Ansible not to try to use SSH to contact the hosts, but to run tasks on our local computer instead. Ansible uses SSH by default, because usually it’s running tasks on faraway machines in the cloud. However, it’s common to encounter problems when connecting to your own computer via SSH, and fixing these problems without impairing your security is tricky and not worth the effort.
- Finally, -m means “use this Ansible module”, and ping is the name of the module. The ping module contacts the host and proves that it’s listening.
I would recommend the reading of the post, as there are more details in it :).
Thank you Mechanical Fish for this post.
Once this is read I would check the following tutorial by black sail division
Part 1
Part 2
Part 3
No comments:
Post a Comment