Slight change - I found out there is a feature in feature-pack stuff that let you ship
with direct file content that gets copied into the server. So I put the Ansible scripts in
the feature pack. This is the correct way to do it. Now anyone building the server with
the feature pack (integration tests, for example) will get the Ansible integration as
well.
So link [3] changes from my original email. It is now:
[3]
I have a very simple PoC working that shows Ansible integrated with
Hawkular
such that it can start a WildFly server remotely.
I'll begin with a brief summary.
SUMMARY
A client connects to the Hawkular Server via its websocket and passes in a
JSON request (like it does the other kinds of requests). The JSON request
looks something like:
AnsibleRequest={"playbook":"start-wildfly.yml",
"extraVars": {
"wildfly_home_dir":"/opt/wildfly10" } }
The command-gateway server takes the request, runs the Ansible playbook, and
returns the response back over the websocket to the client with an
AnsibleResponse (which includes the Ansible output to show what it did).
DETAILS
The code is in two branches in my repos. See [1] and [2]. You need both for
this to work.
Hawkular-Services packages up Ansible playbooks and its associated files in
standalone/configuration/ansible. See [3].
Hawkular-Commons adds to command gateway a new JSON request/response for
Ansible requests. See [4] and [5].
The Ansible command is invoked in the server when the AnsibleRequest JSON is
received over the websocket. This command implementation runs the Ansible
playbook and returns the results back in a AnsibleResponse. See [6].
If you build commons and then services to pull the new commons in, you can
run a test to see it work. I use the test command CLI utility in the agent
to do this [7]. First, build the new dist and run it so you have a Hawkular
Service running (for example, "mvn clean install -Pdev,embeddedc"). Next,
create a test JSON request file (say, "/tmp/hawkular.json") with this
content:
{ "playbook":"start-wildfly.yml",
"extraVars": {
"wildfly_home_dir":"/directory/where/you/installed/wildfly"
}
}
Now build the hawkular-agent from source (just so you get the test command
CLI utility) and run the test command CLI, telling it to use the JSON in
your file and send it to your Hawkular Service server:
$ cd
<hawkular-agent-source-dir>/hawkular-wildfly-agent-itest-parent/hawkular-wildfly-agent-command-cli/target
$ java -jar hawkular-wildfly-agent-command-cli-*.jar --username jdoe
--password password \
--command AnsibleRequest --request-file=/tmp/hawkular.json
This sends the request to your local Hawkular Service server over the
websocket, the Ansible playbook "start-wildfly.yml" is run, which starts the
WildFly in that home dir you specified in your JSON request, and the
response is sent back. The Command CLI tool will write the responses it
receives to disk - look at the cli output for the names of the files it
writes - you can look in there to see what the Ansible command response was
(its just the full Ansible output).
There is still LOTS to do here (for one, you'll notice it assumes your
wildfly install is on "localhost" :)). This is merely a PoC that we can use
as a starting point - it shows that this can be done and how we can do it.
-- John Mazz
[1]
https://github.com/jmazzitelli/hawkular-commons/tree/HAWKULAR-1096-ansibl...
[2]
https://github.com/jmazzitelli/hawkular-services/tree/HAWKULAR-1096-ansib...
[3]
https://github.com/jmazzitelli/hawkular-services/tree/HAWKULAR-1096-ansib...
[4]
https://github.com/jmazzitelli/hawkular-commons/blob/HAWKULAR-1096-ansibl...
[5]
https://github.com/jmazzitelli/hawkular-commons/blob/HAWKULAR-1096-ansibl...
[6]
https://github.com/jmazzitelli/hawkular-commons/blob/HAWKULAR-1096-ansibl...
[7]
https://github.com/hawkular/hawkular-agent/tree/master/hawkular-wildfly-a...
_______________________________________________
hawkular-dev mailing list
hawkular-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hawkular-dev