-2

How to write Ansible playbook to commit and push a gitlab repository?

I have Ansible tower template to launch my playbook, then playbook must do commit and push on different git repo. This git repo on successful push will trigger jenkins pipeline.

2
  • Which part with the git module do you have problems with? Please provide your playbook. Commented Jan 20, 2023 at 9:39
  • I am new to ansible, need help in understanding how is it possible to write a file seating in git repo and pushing the upudated file in the same git repo, this should be achieved by playbook (writing and pushing in git repo) Commented Jan 20, 2023 at 10:15

1 Answer 1

0

Write a script to do edit, commit, probably push. In shell or whatever. Run this with Ansible's generic script module. Maybe your own custom module if you are feeling fancy and return JSON Ansible return values.

Ansible's git module only installs trees from a repo to a path on the target host. For cases in which the thing does not release proper package archives. Or as a VCS wrapper to help ansible-pull work. Currently it does not have commit features.

Consider if a commit only to trigger some pipeline system is your preferred solution. Glancing at Jenkins, they have an API, which could be used to trigger it. Without needing to give the automation commit access. Or, you might need to do the edits, so trigger on commit is useful.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.