Can Ansible alone be a complete CI-CD tool? I am new to Ansible and was wondering about the capabilities of Ansible. Can Ansible alone be a complete CI-CD tool?
Scenario that needs to be implemented:
As soon as a developer perform a git commit, the build should be generated and placed some central server or maybe Amazon S3. This is a JAR file assuming a Java application. One can then download the build and deploy that build to the testing environment and after deployment invoke the automated test cases. Upon successful implementation of the test cases,one should be able to deploy this build onto the production environment in a rolling fashion. Note that one must not deploy this build every time, but it should be a discretionary power. I.e. even if during a day let us say, 5 builds were created and 3 of them passed the test cases, It should not go and deploy the builds on production. I should decide when to deploy the build, this could be a flag that I set to &quot;Go&quot; and then the deployment to production should take place.
Points that I am apprehensive about Ansible's capability are:

Will ansible be able to detect the git commit event. Is there a way my playbook to constantly poll the GIT server on a regular basis to detect any commits?

Is it possible to create Build using just Ansible. (Can I use command module to just execute the build creation process(assuming there is some command to create the build and I was thinking of firing those command using the command module, maybe maven or ant command).
Kindly forgive me for my ignorance if there is no such thing. I have never done development and hence am complete beginner.

How can I invoke automated test cases on the testing environment where the build was deployed (I am assuming a successful deploy on the stage environment).

Can I capture the success or failure result? (It maybe be a suite of test cases and won't be an objective o/p as pass or fail.)

Is there a way to achieve the discretion based deployment to production systems using Ansible?


Note that I don't want to use Jenkins or any such tools for creation of builds or deployment to test environments .
This may sound like a beginner question on DevOps, but I just wanted to assess the scope of Ansible as a CI tool. Is Jenkins (or any other variant) inevitable for achieving this? Or can people do away without using Jenkins.
Also if someone can comment on what is the recommended way to achieve this pipeline.
This is totally possible.  Of course you can achieve it without jenkins or similar tools being required.  We're always free to reinvent the wheel.  The question becomes is it worth the effort?  When it helps you avoid jenkins I'd be inclined to put the effort in.  (I'd also suggest looking at Concourse before doing jenkins again, but that's not what this question is about...)

For your case you need two things:


a playbook that automates your build using ansible.
a git hook to invoke your ansible playbook, probably post-commit.


If you are using gitlab or github you should look at their specific documentation for creating hooks, but otherwise the generic help I linked to should do it.

To answer your specific questions:


Yes, use the git hook.
Sure.  You probably want ansible to do a fresh git checkout first.  Eventually you will want to add any prerequisites to be verified too.
You don't have to assume anything, just add these steps to the end of your playbook.  If the build fails, it will stop before wasting effort on testing anything.  You could split build, deploy, and validate into their own roles within one larger playbook.  This will help make each of the sets of tasks easier to manage and you could call them manually if needed for debugging or emergencies.
You could do this in a myriad of ways.  I'd create a text file with a date/time stamp and the results inside.  You could write it to a database or K/V store.
I'm not sure what you mean.