cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
355
Views
0
Helpful
2
Replies

Adding hosts to CML Ubuntu server /etc/hosts file

ramirezcyrus
Level 1
Level 1

The /etc/hosts file is a readonly file. Is there any way I can create another hosts file to add devices to in order to complete an ansible lab? 

2 Replies 2

liviu.gheorghe
Spotlight
Spotlight

Hello @ramirezcyrus ,

If your user is a member of the sudo group, which should be true for a CML Ubuntu server, you can edit the file /etc/hosts using the sudo command:

sudo nano /etc/hosts

or

sudo vi /etc/hosts

The OS will ask you again for your password and after you supply it, you can edit the file in the editor of your choice.

 

Regards, LG
*** Please Rate All Helpful Responses ***

liviu.gheorghe
Spotlight
Spotlight

By default, Ansible uses the inventory file located in /etc/ansible/hosts

You can use any inventory file you want, but in this case you have to provide the path to the inventory file with the -i parameter when running Ansible commands.

It's better to use the default ansible inventory file in /etc/ansible/hosts and leave the /etc/hosts for it's intended purpose of name resolution.

Regards, LG
*** Please Rate All Helpful Responses ***