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

ldap_attr, ldap_entry: Add validate_certs option #24060

Merged
merged 1 commit into from May 3, 2017

Conversation

Akasurde
Copy link
Member

SUMMARY

This fix adds a module option `validate_certs' to check
self-signed certificate of LDAP server.

Fixes #24009

Signed-off-by: Abhijeet Kasurde akasurde@redhat.com

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/modules/network/ldap_attr.py
lib/ansible/modules/network/ldap_entry.py

ANSIBLE VERSION
2.4 devel

@ansibot
Copy link
Contributor

ansibot commented Apr 27, 2017

The test ansible-test sanity --test validate-modules failed with the following errors:

lib/ansible/modules/network/ldap_attr.py:0:0: E309 version_added for new option (validate_certs) should be 2.4. Currently 0.0
lib/ansible/modules/network/ldap_entry.py:0:0: E309 version_added for new option (validate_certs) should be 2.4. Currently 0.0

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Apr 27, 2017

cc @jtyr
click here for bot help

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bugfix_pull_request ci_verified Changes made in this PR are causing tests to fail. module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. networking Network category labels Apr 27, 2017
Copy link
Contributor

@jtyr jtyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have commented on the ldap_entry.py module only, but the same comments apply on the other one as well.

bind_dn: cn=Directory Manager
bind_pw: password
objectClass: organizationalUnit
validate_certs: True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line doesn't make much sense if the default value is True. The whole example is redundant. Please remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to have a example with validate_certs: no.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to have examples with all possible options. Please remove the example entirely.

@@ -101,6 +101,12 @@
default: present
description:
- The target state of the entry.
validate_certs:
required: false
choices: [true, false]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be:

['yes', 'no']

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

choices: [true, false]
default: true
description:
- If false, will ignore self-signed certificates of server and connect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be (decoration around the no and period at the end of the sentence):

- If set to C(no), it will ignore self-signed certificates of server and connect.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@@ -268,17 +287,18 @@ def main():
'server_uri': dict(default='ldapi:///'),
'start_tls': dict(default=False, type='bool'),
'state': dict(default='present', choices=['present', 'absent']),
'validate_certs': dict(default=True, type='bool'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thing the option should be called verify_cert.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the option validate_certs is also used in the get_url module. I think we should keep it in sync with other modules.

@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html and removed needs_triage Needs a first human triage before being processed. labels Apr 27, 2017
@gundalow gundalow added net_tools Net-tools category and removed networking Network category labels Apr 27, 2017
@gundalow gundalow changed the title Add validate_certs option to ldap_attr, ldap_entry ldap_attr, ldap_entry: Add validate_certs option Apr 27, 2017
Copy link
Contributor

@gundalow gundalow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that on rebase this files have moved to modules/net_tools/

choices: [true, false]
default: true
description:
- If false, will ignore self-signed certificates of server and connect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   description:
      - If C(no), SSL certificates will not be validated. This should only be used
        on personally controlled sites using self-signed certificates.
   version_added: "2.4"

@@ -101,6 +101,12 @@
default: present
description:
- The target state of the entry.
validate_certs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update as per other modules

@@ -101,6 +101,13 @@
- The value(s) to add or remove. This can be a string or a list of
strings. The complex argument format is required in order to pass
a list of strings (see examples).
validate_cert:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be validate_certs as per other modules (e.g. get_url). The same anywhere else in the code.

server_uri: ldaps://localhost
bind_dn: cn=admin,dc=example,dc=com
bind_pw: password
validate_cert: no
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, it's not really necessary to demonstrate every option. Please remove this example.

@ansibot ansibot removed ci_verified Changes made in this PR are causing tests to fail. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html labels Apr 27, 2017
@Akasurde
Copy link
Member Author

ready_for_review

@gundalow
Copy link
Contributor

Please change to

   description:
      - If C(no), SSL certificates will not be validated. This should only be used
        on personally controlled sites using self-signed certificates.
   version_added: "2.4"

@jtyr
Copy link
Contributor

jtyr commented Apr 28, 2017

@gundalow I think that it's not necessary to mention that it should only be used on personally controlled sites. I would change it to this:

   description:
      - If C(no), SSL certificates will not be validated. This should only be used
        on sites using self-signed certificates.
   version_added: "2.4"

This fix adds a module option `validate_certs' to check
self-signed certificate of LDAP server.

Fixes ansible#24009

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde
Copy link
Member Author

@jtyr @gundalow ready_for_review

@jtyr
Copy link
Contributor

jtyr commented Apr 28, 2017

@Akasurde LGTM now. Thanks for the contribution.

@ansibot please shipit.

@Akasurde
Copy link
Member Author

@jtyr @gundalow Thanks for comments.

@gundalow gundalow merged commit a3053d8 into ansible:devel May 3, 2017
@gundalow
Copy link
Contributor

gundalow commented May 3, 2017

Merged, thanks for the PR and the reviews.

@Akasurde Akasurde deleted the i24009 branch May 3, 2017 15:33
@Akasurde
Copy link
Member Author

Akasurde commented May 3, 2017

@gundalow Thanks a lot.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. net_tools Net-tools category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ldap_entry and ldap_attr: add validate_certs option
4 participants