Press "Enter" to skip to content

Add linux host in Ansible

bist 0

I am getting to learn Ansible and I liked it the first second I saw how simple this is. What I eventually want to achieve is to manage Windows clients and install software in a consistent way. Unattended. Chocolatey here I come. But first things first. Let’s start with a linux host.

 

So I assume that ansible is installed.

  1. Add the host name in /etc/hosts or if you have DNS online don’t bother. This needs to be done on the ansible host
  2. Add the host in the /etc/ansible/hosts file. Make sure you add it to a group. Groups can we made like this: [groupname]
  3. On the Client create a user. For example ansible:ansible. Then visudo and under the root directive add ansible ALL=(ALL) NOPASSWD:ALL
  4. Now on the ansible host su ansible -   No you need to copy the SSH key to the client server.  ssh-copy-id ansible@hostname.bist.local

You should be able to ssh into the client without passwords and becoming root should be seamless.

 

Try to execute a ansible command like ansible ubuntu -m setup

 

 

On a side note. You might need to install python in ubuntu. As this is not by default installed on 18.04

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.