Adding hosts to CML Ubuntu server /etc/hosts file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 02:35 PM
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?
- Labels:
-
Cisco Modeling Labs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 02:48 PM
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.
*** Please Rate All Helpful Responses ***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 01:27 PM - edited 01-22-2024 01:41 PM
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.
*** Please Rate All Helpful Responses ***
