Graylog2 / graylog-ansible-role

Ansible role which installs and configures Graylog
Apache License 2.0
212 stars 126 forks source link

Error when (disabled) dependencies are not installed #49

Closed veger closed 8 years ago

veger commented 8 years ago

I get an error that the depend roles (ES, MongoDB, nginx) are not installed, even when I disable those functionalities using:

  roles:
  - role: Graylog2.graylog-ansible-role
    graylog_install_mongodb: false
    graylog_install_elasticsearch: false
    graylog_install_nginx: false

I would expect that by disabling them, the dependent roles do not have to be installed?

mariussturm commented 8 years ago

The dependencies are disabled when set to false: https://github.com/Graylog2/graylog-ansible-role/blob/466d51f61657586a5e4ce04b2bb7267135855e2b/meta/main.yml#L4

Maybe sharing the error you get could be helpful?

veger commented 8 years ago

I saw that change (the galaxy install, is slightly different, but functionally the same), but it does not disable the dependency requirement:

$ ansible-playbook playbook.yml

ERROR! the role 'lesmyrmidons.mongodb' was not found in /path/to/ansible/roles

The error appears to have been in '/path/to/ansible/roles/Graylog2.graylog-ansible-role/meta/main.yml': line 3, column 5, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

dependencies:
  - { role: lesmyrmidons.mongodb, when: graylog_install_mongodb }
    ^ here

(Ansible 2.2)

Removing the dependencies from meta/main.yml (obviously) 'fixes' the issue.

mariussturm commented 8 years ago

After looking into the Ansible docs and some old issues, it looks like this is the expected behaviour. The when statement replaces the action with a noop but the validation if the role exist or not happens before that. So you need to download all dependencies in any case or at least create empty directories like mkdir roles/lesmyrmidons.mongodb... to make Ansible happy. If this is not what you expect please open an issue directly in the Ansible repository: https://github.com/ansible/ansible