-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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_certificate: Handle dump() in check_mode #38386
Conversation
The test
|
Currently, when ones run the module in check_mode it tries to retrieve values from the actual certificate generated in the generate() function. Since in check_mode we call dump() without calling generate(), self.cert is None, leading to self.cert.get_notBefore(), self.cert.get_notAfter() and self.cert.get_serial_number() raising an error. > NoneType' object has no attribute 'get_notBefore' The solution is to have two way to handle dump() method, whether its run in check_mode=True or check_mode=False leading to different way the information is retrieved.
I've verified this code, works well for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this code with ansible-2.5.0 (and just this file modified) and it works for me:
ansible --version
ansible 2.5.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/robertdb/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.14 (default, Mar 14 2018, 13:36:31) [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
shipit |
Currently, when ones run the module in check_mode it tries to retrieve values from the actual certificate generated in the generate() function. Since in check_mode we call dump() without calling generate(), self.cert is None, leading to self.cert.get_notBefore(), self.cert.get_notAfter() and self.cert.get_serial_number() raising an error. > NoneType' object has no attribute 'get_notBefore' The solution is to have two way to handle dump() method, whether its run in check_mode=True or check_mode=False leading to different way the information is retrieved. (cherry picked from commit 99497ce)
Merged into Thanks for code & reviews |
* openssl_certificate: Handle dump() in check_mode (#38386) Currently, when ones run the module in check_mode it tries to retrieve values from the actual certificate generated in the generate() function. Since in check_mode we call dump() without calling generate(), self.cert is None, leading to self.cert.get_notBefore(), self.cert.get_notAfter() and self.cert.get_serial_number() raising an error. > NoneType' object has no attribute 'get_notBefore' The solution is to have two way to handle dump() method, whether its run in check_mode=True or check_mode=False leading to different way the information is retrieved. (cherry picked from commit 99497ce)
Currently, when ones run the module in check_mode it tries to retrieve values from the actual certificate generated in the generate() function. Since in check_mode we call dump() without calling generate(), self.cert is None, leading to self.cert.get_notBefore(), self.cert.get_notAfter() and self.cert.get_serial_number() raising an error. > NoneType' object has no attribute 'get_notBefore' The solution is to have two way to handle dump() method, whether its run in check_mode=True or check_mode=False leading to different way the information is retrieved.
SUMMARY
Currently, when ones run the module in check_mode it tries to retrieve
values from the actual certificate generated in the generate() function.
Since in check_mode we call dump() without calling generate(), self.cert
is None, leading to self.cert.get_notBefore(), self.cert.get_notAfter()
and self.cert.get_serial_number() raising an error.
The solution is to have two way to handle dump() method, whether its run
in check_mode=True or check_mode=False leading to different way the
information is retrieved.
ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
ADDITIONAL INFORMATION
Fixes: #37867