K
K
kalamyrka2019-05-13 20:55:14
Xubuntu
kalamyrka, 2019-05-13 20:55:14

How to parse /etc/hosts file in ubuntu?

In general, there is a task like:
Write a bash script (which will run on the selected virtual machine) that does the following: on all virtual machines (network nodes), you need to remotely install a software deb package (which is present only on the selected machine), the name of which should be passed to the script as a parameter on the command line.
Clarifications.
The list of hosts (virtual machines) is specified in the /etc/hosts file. From it the script should take IP addresses. As a package, you can take any uninstalled package from the OS distribution. As a way to remotely control and transfer a file, it is possible to use the ssh service. The script in the course of its work should not issue any requests to the user.
Almost everything is ready except for interacting with the hosts file. I just can't find the command by which these ip addresses should be taken from the file and used by the script, and the condition does not allow writing them manually all the time. If possible, write in detail. I'm new to this business and there's a lot I don't know. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2019-05-13
@inoise

Seems like a task for perverts. Invented Ansible. And to store the configuration of managed machines in /etc/hosts is wildness

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question