Need Help on Foreman Host's having Dynamic IP's and Multiple Network Interfaces

Hello Team,

Our Agenda is to manage Ubuntu Machines Centrally (16 and 18 versions).

*We use Ansible callback plugin to onboard hosts to foreman which we started using recently before it we used to do this by installing puppet agent on hosts. The Ubuntu machines do not have static ip addresses, we run ansible playbook only once to onboard hosts. The problem here since we do not have static ips configured and no dns entries, if the ip address of host changes, we are doing remote execution on different machines rather than on actual host, the ip addresses will not update in foreman because we gather facts only once when on boarding.
– if we run ansible playbook again after host ip changes, foreman will add if that ip does not exists, also host with old ip also be there in foreman but it is not reachable unless ip is configured in other host.
Please suggest on how to get out of this issue?

*We have multiple network interfaces(wifi,eth1,eth2) present on hosts and ip’s configured on each interface. if wifi ip address taken as primary interface in foreman, we disable wifi-interface for some reason, then we will not be able to do remote execution on host since remote execution is allowed for only primary interface. Is there any options like if remote execution fails on primary interface, automatically switching over to secondary interface or next available interface and allows remote execution?

Thanks

Hello Team,

Could anyone help me out on these?

Thanks in Advance!!

Hello Folks,

Adding More info about Requirement:

We have multiple sites at different locations – Let say S1,S2 and S3 are the sites at different locations, we have ubuntu machines on all these sites S1,S2 and S3 where these ubuntu machines do not have static ip configured, probably ip will be taken from DHCP.

Onboarding ubuntu machines to Foreman: We take site wise dhcp scope subnet details and add these scope details in ansible inventory along with login details and enabled callback plugin. We had written a playbook to copy foreman-proxy user SSH key to all hosts. We will run this playbook against inventory, if play executed successfully on hosts, those hosts will be added to foreman.

Let say, in Site S1, we have dhcp scope details 192.168.1.1 to 192.168.1.50 and 192.168.2.1 to 192.168.2.50. first time when we run playbook, hosts H1,H2 and H3 in 192.168.1.1-254 scope,the hosts added to foreman with ip addresses as 192.168.1.2, 192.168.1.3 and 192.168.1.4.
After dhcp lease time exceeded or user reconnected to network, now the same hosts H1,H2 and H3 are in 192.168.2.1-254 scope and ipaddress of H1,H2 and H3 are 192.168.2.5, 192.168.2.6 and 192.168.2.7

In foreman, when we do remote execution on H1,H2 and H3 hosts, ultimately it will be failed since hosts H1,H2 and H3 having different ip address present at site S1.
So again we run ansible, then hosts H1, H2 and H3 will be added to foreman as 192.168.2.5, 192.168.2.6 and 192.168.2.7 – Now we have same host H1,H2, H3 twice for site S1 with different ip address in foreman.

How to avoid this duplication in foreman? and updating the ip addresses of hosts H1,H2 and H3 instead of adding them again?

How to manage the hosts having dynamic ip’s from foreman?

Thanks

There is no such option. Only one NIC can be marked as “remote execution” and that one is used. There is an option to use DNS name instead. But that’s about it.

@lzap Could you please suggest on hosts having dynamic ips?
Thanks

Honestly, I am not sure if Foreman is the sotware you want to use in this case. Foreman is inventory with provisioning and content capabilities. Foreman should be the “source of truth”, the thing that defines your NICs, IPs and DNS names. You take this from the other end, I think you will have hard time integrating everything.

No idea, I am sorry.

@lzap Thanks

What If we make a dns entry for these hosts and make resolvable from foreman server. Could we able to do manage(remote execution, web console) these hosts with hostname instead of ip address and can we avoid this duplication of hosts in foreman?

In this case if foreman not works, can you suggest us any other tools to manage ubuntu machines which are at sites (not only be a single tool, could also be a combination of multiple tools)?

Thanks

Looking in the codebase, it looks like ReX actually uses FQDN to connect to hosts by default, you can actually turn off this behavior with setting named ‘Connect by IP’ to use IP addresses. @aruzicka to confirm, but if you fix your DNS, it will work correctly.

Yes, exactly. It uses a hostname unless that setting is enabled. If that setting is enabled, it tries to pick an ip address from the hosts interfaces, if none is found it falls back to the hostname. It could be a way to go, but if you can get your DNS up and running properly, that would be a better way.

1 Like

@lzap @aruzicka Thanks a lot for your suggestions !!!

We can able to resolve the hosts from foreman server and set connect by ip in ReX to false.
We are able to do remote execution and access Web Console of hosts.

Thanks