Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

ansible-pull

ANSIBLE VERSION

ansible 2.1.2.0

OS / ENVIRONMENT

N/A

SUMMARY

Not sure if this is a problem or just me doing it wrong, but I can not add a custom path for the known_hosts file for ansible-pull.

STEPS TO REPRODUCE

By default, ansible-pull uses the known_hosts file located at ~/.ssh/known_hosts but I should be able to add a custom one with --ssh-common-args=UserKnownHostsFile=~/my_temporary_known_host

Unfortunately, this setting is ignored by ansible-pull and the git checkout fails.

Starting Ansible Pull at 2016-10-26 15:06:29
/usr/local/mydir/bin/ansible-pull -i myinventory -U ssh://git@mygit -C master --private-key=mykey --ssh-common-args=UserKnownHostsFile=~/my_temporary_known_host
localhost | FAILED! => {
"changed": false,
"failed": true,
"msg": "mygit has an unknown hostkey. Set accept_hostkey to True or manually add the hostkey prior to running the git module"
}

Issue 2:
SUMMARY

The git submodule which is used by ansible-pull when cloning the inventory repo is fixed to either initializing submodules recursively or not initializing submodules and doesn't support just initializing the first level of submodules in the repo.

Use Case:

I have thousands of IOT devices being managed using ansible-pull. Some SCM providers like Bitbucket have API limits and recursive cloning can be a problem here and also a scalability issue.

If my ansible-pull inventory uses submodules for roles in roles/ and each role itself uses submodules in its tests directory which mimics the inventory at tests/roles/ used only for unit testing, then doing recursive submodule initialization is a huge cloning overhead that is ultimately not necessary.

The difference in the number of clones in my case when I use 11 role submodules in the inventory repo is that non recursive submodule cloning causes 12 git clones, whereas recursive submodule cloning causes 52 git clones.

When your IOT devices may be on internet connections of questionable quality, reducing the amount clones helps reduce the network traffic, load on SCM provider or self hosted instances, and reduce ansible-pull failures resulting from just trying to retrieve the inventory/roles.

ISSUE TYPE

Feature Idea

COMPONENT NAME

ansible-pull

git

ADDITIONAL INFORMATION

My guess is that the current git module's behavior is modeled after git-clone's behavior with its built in --recurse-submodules and --shallow-submodules options.

However, in actual implementation, the git submodule is not using these git-clone options though, but instead using git-submodule-update recursive submodue init except with --init and --recursive always fixed.

Proposal:

Extend the git module to add a submodule_init parameter (defaults to yes for backward compatibility) that controls whether or not submodules are initialized at all, and update the submodule_update method to only initialize recursively if the current recursive parameter is enabled. In addition, add submodule_depth parameter which is also used by submodule_update method to expose the depth and allow us to further reduce the clone size for better scalability.

Extend the ansible-pull command to add flags for --no-recurse-submodules and --no-submodule-init and update the options passed to git module (the submodule_depth parameter can be set the same way as the depth parameter currently is, based on whether or not --full is provided).

cc @bcoca @sivel Thoughts on proposal and likelihood they would be accepted if I submitted PRs?