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

Add module read_mail #57357

Open
wants to merge 14 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@caiohsramos
Copy link
Contributor

commented Jun 4, 2019

SUMMARY

Developing new module read_mail with IMAP standart lib

Fixes #51151

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

read_mail.py

ADDITIONAL INFORMATION

Usage example:

- read_mail:
    host: "{{ imap_host }}"
    username: "{{ imap_user }}"
    password: "{{ imap_password }}"
    ssl: True
    filter:
      subject: "subject_should_contain_this"
      from: "email@example.com"
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

The test ansible-test sanity --test boilerplate [explain] failed with 2 errors:

lib/ansible/modules/net_tools/basics/read_mail.py:0:0: missing: __metaclass__ = type
lib/ansible/modules/net_tools/basics/read_mail.py:0:0: missing: from __future__ import (absolute_import, division, print_function)

The test ansible-test sanity --test validate-modules [explain] failed with 4 errors:

lib/ansible/modules/net_tools/basics/read_mail.py:0:0: E305 DOCUMENTATION.author: Invalid author for dictionary value @ data['author']. Got ['Caio Ramos (@caiohsramos)', 'Gabriely Rangel (@)']
lib/ansible/modules/net_tools/basics/read_mail.py:0:0: E307 version_added should be '2.9'. Currently '2.8'
lib/ansible/modules/net_tools/basics/read_mail.py:0:0: E327 Argument 'filter' in documentation defines default as ('ALL') but this is incompatible with parameter type 'dict'
lib/ansible/modules/net_tools/basics/read_mail.py:0:0: E327 Argument 'port' in documentation defines default as ('993 or 143') but this is incompatible with parameter type 'int'

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:7:0: misplaced-future __future__ import is not the first non docstring statement

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:7:1: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:0:0: E321 Exception attempting to import module for argument_spec introspection, 'from __future__ imports must occur at the beginning of the file (read_mail.py, line 7)'

click here for bot help

@ansibot ansibot removed the ci_verified label Jun 5, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:0:0: E327 Argument 'port' in documentation defines default as ('None') but this is incompatible with parameter type 'int'

click here for bot help

@ansibot ansibot added ci_verified and removed ci_verified labels Jun 5, 2019

@caiohsramos caiohsramos changed the title [WIP] Add module read_mail Add module read_mail Jun 5, 2019

@caiohsramos

This comment has been minimized.

Copy link
Contributor Author

commented Jun 5, 2019

ready_for_review

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2019

@jpmens @mpdehaan @ptux

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot ansibot added community_review and removed WIP labels Jun 5, 2019

version_added: "2.9"
description:
- "Get emails from a IMAP server using basic filtering rules an returns an email count and list"

This comment has been minimized.

Copy link
@jpmens

jpmens Jun 6, 2019

Contributor

"rules and return"

This comment has been minimized.

Copy link
@jpmens

jpmens Jun 6, 2019

Contributor

I think it would also be useful to indicate what this module is actually intended for, by which I mean "why would I want to use it" in a configuration management scenario.

This comment has been minimized.

Copy link
@caiohsramos

caiohsramos Jun 6, 2019

Author Contributor

Thank you for the review! My main motivation was to solve the issue mentioned in the description and marked as "waiting_on_contributor" by a contributor. I added a intended use case in the module description of what I think this module would be useful

Show resolved Hide resolved lib/ansible/modules/net_tools/basics/read_mail.py Outdated
Show resolved Hide resolved lib/ansible/modules/net_tools/basics/read_mail.py Outdated
- Whether to use SSL or not
required: false
default: true
mailbox:

This comment has been minimized.

Copy link
@jpmens

jpmens Jun 6, 2019

Contributor

an example using mailbox in EXAMPLES below would be useful; i.e. what does mailbox look like?


EXAMPLES = '''
# simplest use
- name: Read mails

This comment has been minimized.

Copy link
@jpmens

jpmens Jun 6, 2019

Contributor

"read mails" and do what with them? Here again, I would like to see use cases.

This comment has been minimized.

Copy link
@caiohsramos

caiohsramos Jun 6, 2019

Author Contributor

I will work on some more complex examples (something more like a "real world example")

Show resolved Hide resolved lib/ansible/modules/net_tools/basics/read_mail.py
description: The username used in the request
type: str
returned: always
mails:

This comment has been minimized.

Copy link
@jpmens

jpmens Jun 6, 2019

Contributor

if just the mail headers are returned: where do I obtain the mail body itself?

This comment has been minimized.

Copy link
@caiohsramos

caiohsramos Jun 6, 2019

Author Contributor

I'll add a field with the email's body and think of some use cases for that

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:26:78: W291 trailing whitespace

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:113:54: E313 RETURN is not valid YAML

The test ansible-test sanity --test yamllint [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:113:54: error RETURN: syntax error: mapping values are not allowed here

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:115:5: E313 RETURN is not valid YAML

The test ansible-test sanity --test yamllint [explain] failed with 1 error:

lib/ansible/modules/net_tools/basics/read_mail.py:115:5: error RETURN: syntax error: could not find expected ':'

click here for bot help

@ansibot ansibot added ci_verified and removed ci_verified labels Jun 6, 2019

@gprangel gprangel force-pushed the caiohsramos:add-module-read_mail branch from b5d9895 to 7ee4cb6 Jun 7, 2019

@gprangel gprangel force-pushed the caiohsramos:add-module-read_mail branch from 7ee4cb6 to 02a06e1 Jun 7, 2019

@ansibot ansibot added the stale_ci label Jun 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.