-
Notifications
You must be signed in to change notification settings - Fork 358
Embedded Ansible in devel mode
Or, what to do when you just need the embedded ansible role to work in development setup. Taken from https://github.com/ManageIQ/guides/pull/276#issuecomment-538070129.
-
Start a development server:
$ bin/rails s
-
Enable the Embedded Ansible role on the settings page
-
From the console, run the following:
$ bin/rails c irb> ManageIQ::Providers::EmbeddedAnsible.seed irb> MiqServer.my_server.reload_settings # just incase irb> MiqServer.my_server.sync_assigned_roles irb> MiqServer.my_server.monitor_server_roles irb> MiqRegion.my_region.role_active?('embedded_ansible') #=> true
Well, the tl;dr for the "long answer" since bin/rails s
doesn't run a MiqServer
instance which is in charge of both seeding the EmbeddedAnsible
data and setting up server roles.
The methods specifically that are locking you out are found here:
Specifically:
!MiqRegion.my_region.role_active?('embedded_ansible')
ManageIQ::Providers::EmbeddedAnsible::Provider.count.zero?
Each of those are described below:
So seeding for EmbeddedAnsible
is located here, and that will get triggered by lib/evm_database.rb
here (which is included as part of the [OTHER_SEEDABLE_CLASSES][]
). This is triggered on server start by the [MiqServer.start][]
, so this explains why you didn't see this when running a local server since MiqServer.start
is never triggered when doing
$ bin/rails s
So above, I have simulated that by just calling the seed method directly:
ManageIQ::Providers::EmbeddedAnsible.seed
I was initially under the impression that activating the role actually enabled this seeding, but that is I guess not the case. However, I admittedly spent way to much time trying to determine that wasn't the case...
So this part also took a bit to figure out...
Again, this is something that is triggered by the MiqServer
, and it is part of the monitor_loop
:
This does eventually call the role balancing code and activates the needed roles, but it requires using the role data from the "default roles" from the settings, which isn't set here.
This is set and modified via the ops UI, and updates from there eventually trigger this method:
Which will reload the settings value that has now been updated via the Ops UI. This gets synced to the MiqServer
instances as part of the [monitor_workers][]
call, which eventually triggers .sync_assigned_roles
in [sync_needed?][]
.
.sync_assigned_roles
will eventually call [MiqServer#role=][]
to create the AssignedServerRole
records to the server, but doesn't activate them.
Note: Up until a little over a week ago, #role=
was the only method, but someone (adam) decided to change it to make this explanation even more verbose than it needed to be...
So the MiqServer#monitor_server_roles
roles is then in charge of just that, and will activate any of the created roles that need to be activated.
At this point, after these three lines have been called:
MiqServer.my_server.reload_settings # just incase
MiqServer.my_server.sync_assigned_roles
MiqServer.my_server.monitor_server_roles
MiqRegion.my_region.role_active?('embedded_ansible')
should now return true
and the UI should work as expected.
Should this be much more straight forward in development mode? Yes Do I have an idea how we would go about doing that? No
But hopefully, for @himdel and others, this explanation gives insight into the "why", and we can determine the "how" for the above from that.