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 source interface parameter to ios_logging #49766

Closed
wants to merge 5 commits into from
Closed

add source interface parameter to ios_logging #49766

wants to merge 5 commits into from

Conversation

lvrfrc87
Copy link
Contributor

@lvrfrc87 lvrfrc87 commented Dec 11, 2018

SUMMARY

Add arguments to support source interface for logging host

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ios_logging

@ansibot
Copy link
Contributor

ansibot commented Dec 11, 2018

@ansibot
Copy link
Contributor

ansibot commented Dec 11, 2018

@FedericoOlivieri, just so you are aware we have a dedicated Working Group for network.
You can find other people interested in this in #ansible-network on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. networking Network category new_contributor This PR is the first contribution by a new community member. support:network This issue/PR relates to code supported by the Ansible Network Team. labels Dec 11, 2018
@ansibot
Copy link
Contributor

ansibot commented Dec 11, 2018

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

lib/ansible/modules/network/ios/ios_logging.py:0:0: E322 "source" is listed in the argument_spec, but not documented in the module

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Dec 11, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Dec 11, 2018
@ansibot
Copy link
Contributor

ansibot commented Dec 11, 2018

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

lib/ansible/modules/network/ios/ios_logging.py:0:0: E309 version_added for new option (source) should be 2.8. Currently 0.0

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Dec 11, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Dec 11, 2018
@ansibot
Copy link
Contributor

ansibot commented Dec 11, 2018

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

lib/ansible/modules/network/ios/ios_logging.py:0:0: E309 version_added for new option (source) should be 2.8. Currently 0.0

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Dec 11, 2018
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Dec 12, 2018
@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Dec 12, 2018
@NilashishC
Copy link
Contributor

@FedericoOlivieri Thanks a lot for this feature PR. The same option is defined as the interface parameter in the nxos_logging module and it would be great if the parameter names are consistent across all the platforms.
Also, could you please add some integration tests for this feature?

for consistency with nxos module
@lvrfrc87
Copy link
Contributor Author

lvrfrc87 commented Dec 13, 2018

@NilashishC I have updated the code as required. I have noticed 2 things that they don't work as expected and I might need for you support because I cannot figure out what is wrong:

  • Module is not Idempotent for source interface
changed: [uk-tempvpn8] => {
    "changed": true,
    "commands": [
        "logging source-interface FastEthernet0",
        "logging host 8.8.8.8"
    ],
    "invocation": {
        "module_args": {
            "aggregate": null,
            "auth_pass": null,
            "authorize": null,
            "dest": "host",
            "facility": null,
            "host": null,
            "level": "notifications",
            "name": "8.8.8.8",
            "password": null,
            "port": null,
            "provider": {
                "auth_pass": null,
                "authorize": null,
                "host": "10.108.49.161",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "username": "federico.olivieri"
            },
            "size": null,
            "source": "FastEthernet0",
            "ssh_keyfile": null,
            "state": "present",
            "timeout": null,
            "username": null
        }
    }
}
  • Absent is not working as expected. That it happen for other parameters, not just for source interface. I see command list is always empty.
ok: [uk-tempvpn8] => {
    "changed": false,
    "commands": [],
    "invocation": {
        "module_args": {
            "aggregate": null,
            "auth_pass": null,
            "authorize": null,
            "dest": null,
            "facility": null,
            "host": null,
            "level": "notifications",
            "name": null,
            "password": null,
            "port": null,
            "provider": {
                "auth_pass": null,
                "authorize": null,
                "host": "10.108.49.161",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "username": "federico.olivieri"
            },
            "size": null,
            "source": null,
            "ssh_keyfile": null,
            "state": "absent",
            "timeout": null,
            "username": null
        }
    }
}

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Dec 13, 2018
Copy link
Contributor

@NilashishC NilashishC left a comment

Choose a reason for hiding this comment

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

@FedericoOlivieri There appears to be a couple of different issues with the changes you made. Have a look at https://www.diffchecker.com/776O6EV0. I have made the required changes for this parameter to be idempotent.

