1

Is there any way how i can resolve dependencies from private project in gitlab? On my actual gitlab-ci i use such a trick

requirements.tmpl:

- name: my-company.ansible-init-disk
  scm: git
  src: https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.my-company/sre/ansible-roles/ansible-role-init-disk.git
  version: 0.1.0

.gitlab-ci.yaml

- envsubst < requirements.tmpl > requirements.yaml
- ansible-galaxy install -r requirements.yaml -p roles --force-with-deps

And voila i got my deps in roles folder.

For molecule i have to do something like

dependency:
  name: galaxy
  options:
    role-file: molecule/default/requirements.yml

but of cause there is no env interpolation in requirements.yml. see https://github.com/ansible/ansible/issues/36395

Any ideas how to get my deps ?

  • I would try using an ssh connection to gitlab with deploy keys if possible. This would remove the need to `envsubst` the requirement file and would work anywhere a recognised ssh key is registered. Regarding gitlab-ci, a solution here: https://docs.gitlab.com/ee/ci/ssh_keys/ – Zeitounator May 03 '20 at 08:08

1 Answers1

0

Current best solution looks like that

molecule.yml

dependency:
  name: shell
  command: $PWD/molecule/default/deps.sh

deps.sh

envsubst < molecule/default/requirements.tmpl > molecule/default/requirements.yaml
ansible-galaxy install -r molecule/default/requirements.yaml

but that look bit ugly