Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible playbook using private git role dependency

I have an issue running an Ansible playbook with a set of private roles (that is, Ansible roles in a private git repository).

For example, I have a playbook that uses the role base which depends on dep, both of which are hosted in private git repositories. Running ansible-galaxy fetches and installs all roles and dependencies as it should, but later ansible-playbook fails at using the correct role name.

play.yml

- hosts: test
  roles:
    - role: base

requirements.yml

- name: base
  src: ssh://[email protected]/ansible/role-base.git
  scm: git

role-base/meta/main.yml

galaxy-info:
  author: Me
  description: Test Ansible role dependencies
  min_ansible_version: 1.9
  platforms: Ubuntu
dependencies:
  - name: dep
    src: ssh://[email protected]/ansible/role-dep.git
    scm: git

$ ansible-galaxy -r requirements.yml
- executing: git clone ssh://[email protected]/ansible/role-base.git base
- executing: git archive --prefix=base/ --output=/tmp/tmp4YKG7a.tar
- extracting base to ansible-roles/base
- base was installed successfully
- adding dependency: dep
- executing: git clone ssh://[email protected]/ansible/role-dep.git dep
- executing: git archive --prefix=dep/ --output=/tmp/tmpT2YiW4.tar
- extracting base to ansible-roles/dep
- dep was installed successfully

$ ansible-playbook play.yml
ERROR: expected a role name in dictionary: {'scm': 'git', 'src': 'ssh://[email protected]/ansible/role-dep.git', 'name': 'dep'}

I tried using the alternative role-name system as the dependency:

dependencies:
  - role: "git+ssh://[email protected]/ansible/role-dep.git,,dep"

Which is fine for ansible-galaxy but still ansible-playbook fails...

$ ansible-galaxy -r requirements.yml
- executing: git clone ssh://[email protected]/ansible/role-base.git base
- executing: git archive --prefix=base/ --output=/tmp/tmpTcvpDu.tar
- extracting base to ansible-roles/base
- base was installed successfully
- adding dependency: dep
- executing: git clone ssh://[email protected]/ansible/role-dep.git dep
- executing: git archive --prefix=dep/ --output=/tmp/tmpd726OV.tar
- extracting base to ansible-roles/dep
- dep was installed successfully

$ ansible-playbook play.yml
ERROR: cannot find role in <pwd>/roles/git+ssh://[email protected]/ansible/role-dep.git,,dep or <pwd>/git+ssh://[email protected]/ansible/role-dep.git,,dep or <pwd>/ansible-roles/git+ssh://[email protected]/ansible/role-dep.git,,dep

Is there a way to use role dependencies from private repos correctly?

like image 232
Tim Jones Avatar asked Jan 08 '16 14:01

Tim Jones


1 Answers

Looks like it's a bug in the 1.9. I created a PR (https://github.com/ansible/ansible/pull/13802) but I doubt it'll get merged as Ansible 2.0 has just been released.

like image 85
Tim Jones Avatar answered Oct 24 '22 08:10

Tim Jones