Also, please note that configuring a logging interface should be a separate task and should not be combined with other parameters such as host in order for the module to function properly(i.e, be idempotent).

A brief example would be:

tasks:
    - name: Configure Interface
      ios_logging:
        interface: GigabitEthernet0/1
        state: present

    - name: Configure Host
      ios_logging:
        dest: host
        name: 8.8.8.8
        state: present

Edit: A comment below demonstrates the same with aggregate.

@lvrfrc87
Copy link
Contributor Author

@NilashishC Thanks for your help. Just a question as I cannot figure out from the code: why the source interface has to be put in a separate task and not with the others?

@NilashishC
Copy link
Contributor

@FedericoOlivieri The way the module currently works is - the map_config_to_obj function reads each line in the output of show running configuration | include logging and forms a dictionary for each line. So essentially, have and want both are list of dictionaries.

So for the following output of show running configuration | include logging:

logging source-interface GigabitEthernet0/1
logging host 8.8.8.8
have = [{'dest': None, 'facility': None, 'interface': u'GigabitEthernet0/1', 'level': 'debugging', 'name': None, 'size': None}, {'dest': u'host', 'facility': None, 'interface': None, 'level': 'debugging', 'name': u'8.8.8.8', 'size': None}]

If we specify host and interface configurations in the same task(without using aggregate), want would look like:

want=[{'dest': 'host', 'facility': None, 'interface': 'GigabitEthernet0/1', 'level': 'debugging', 'name': '8.8.8.8', 'size': None, 'state': 'present'}]

In essence, that would be a single dictionary with both the configurations.

Evidently, in this scenario, idempotency would not be preserved.

A better approach to this would be using aggregate:

tasks:
  ios_logging:
    aggregate:
      - { dest: host, name: 8.8.8.8, state: present }
      - { interface: GigabitEthernet0/1, state: present }

@lvrfrc87
Copy link
Contributor Author

Thanks for the explanation. :)

@NilashishC
Copy link
Contributor

NilashishC commented Dec 19, 2018

@FedericoOlivieri It would be great if you could make the suggested changes so that we can go ahead and merge this PR. Thanks!

@lvrfrc87
Copy link
Contributor Author

@NilashishC Which changes are we talking about? I understand you amended the code :) Is that right?

@NilashishC
Copy link
Contributor

@FedericoOlivieri Actually, I did not amend the code. Based on your work, I pointed to the places which needs changes. A commit including those changes and some tests would be great!

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Dec 28, 2018
@ansibot ansibot added the needs_repo This PR no longer has an associated branch as it was removed by the submitter. label Jan 13, 2019
@Qalthos Qalthos changed the title add source interface add source interface parameter to ios_logging Jan 22, 2019
@abenokraitis abenokraitis added waiting_on_contributor This would be accepted but there are no plans to actively work on it. needs_info This issue requires further information. Please answer any outstanding questions. labels Jan 22, 2019
@abenokraitis
Copy link
Contributor

@FedericoOlivieri Greetings, just checking in on this - are you still supporting this PR? If so please let us know, else we will close this. Thanks!

@ansibot ansibot added the feature This issue/PR relates to a feature request. label Jan 22, 2019
@ansibot ansibot removed the new_contributor This PR is the first contribution by a new community member. label Feb 7, 2019
@dagwieers dagwieers added ios Cisco IOS community cisco Cisco technologies labels Feb 22, 2019
@ansibot
Copy link
Contributor

ansibot commented Mar 2, 2019

@FedericoOlivieri This pullrequest is waiting for your response. Please respond or the pullrequest will be closed.

click here for bot help

@lvrfrc87 lvrfrc87 closed this Mar 4, 2019
@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
@sivel sivel removed the waiting_on_contributor This would be accepted but there are no plans to actively work on it. label Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 cisco Cisco technologies feature This issue/PR relates to a feature request. ios Cisco IOS community module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. needs_repo This PR no longer has an associated branch as it was removed by the submitter. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. networking Network category stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:network This issue/PR relates to code supported by the Ansible Network Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants