Closed paulgration closed 4 years ago
Related to #256 and #647
Do the changes in https://github.com/theforeman/foreman-ansible-modules/pull/745 help you?
we've merged that branch now, could you have a look if that's sufficient for your usecase or not?
@evgeni this is great! I've tested the playbook in the original description above with the additional attributes (architecture
, operatingsystem
, media
and ptable
) and all seems to be working.
I haven't tried creating a host without assigning it to a host group as part of it's creation but it looks like everything is there now to support this?
Yes, you should be able to create a host completely without a hostgroup now.
Hey @pmgration wanted to check in if you had time to test without defining a hostgroup? I'd like to close this issue with "everything works for the user" ;)
Hi @evgeni yeah I've been able to add hostgroups, and hosts assigned to those hostgroups - I haven't tried adding hosts that aren't assigned to a hostgroup yet but from our discussion and the changes in #745 that should all be possible too - I'll check that later today but happy to have the issue closed
@evgeni I've tested creating a buildable host without it being assigned to a hostgroup so everything appears to be working as expected. Thanks!
Perfect, closing as happy customer then ;)
SUMMARY
Similar to #696 when creating a host in foreman (1.24.2) using the latest foreman-ansbile-modules (0.6.0) the host creation fails if all required parameters aren't present and some of these appear to be missing. With foreman-ansible-modules to add a managed host, the host needs to be part of a host group[1]. A host group created by the foreman web UI or foreman-ansible-modules can contain no settings other than a name, so when subsequently creating a host as part of this host group it doesn't inherit the following attributes and these aren't available in foreman_host of foreman-ansible-modules to specify them:
I believe it's reasonable to expect that multiple hosts in the same host group could have differing architectures/operating systems so it appears that both of these are missing from the foreman_host.
To make the host buildable, also requires:
So these are both missing from foreman_host too.
For info, adding the host to the same host group using the Foreman web UI also requires the
Media
,Partition Table
andRoot Password
fields to be completed/valid (this is enforced by the web UI).Generally there appears to be a bit of a mismatch between the required parameters for the foreman host creation API and the list of valid attributes in foreman-ansible-modules so the host creation attempt fails at the API with a 422 (Unprocessable Entity) HTTP response code when attributes are missing.
Foreman 1.24.2 API required attributes for host creation:
[1] This restriction doesn't seem to exist when using the Foreman web UI, it's possible to create a managed host without it being assigned to a host group (managed hosts shouldn't have to belong to a host group) and there are other, non-required, attributes missing in foreman-ansible-modules related to this.
ISSUE TYPE
ANSIBLE VERSION
KATELLO/FOREMAN VERSION
APYPIE VERSION
STEPS TO REPRODUCE
EXPECTED RESULTS
Domain, subnet, host group and host expected to be created
ACTUAL RESULTS
Domain, subnet, host group are created but the host isn't created, unless the
Architecture
andOperating system
are updated using Foreman web UI (or API) and the playbook is run again - not possible via foreman-ansbile-modules alone. To make the host buildable, also requires setting theMedia
andPartition Table
fields of the web UI.