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

'openssl_packages' is undefined error when using role. #20

Open
abenedict opened this issue Jul 15, 2021 · 1 comment
Open

'openssl_packages' is undefined error when using role. #20

abenedict opened this issue Jul 15, 2021 · 1 comment

Comments

@abenedict
Copy link

I am getting an error when trying to use this role.

TASK [weareinteractive.openssl : Installing packages] **********************************************************************************************************
fatal: [host1]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'openssl_packages' is undefined\n\nThe error appears to be in '.ansible/roles/weareinteractive.openssl/tasks/install.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Installing packages\n  ^ here\n"}

I found .weareinteractive.openssl/vars/defaults.yml that defines this, but maybe I am missing something?

@gkedge
Copy link

gkedge commented Jul 21, 2021

I am experiencing this also. Based on some sleuthing with a well-placed debug: msg=..., I bet that you are attempting to install this role onto a Debian variant (I am attempting an install on Ubuntu). Follow me here (I am a tad green on role dependencies)...

weareinteractive/ansible-vsftpd depends on weareinteractive/ansible-openssl. weareinteractive/ansible-vsftpd seems to make an attempt to load weareinteractive/ansible-openssl for us by simply depending on weareinteractive/ansible-openssl. But, a well-placed debug statement shows that when weareinteractive/ansible-openssl attempts to do its install into a Debian distro, it is not picking up roles/weareinteractive.openssl/vars/default.yml as you (and I) expect, it is picking up vsftpd's Debian vars: roles/vsftpd/vars/Debian.yml.

roles/vsftpd/vars/Debian.yml is being found with this command in roles/weareinteractive.openssl/tasks/vars.yml:

- name: Including variables
  include_vars: "{{ item }}"
  with_first_found:
    - "{{ ansible_distribution | lower }}/{{ ansible_distribution_release }}.yml"
    - "{{ ansible_distribution | lower }}.yml"
    - "{{ ansible_os_family | lower }}.yml"
    - "default.yml"

... which is a nasty bug that actually seems to be in Ansible's realm that shouldn't be referring to another role's YAML.

My work-around ('cause I'm green and really am unqualified to do a pull-request for this) was to add weareinteractive/ansible-openssl to my role dependencies in my roles/requirements.yml:

roles:
  - src: weareinteractive.openssl
    name: openssl
    version: 2.2.1
  - src: weareinteractive.vsftpd
    name: vsftpd
    version: 1.8.1

And in my playbook, make sure both are there and importantly openssl is listed first to make sure it installs first:

---
- hosts: all
...
  roles:
    - openssl
    - vsftpd

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

2 participants