Skip to content

Instantly share code, notes, and snippets.

@droidMakk
Created January 11, 2018 08:05
Show Gist options
  • Save droidMakk/0902f6352337ff0343bb2361b270161b to your computer and use it in GitHub Desktop.
Save droidMakk/0902f6352337ff0343bb2361b270161b to your computer and use it in GitHub Desktop.
Ansible Snippet to generate a token from GIt
- name: generate token
#CURL to generate a Token
win_command: curl -k -X POST https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials -u user_key:user_secret
register: resp
- set_fact:
tkn: "{{ resp.stdout | from_json }}"
cacheable: true
- name: initiating it as git repository
win_shell: git init
args:
chdir: "The Path to initiate Git repository"
register: output
- debug: var=output
- name: cloning the repo
# Your Token gets added here.
win_shell: git pull https://x-token-auth:"{{ tkn.access_token }}"@bitbucket.org/user_or_orgname/repo_name.git
args:
chdir: "To Path where repo to be cloned"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment