Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git module add separate remotes for push / pull #27493

Open
elaske opened this issue Jul 31, 2017 · 5 comments
Open

git module add separate remotes for push / pull #27493

elaske opened this issue Jul 31, 2017 · 5 comments

Comments

@elaske
Copy link

@elaske elaske commented Jul 31, 2017

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

git module

ANSIBLE VERSION
ansible 2.3.0.0
  config file = 
  configured module search path = Default w/o overrides
  python version = 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

(but others as well).

CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

The repo option of the git module only allows setting of one remote URL for the entire repo. The ability to set separate push / pull URLs would be useful in managing the protocols to use. Currently, we use the git module to set a remote, and then a command to change the --push URL to a different URL.

STEPS TO REPRODUCE

Something like this would be nice:

#  A single URL
git: 
    repo: https://github.com/ansible/ansible.git

# Different URLs
git: 
    repo:
        pull: git@github.com:ansible/ansible.git
        push: https://github.com/ansible/ansible.git

In this usage it allows anyone to pull on that machine, but you have to authenticate to push ^. There may be other use-cases that require different URLs, however.

EXPECTED RESULTS

The equivalent of running git remote set-url --push <remote> <pushurl> --pull <remote> <pullurl>.

ACTUAL RESULTS

N/A

@ansibot

This comment has been minimized.

Copy link
Contributor

@ansibot ansibot commented Jul 31, 2017

@robinro

This comment has been minimized.

Copy link
Contributor

@robinro robinro commented Jul 31, 2017

Thanks @elaske for this feature idea.

I think some way to separately set push/pull URLs would be a good addition.
I don't like the syntax you propose, since it allows different types (string, dict) for one argument and thereby makes the documentation and implementation more complex.
I would rather suggest something like

git: 
    repo: git@github.com:ansible/ansible.git # pull URL, maybe alias pull_url
    push_url: https://github.com/ansible/ansible.git

Most uses of the git module only ever use pull, so here the repo URL can be used.
If push_url is unset, the module defaults to the old behavior (same URL for both cases) and only sets a distinct push URL when given.

Additional care is need to ensure idempotency and check_mode.

I'm looking forward to a PR for this feature
needs_contributor

@elaske

This comment has been minimized.

Copy link
Author

@elaske elaske commented Jul 31, 2017

I am by no means tied to that syntax - the two types is awkward. However, just adding push_url may not be the best solution because of possible other use-cases.

Here's another I thought of: Managing a fork of a repo. You may want one URL that is just a pull url in addition to your origin (read: repo:). In this case you'd need two pull remotes, and only one push. That may require a different kind of feature request, though.

@robinro

This comment has been minimized.

Copy link
Contributor

@robinro robinro commented Jul 31, 2017

I don't think having more than one remote is within the scope of this module. There are issues about remotes other than "origin" already and they would overcomplicate a module that is mostly used for simple deployments.

@newtonne

This comment has been minimized.

Copy link
Contributor

@newtonne newtonne commented Sep 23, 2018

The git_config module is suited to this.

- name: Clone repo as normal (which will define the push and pull URLs)
  git: 
    repo: git@github.com:ansible/ansible.git

- name: Set push remote URL
  git_config:
    name: remote.origin.pushurl
    value: https://github.com/ansible/ansible.git
    scope: local
    repo: path/to/local/repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.