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

Check to see if variables is nil before proceeding #322

Merged
merged 1 commit into from
Jan 3, 2020

Conversation

dtibarra
Copy link
Contributor

Ref: https://community.theforeman.org/t/openscap-plugin-with-ansible-role-variables-import-failed/16601

When attempting ansible variables import through the Foreman UI, there is a case where
clicking Configure > Ansible Variables > Import from Foreman will fail. The error that gets
thrown is the following:

*NoMethodError*
**undefined method `map' for nil:NilClass**

/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:48:in `initialize_variables'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:34:in `block in import_variables'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:31:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:31:in `map'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:31:in `import_variables'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:25:in `import_variable_names'

This commit will skip those nil variables, which then makes Foreman operate as expected.

@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

@dtibarra
Copy link
Contributor Author

Another user in the linked forums post confirmed that it worked.

@ares
Copy link
Member

ares commented Dec 22, 2019

Looks reasonable, could you please open a redmine issue with a description and update commit message to a format "Fixes #123 - ..."? If you can't or don't know how, please let us know.

@ares
Copy link
Member

ares commented Dec 22, 2019

[test foreman_ansible]

…through the Foreman UI

    Check to see if variables is nil before proceeding

    Ref: https://community.theforeman.org/t/openscap-plugin-with-ansible-role-variables-import-failed/16601

    When attempting ansible variables import through the Foreman UI, there is a case where
    clicking Configure > Ansible Variables > Import from <foreman> will fail. The error that gets
    thrown is the following:

    *NoMethodError*
    **undefined method `map' for nil:NilClass**
    /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:48:in `initialize_variables'
    /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:34:in `block in import_variables'
    /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:31:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:31:in `map'
    /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:31:in `import_variables'
    /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.9/app/services/foreman_ansible/variables_importer.rb:25:in `import_variable_names'

    This commit will skip those nil variables, which then makes Foreman operate as expected.
@dtibarra
Copy link
Contributor Author

Okay, I updated the commit message. Thanks!

@ares
Copy link
Member

ares commented Jan 3, 2020

Thanks @dtibarra, merging! Test failures were unrelated.

@ares ares merged commit 76c7dd3 into theforeman:master Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants