-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded Ansible setup guide #276
Conversation
|
||
* Debian: `/etc/postgresql/9.6/main/` | ||
* Fedora: `/var/lib/pgsql/data/` | ||
* MacOSX: `/usr/local/var/postgres/` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would imagine these would depend heavily on where you installed the package from.
For example I'm using Fedora and my postgresql.conf
file is in /var/lib/pgsql/9.5/data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this is probably more portable.
$ psql -d postgres -c 'show config_file'
config_file
-----------------------------------------
/var/lib/pgsql/9.5/data/postgresql.conf
(1 row)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except then we need the right invocation for each system :)...
$ psql -d postgres -c 'show config_file'
ERROR: must be superuser to examine "config_file"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll just add a mention that these dirs may wary, and that you may have some luck running that command, WDYT?
The idea was mostly so that people have a place to start looking, it will always depend on the current version, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, added a note about these depending on other stuff, and a note that you can try running that command.
Make sure your `pg_hba.conf` contains: | ||
|
||
``` | ||
host all all 172.17.0.1/24 md5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this subnet is the same for all docker installations.
Maybe an explicit address isn't a good idea here. I would say instead to allow connections from the subnet used by the docker0
interface.
For example, ip a
shows this for me, but that gateway address might not be the same for everyone.
docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:3a:94:df:ba brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a note on running ip addr show dev docker0
, thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe these postgresql.conf
and pg_hba.conf
changes should be made to the developer setup guide with a note that you'll only need them if you want to use embedded ansible.
``` | ||
|
||
|
||
Ensure your DB user (the one in `config/database.yml`) has `superuser` rights.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be specified here as this is suggested in the main developer setup document
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep it just to make sure :). It surprised me so it could surprise more people, and ... assuming every devel has removed any security from their postgres install is probably wrong, even though those instructions mention it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be specified here as this is suggested in the main developer setup document
Well I don't have it that way. Security is one of the reasons.
This setup adds more stuff that depends on the superadmin config?
I don't think we should be doing that and I definetly agree that if it's really needed we write it here (again).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setup adds more stuff that depends on the superadmin config?
Unfortunately the worker needs to create a DB and a role, so yes. :(
Agreed it's a bad idea, in the gitter discussion @Fryguy mentioned this should be something that should be optional for the more exotic setups ... but for now we seem to be stuck with it, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, you can't rake evm:db:reset
either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you run differently then the default guides, you're going to have issues because we can't know how you diverged from the guides. Please either change the default guides to be "right", include sensible alternatives in the guides, or use the defaults. It's hard enough to maintain these guides when people use the defaults, if they don't use the defaults, the guides become stale and it's easy to accidentally break someone else's setup.
@himdel : thank you for taking the time to do this work. I think that in the future we should not merge PRs with functionality that cannot be setup for testing (and the setup is not explained) in the PR. I mean if special steps are needed to review a PR the steps should be publically available so that anyone can test and review and work with the PR. |
|
||
Your PostgreSQL must be configured to allow connections from the docker container, so that AWX can connect to manageiq's database. | ||
|
||
Your ManageIQ DB user (the one in `manageiq/config/database.yml`) must have the `SUPERUSER` privilege (or at least needs to be able to create roles and databases). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's already a requirement of the development setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #276 (comment)
Nobody who knows about DB security follows these intstructions precisely :).
|
||
### Dependencies | ||
|
||
You need docker. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add any more than this. Different platforms have it packaged with their native package manager otherwise Docker has instructions for installation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we needed to find out how to do this on a mac. I can either throw this info away, or include it in the guide :).
Since many of our devels use macs, I think this is valuable :).
Your ManageIQ DB user (the one in `manageiq/config/database.yml`) must have the `SUPERUSER` privilege (or at least needs to be able to create roles and databases). | ||
|
||
|
||
Config file locations (where to expect it): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, do we need this? It's going to be different for every platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, we can make it easy by giving people info they'll probably need, or we can tell them to go looking.
If you're willing to answer all the questions from people trying to follow the document, I'm willing to remove it :).
``` | ||
|
||
|
||
Ensure your DB user (the one in `config/database.yml`) has `superuser` rights.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, you can't rake evm:db:reset
either?
If you've already set up an AWX instance this way and want to clean it up: | ||
|
||
``` | ||
psql -d postgres -c 'DROP DATABASE awx' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably enhance rake evm:db:reset
to handle these for us.
In both cases, you may also need to clean up the old authentications (in Rails console): | ||
|
||
``` | ||
db = MiqDatabase.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should probably be cleaned up on provider destroy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should.. but aren't :).
I had to do this to get it working, so IMHO this needs to be in the guide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like a provider bug we should fix. I'm fine with keeping these steps but open an issue and link to the issue so we can circle back and remove this if and when it's fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> created ManageIQ/manageiq#16678
|
||
``` | ||
db = MiqDatabase.first | ||
db.authentication_type('ansible_secret_key').delete # db.ansible_secret_key.delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, shouldn't these be destroy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
providers/embedded_ansible.md
Outdated
|
||
### Procfiles | ||
|
||
Under your `manageiq/` directory, create these 2 files: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this information be in Procfile.example instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless of it's presence in Procfile.example
, this needs to be here too, so that people know which lines to uncomment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With ManageIQ/manageiq#16679 merged, can this just be a pointer to that now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
### Setting it up | ||
|
||
* configure your server to enable the ansible role (from Rails console): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you should be able to rake evm:start
and turn the role on. Right @carbonin ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never run evm:start
and don't really intend to. That's simply not how UI does it..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@himdel If that's the case, there's some things you just won't be able to do in the UI. I would not expect all features on the appliance to be feasible or desirable in a rails server process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know which? So far, everything seemed to work...
But, as long as this is mostly around refresh or things like that I think that's perfectly acceptable - at least, I have not needed to evm:start
for any PR I've reviewed in the last year, so.. :)
At least, still better than that "Embedded Ansible not supported, deal with it" :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@himdel replication, server failover, various platform/provider specific things such as scanning vms/instances on various providers. We will try to make things easier if we can but at some point we have to say it's too much effort and frankenstein code if there's an easy workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrafanie Ah, perfect, thanks! :) I don't think we get many UI PRs dealing with those things.
I agree that when you want to test replication, etc., you need to run the whole app.
But this mostly is so that every member of the team can actually test embedded ansible PRs in their devel setups, and for that I think this is OK :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I long ago accepted that there's just some things that are easier to let run on appliances. Thanks for questioning this because if there are easy changes to do, we should do them. With that said, though we have to be careful not to add too much hard to maintain hackery. At some point, we'll need to step back, measure the size of each yak and see if it's worth shaving.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed there.. but.. if the UI team can't run code needed to merge PRs, we would literally waste hours on reviews, so... balance :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need to run most PRs locally before merge, that sounds like the problem in the workflow. The only ones I ever run manually on an appliance are ones where tests would be brittle or even useless since they'd require mocks around everything, such as running system commands in ruby and testing some side effect much later (black console partitioning, etc.)
I never tried. What does it do? |
@bdunne As far as I can tell ... If that's so... nobody can use it :). Not if you want to keep your data :). So no, not a solution for people trying to get embedded ansible working in devel mode, no :). |
@himdel Right, it's a replacement for |
@bdunne So I'd assume we can't use it in the guide :). The intended audience for this document is essentially:
(or "there's a PR touching embedded ansible I need to write" :)) Anything that removes my data is probably not for everybody :) |
LOL I think I use it daily. |
Seems the typical workflow on the UI is very different to the backend. For most UI developers a database with all the important types of entities populated is a precious resource that is shared and passed from one dev to another. |
This is fine and hopefully switching branches isn't too much of a hassle with that flow. Whatever gets the job done but clearly we have completely different perspectives. Please open issues or PRs when there's contamination such as the provider destroy not removing authentications since those of us using Is there are a document that illustrates the differences between the current guides and what is done in the UI workflow? |
It depends. What I do is keep several databases and switch between the databases as I switch branches. Especially between releases.
I am not aware of such document. And there's not that much difference. Many UI people keep databases and switch between databases. And some use more secure database authorization configuration. But @himdel, @ZitaNemeckova and @romanblanco might know more about such differences as they go throught the setup with students. |
@martinpovolny We don't have anything special for students, that I'd be aware of. |
The only difference that wasn't mentioned here already that I'm aware of - most of us don't use |
Ping @bdunne ... looks like this is waiting on you.. Anything else needs to be fixed here? |
ping @bdunne ? |
|
||
``` | ||
# redirect local 54321 to docker-machine - otherwise, localhost:54321 doesn't work | ||
docker-machine ssh default -L 54321:127.0.0.1:54321 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn’t it be better to set up a proper port forwarding in VirtualBox? This way it wouldn’t be necessary to keep the SSH session open. It’d be a less hacky solution too.
See https://stackoverflow.com/questions/32174560/port-forwarding-in-docker-machine
You’d need to run something like this
VBoxManage modifyvm "default" --natpf1 "awx,tcp,127.0.0.1,54321,,54321"
or you can set it up in the VirtualBox GUI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds better, how would you do that so that it only affects the docker machine and not other VirtualBox machines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setting is machine-specific. The default
there in the command is a name of the Docker Machine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mentioned as an alternative
I feel like this should be merged, and any corrections or updates that need to be made can be done in separate PR's. I get that the UI team has a different workflow from the backend folks, but I think we can adapt and/or tuit how we want to do those bits. Or update the doc later. Otherwise this seems like it will languish. |
Rebased, updated to use I can no longer vouch for any of those instructions to be current and accurate though. |
I know that certain teams (not just the UI) have somewhat different workflows and use cases and I have no problem with that. People should follow whatever workflow is most productive for them.
|
I respectfully disagree, because that's not how you use the documentation. The intended audience here was: I'm already a UI developer, and need to get ansible working. Removing the info about databases will force everybody to have to look up some other piece documentation. I think if you want the documentation simple, the process needs to be simple as well. It's not. For example: But as long as we need people who use macs to be able to set up ansible, we need to document everything they will need to do. Otherwise, this guide will be:
In other words, I believe the documentation would be completely useless without the details :). At the same time, I'd really love to not have to document all those things. (Or we need to exclusively hire people who all have experience configuring postgres, experience using docker, experience setting SNAT/DNAT/some kind of tunels, and experience setting up ansible.) |
@himdel : I could use a working Ansible setup for a PR I am working on. Going to test your Guide. |
Thanks :) Just heads up, I'm not sure if this will be useful for much longer, as far as I know there's no AWX in 5.11, |
Cool and is there a way to test? |
Maybe @carbonin knows more.. I'm not sure ansible runner is even ready yet, I don't see any PRs. |
Yeah, @NickLaMuro and I are hoping to get the first pass in soon. I'm also trying to ensure that everything works locally as long as you have |
You can watch ManageIQ/manageiq#18687 for status. That's the first pass on runner. |
Thanks!!! I'd love to be able to live without docker in development :) |
For what it is worth, ManageIQ/manageiq#18687 is about 3 tests away from passing, so we are pretty close. Also, @Fryguy had some primitive steps for installing So you could possibly use that as a jumping off point for the re-working of this guides PR. |
I just added an |
@himdel The new embedded ansible is done, and ivanchuk-1 release is right around the corner. Would you like to revamp this PR or close it? Whichever you prefer. |
Closing, this may still be useful as-is if we need to debug embedded ansible pre-ivanchuk, |
As for the new thing, here's what I figured so far:
@NickLaMuro any ideas there please? |
@himdel huh, that is a bit surprising, but I have almost exclusively been running/testing this on an appliance since I don't want to jack up my machine by running some playbook inadvertently. I will look into this this morning, but you only really should need |
Thanks Nick :) I tried restarting the server too, but still, (a |
@himdel oh crap... I just realized I have left this for a week now with no response... sorry! So, I don't have a firm "this will fix it" but something you might be able to do is run the server with "rake evm:start" and let that run for a bit. My guess is it should run though some of the code here: And would most likely handle what is needed to enable the role, but not positive. I still haven't figured out what triggers the seeding when a role is activated, which is why I am not able to give you a Note: I was looking into this, but I didn't really have anything concrete to share, and still don't think this is a good solution either, hence the radio silence. |
Thanks @NickLaMuro, no problem, a week is beneath my threshold really :) Right now, the server claims embedded ansible is on in Server Settings, ( |
When running as |
So, sounds like the issue is that |
Maybe ManageIQ/manageiq#19328 would help your workflow in regards to setting the assigned roles and activating them. I can't tell if you're running this only in bin/rails server or another way. But, if it's rails server, putting the lines from that PR to assign the roles and activate them could possibly be used here |
Quick Instructions
Long Answer (WTF is going on here)Well, the tl;dr for the "long answer" since The methods specifically that are locking you out are found here: Specifically:
Each of those are described below: SeedingSo seeding for
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... Server rolesSo this part also took a bit to figure out... Again, this is something that is triggered by the 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
Note: Up until a little over a week ago, So the 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
Should this be much more straight forward in development mode? Yes But hopefully, for @himdel and others, this explanation gives insight into the "why", and we can determine the "how" for the above from that. |
Mostly expanded from https://gist.github.com/carbonin/8cfd24906d3c1513c5b91736226f0007
This adds a guide to enable embedded ansible in devel mode, using
DockerEmbeddedAnsible
which sets up a local awx instance under docker.Cc @carbonin , @martinpovolny , @ZitaNemeckova