# Git accept\_hostkey submodule fix proposal

**URL:** <https://forum.ansible.com/t/git-accept-hostkey-submodule-fix-proposal/16941>\
**Category:** Ansible Developer\
**Created:** [December 2, 2014, 7:46pm UTC](https://forum.ansible.com/t/git-accept-hostkey-submodule-fix-proposal/16941 "2014-12-02T19:46:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_Dav](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@J\_Dav](https://forum.ansible.com/u/J_Dav)\
**Post date:** [December 2, 2014, 7:46pm UTC](https://forum.ansible.com/t/git-accept-hostkey-submodule-fix-proposal/16941/1 "2014-12-02T19:46:04Z")

</div>

So working on fixing a little issue where accept\_hostkey in the git module doesn’t take into account submodule remotes with different urls. Thus ansible hangs waiting for user to accept the hostkey so it fails when recursion and accept\_hostkey are true. There doesn’t seem to be a way to simply clone a single file from a git server (thought about just cloning .gitmodule and parsing it). What I’m thinking may be the only option is to download the repo into say /tmp, parsing the .gitmodule dir to get the urls, removing the clone from tmp and thats it. Seems a bit excessive. Thoughts?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 2, 2014, 9:21pm UTC](https://forum.ansible.com/t/git-accept-hostkey-submodule-fix-proposal/16941/2 "2014-12-02T21:21:05Z")

</div>

“So working on fixing a little issue where accept\_hostkey in the git module doesn’t take into account submodule remotes with different urls.”

Can you share an example of what this might look like?

This proposed fix seems a bit heavyweight and I’m not sure it’s required – might be a workaround available, but I need to understand the use case a little better first.

---

<div class="post-metadata">

**Author:** ![J\_Dav](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@J\_Dav](https://forum.ansible.com/u/J_Dav)\
**Post date:** [December 3, 2014, 4:02pm UTC](https://forum.ansible.com/t/git-accept-hostkey-submodule-fix-proposal/16941/3 "2014-12-03T16:02:19Z")

</div>

Right, so imagine if you have your base project stored on GitHub and within that project you have submodules stored on bitbucket.

Assume that neither hostkey has been added to known\_hosts

When running a playbook that uses the git module with both recursion and accept\_host\_key set to true/yes the playbook ran via CLI adds the GH but still prompts for the BB hostkey acceptance/rejection. Within ansible-tower this has the effect of causing the playbook to hang as it is waiting for user input.

Another solution which is more lightweight and less repetitive I thought of is that when recursion and accept\_hostkey are true to then let the module run as if recursion was not specified and after the base repo has been cloned to then parse .gitmodules, add the keys and execute ‘git submodule update --init --recursive’ to then add the submodules.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 3, 2014, 4:31pm UTC](https://forum.ansible.com/t/git-accept-hostkey-submodule-fix-proposal/16941/4 "2014-12-03T16:31:02Z")

</div>

Ah, got it – and interesting – haven’t seen that done before and I suspect it’s a rare case. Thanks for the explanation!

What I would suggest is having a step in the playbook before the git call that makes sure the host keys for github and bitbucket are both present. This could be lineinfile for instance.

I’d prefer that from the logic getting somewhat overcomplicated for an edge case that is unlikely to occur once in a thousand use cases – I’m sympathetic, but that seems to be the better way to go from a maintainability perspective.
