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

Unable to test via molecule own role with a dependency to openshift-applier #112

Open
matihost opened this issue Mar 13, 2019 · 0 comments

Comments

@matihost
Copy link

matihost commented Mar 13, 2019

If own role uses molecule and uses openshift-applier dependency to - the "openshift-applier" role is run with empty results.

The reason is the openshift-applier git repository equals to the name of the role "openshift-applier"
So even adding :

provisioner:
  name: ansible
  log: True
  env:
    ANSIBLE_ROLES_PATH: /tmp/molecule/role-under-test/default/roles/openshift-applier/roles

does not help because molecule append ANSIBLE_ROLES_PATH to ansible rolepath at the end.
Since /tmp/molecule/role-under-test/default/roles is earlier on the role path, Ansiblefinds /tmp/molecule/role-under-test/default/roles/ansible-applier directory - which is not valid Ansible role - and it assumes role is empty.

So when Ansible looks for "openshift-applier" role, it finds it earielir (and find the git repository name) and assumes empty.

The problem could be solved in various ways:

  • openshift-applier repo to follow Ansible role directory structure from the top git repo level
  • moving to gilt in molecule but an attempt to download only src: roles/openshift-applier ends with
    "[Errno 40] Too many levels of symbolic links: '/home/user/.gilt/clone/.openshift-applier/roles/openshift-applier/tests/roles/openshift-applier/tests/roles/openshift-applier/tests/roles/openshift-applier/tests/roles/openshift-appbblablabla'")] - it seems gilt doesn't like symbolic links.
  • ansible galaxy to allow importing subdirectories of git repos
  • molecule - to change mind with roles_path overwrite ansible/molecule#1273 - to allow overriding role path or to allows to inject own directories to role path before core rolepath list

Workaround is:

  • disable molecule dependency step
  • run galaxy or gogitit or git submodules to download openshitt-applier
  • add 'openshift-applier/roles/' to molecule ANSIBLE_ROLES_PATH env

Sample makefile to automate stuff:

test: clean get-dependencies ## Test own role
	molecule test

get-dependencies: clean ## download galaxy dependencies
	ansible-galaxy install -r requirements.yml -p galaxy -f

clean:
	-rm -rf galaxy

where molecule.yml is the following:

# cannot use with Ansible role where git role is in subdirectory, and role name equals git repo (for example https://github.com/redhat-cop/openshift-applier.git)
#dependency:
#  name: galaxy
#  options:
#    role-file: requirements.yml
#dependency:
#  name: shell
#  command: gilt overlay
#  options:
#    debug: True
driver:
  name: docker
lint:
  name: yamllint
  options:
    config-file: .yamllint
platforms:
  - name: instance
    image: centos:7
provisioner:
  name: ansible
  log: True
  env:
    ANSIBLE_ROLES_PATH: ../../galaxy/openshift-applier/roles
  lint:
    name: ansible-lint
    options:
      force-color: True
      c: .ansible-lint
  options:
    v: true
scenario:
  name: default
  test_sequence:
    - lint
    - destroy
    #- dependency
    - syntax
    - create
    - prepare
    - converge
    - idempotence
    - side_effect
    - verify
    - destroy

verifier:
  name: testinfra
  lint:
    name: flake8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant