Assign hosts to subnets

hi,

I need to migrate a lot of hosts (600+) , source server puppet, no katello to a new server instance with katello and ansible. since i’m planning to set parameters on subnet base the hosts (interfaces) need to be assigned correctly. on the old server, maybe 20% of all hosts are assigned to subnets, all that I’ve created with foreman directly, but the rest is lacking this information

do you guys have a hammer script that does that for me? assign host interfaces to subnets, I can’t do it manually. /24 would be sufficient for me, don’t need sophisticated subnet logic :slight_smile:

thanks in advance!

cheers Daffi

Version information:

ansible-collection-theforeman-foreman-2.1.2-1.el7.noarch
ansible-collection-theforeman-operations-0.3.0-1.el7.noarch
ansiblerole-foreman_scap_client-0.2.0-1.el7.noarch
foreman-2.5.3-1.el7.noarch
foreman-cli-2.5.3-1.el7.noarch
foreman-debug-2.5.3-1.el7.noarch
foreman-dynflow-sidekiq-2.5.3-1.el7.noarch
foreman-installer-2.5.3-1.el7.noarch
foreman-installer-katello-2.5.3-1.el7.noarch
foreman-postgresql-2.5.3-1.el7.noarch
foreman-proxy-2.5.3-1.el7.noarch
foreman-release-3.0.0-1.el7.noarch
foreman-selinux-2.5.3-1.el7.noarch
foreman-service-2.5.3-1.el7.noarch
foreman-vmware-2.5.3-1.el7.noarch
katello-4.1.3-1.el7.noarch
katello-certs-tools-2.7.3-1.el7.noarch
katello-client-bootstrap-1.7.6-1.el7.noarch
katello-common-4.1.3-1.el7.noarch
katello-debug-4.1.3-1.el7.noarch
katello-default-ca-1.0-1.noarch
katello-repos-4.1.3-1.el7.noarch
katello-selinux-4.0.0-1.el7.noarch
katello-server-ca-1.0-1.noarch
pulp-katello-1.0.3-1.el7.noarch
qpid_router_katello_agent-qpid-router-client-1.0-1.noarch
rubygem-foreman_maintain-0.8.6-1.el7.noarch
tfm-rubygem-foreman_ansible-6.3.4-1.fm2_5.el7.noarch
tfm-rubygem-foreman_ansible_core-4.1.2-1.fm2_5.el7.noarch
tfm-rubygem-foreman_openscap-4.3.3-1.fm2_5.el7.noarch
tfm-rubygem-foreman_remote_execution-4.5.6-1.fm2_5.el7.noarch
tfm-rubygem-foreman_remote_execution_core-1.4.8-1.el7.noarch
tfm-rubygem-foreman-tasks-4.1.5-1.fm2_5.el7.noarch
tfm-rubygem-foreman-tasks-core-0.3.6-1.fm2_5.el7.noarch
tfm-rubygem-hammer_cli_foreman-2.5.1-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_ansible-0.3.4-1.fm2_5.el7.noarch
tfm-rubygem-hammer_cli_foreman_bootdisk-0.3.0-2.el7.noarch
tfm-rubygem-hammer_cli_foreman_remote_execution-0.2.1-2.fm2_5.el7.noarch
tfm-rubygem-hammer_cli_foreman_tasks-0.0.15-2.fm2_5.el7.noarch
tfm-rubygem-hammer_cli_katello-1.1.2-1.el7.noarch
tfm-rubygem-katello-4.1.3-1.el7.noarch

Would be creating some hostgroups and then assigning them based on facts during creation by the report coming in be an option? Then https://github.com/theforeman/foreman_default_hostgroup could be a solution, but I have not used it for a while.

thanks for the reply, I have a lot of hostgroups, but hostgroups define some kind of purpose in my case, for example: postgres hosts can be in different subnets. depending on the subnet I might define a different syslog server or mail gateway, so I need a correct subnet association.
this association is done automatically when I create the system with foreman, because I define it there. but existing hosts or newly added puppet/ansible hosts, even when they are in a defined subnet range are not associated automatically.