Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ansible-galaxy and git clone from Bitbucket.org

I am using ansible-galaxy (v2.0.0.2) to install ansible roles that which has the source code on Bitbucket through the requirements.yml file. But I could not checkout the code from bitbucket.org with the private key. Here is the error message, and also my requirements.yml content.

Does any one what's the correct requirements.yml file format for ansible-galaxy 2.0.0.2?

  + ansible-galaxy -vvv install --force --role-file ansible/requirements.yml --roles-path ./ansible/roles

    Using /etc/ansible/ansible.cfg as config file
    Opened /tmp/.ansible_galaxy
    found role {'scm': 'git', 'src': '[email protected]:myrepo/nginx.git', 'version': 'latest', 'name': 'nginx'} in yaml file
    Installing role nginx 

     [WARNING]: - nginx was NOT installed successfully: - command git checkout
    latest failed in directory /tmp/tmpQRZc8j (rc=1)
    ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

[requirements.yml]

- name: nginx
  src: [email protected]:myrepo/nginx.git
  scm: git
  version: latest
  accept_hostkey: yes
  key_file: /tmp/.ssh/id_rsa
like image 637
ezlee Avatar asked Jan 20 '17 03:01

ezlee


3 Answers

Maybe the scp syntax does not work. The url one might:

ssh://[email protected]/myrepo/nginx.git

Try, as in this ansible issue:

Direct copy from github clone repo path

[email protected]:geerlingguy/ansible-role-php.git

Actual URL that works

ssh://[email protected]/geerlingguy/ansible-role-php.git

You have to replace the : with a /.
And it needs to be a URL (i.e. contain ://) otherwise ansible-galaxy assumes it's a filesystem path.

like image 183
VonC Avatar answered Nov 19 '22 04:11

VonC


try git+ssh schema

works on ansible-galaxy 2.7.8

ansible-galaxy install git+ssh://bitbucket.org:<username>/<role-name>.git

like image 3
VictorB Avatar answered Nov 19 '22 05:11

VictorB


If you set "scm: git" underneath the src, galaxy will run "git clone XYZ" where XYZ is your src: field. So, anything you can "git clone XYZ" is what you put in the src field.

- src: ssh://[email protected]:8899/project/repo-name.git
  scm: git

For the private key, in case it's not your default ssh key, we use ssh-agent(1) (see manpage for usage).

like image 2
Jason2616321 Avatar answered Nov 19 '22 06:11

Jason2616321