Call playbook from git

Hi all,

Just a “quick question”
Is it possible to directly “call” an ansible playbook which is stored in git without downloading it prior ?

So the idea is to have all the playbooks stored in our internal git-repo and to “call” them ( something ) like this:

ansible-playbook git://user:pass@our-git.com/repo/branch/myPlaybook.yaml

No, I don’t believe this is possible.

ok :sleepy:
Thanks for your help

You could mount the repo locally and then run Ansible?

I have never used gitfs and it hasn’t had a release since 2019 so there might be a better way of doing this, but in theory this would work:

2 Likes

Hi,

Not without downloading per se, nor through pure git, but you can pass your remote playbook to stdin while fetching its raw content in http, if you git hosting provider allows for it; example for a playbook I ran from a Github repo:

curl -Ls https://raw.githubusercontent.com/myusername/myrepo/mybranch/my/playbook/path?token=mytoken | ansible-playbook -i /my/inventories/path/ /dev/stdin
1 Like

This will also limit you to only using playbooks that are a single file; while it’s probably not common, playbooks are permitted to refer to ‘local’ content (templates, plugins, etc.) like a role can have, and pulling a single file from a repository won’t support that.

1 Like