Last active
December 8, 2017 13:22
-
-
Save carbonin/8cfd24906d3c1513c5b91736226f0007 to your computer and use it in GitHub Desktop.
Run embedded ansible locally using Foreman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # create Procfile.ansible with this line | |
| ansible: ruby lib/workers/bin/run_single_worker.rb EmbeddedAnsibleWorker | |
| # create Procfile.workers with these lines (the -e option should be whatever the provider id is in your database once it is created) | |
| generic: ruby lib/workers/bin/run_single_worker.rb MiqGenericWorker | |
| embedded_ansible_refresh: ruby lib/workers/bin/run_single_worker.rb -e 1 ManageIQ::Providers::EmbeddedAnsible::AutomationManager::RefreshWorker | |
| embedded_ansible_event: ruby lib/workers/bin/run_single_worker.rb -e 1 ManageIQ::Providers::EmbeddedAnsible::AutomationManager::EventCatcher | |
| # From a clean environment | |
| psql -d postgres -c 'DROP DATABASE awx' | |
| psql -d postgres -c 'DROP ROLE awx' | |
| bin/rake evm:db:reset | |
| bin/rake db:seed | |
| # set up server roles in rails console | |
| server = MiqServer.my_server(true) | |
| server.role = "embedded_ansible,ems_inventory,ems_operations,event" | |
| server.activate_roles(%w(embedded_ansible ems_inventory ems_operations event)) | |
| server.save! | |
| # in one terminal | |
| bin/rails s | |
| # in another terminal | |
| foreman start -f Procfile.ansible | |
| # should see this in `docker ps` | |
| CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
| d10993d1f25b ansible/awx_task:latest "/tini -- /bin/sh ..." 6 seconds ago Up 5 seconds 8052/tcp awx_task | |
| b63a677d32a7 ansible/awx_web:latest "/tini -- /bin/sh ..." 7 seconds ago Up 6 seconds 0.0.0.0:54321->8052/tcp awx_web | |
| 59806de1bcd1 memcached:alpine "docker-entrypoint..." 27 seconds ago Up 26 seconds 11211/tcp memcached | |
| a89aa0e4a395 rabbitmq:3 "docker-entrypoint..." 27 seconds ago Up 26 seconds 4369/tcp, 5671-5672/tcp, 25672/tcp rabbitmq | |
| # should see this in evm.log | |
| [----] I, [2017-12-07T11:32:46.833998 #29139:2acb0db2ef8c] INFO -- : MIQ(EmbeddedAnsibleWorker::Runner#setup_ansible) Starting embedded ansible service ... | |
| [----] I, [2017-12-07T11:33:06.637266 #29139:2acb0db2ef8c] INFO -- : MIQ(DockerEmbeddedAnsible#start) Waiting for Ansible container to respond | |
| ... a whole lot of this .... | |
| [----] I, [2017-12-07T11:33:08.732190 #29139:2acb0db2ef8c] INFO -- : MIQ(DockerEmbeddedAnsible#start) Waiting for Ansible container to respond | |
| [----] I, [2017-12-07T11:33:13.530599 #29139:2acb0db2ef8c] INFO -- : MIQ(EmbeddedAnsibleWorker::Runner#setup_ansible) Finished starting embedded ansible service. | |
| [----] I, [2017-12-07T11:33:15.605973 #29139:2acb0db2ef8c] INFO -- : MIQ(ManageIQ::Providers::EmbeddedAnsible::Provider#with_provider_connection) Connecting through ManageIQ::Providers::EmbeddedAnsible::Provider: [Embedded Ansible] | |
| [----] I, [2017-12-07T11:33:16.033227 #29139:2acb0db2ef8c] INFO -- : MIQ(AuthUseridPassword#validation_successful) [Provider] [1], previously valid/invalid on: []/[], previous status: [] | |
| # in another terminal - this will give you refresh and event workers | |
| foreman start -f Procfile.workers |
One more bit I need to figure out:
Update all the services and related stuff with the new embedded ansible id.
(More of a note to self I guess :))
Getting this running on a mac...
# redirect local 54321 to docker-machine
docker-machine ssh default -L 54321:127.0.0.1:54321
# inside that docker-machine ssh shell - redirect postgres from the docker machine to the real one
sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
sudo iptables -t nat -I PREROUTING --dst 172.17.0.1 -p tcp --dport 5432 -j DNAT --to-destination 192.168.99.1:5432
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bits missing from here..
postgresql.confcontains:pg_hba.confcontains:config/database.yml) hassuperuserrights..foreman start -f Procfile.ansiblesuceeds, update the ids inProcfile.workersto the id of the new manager (not provider)