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

ios_config #macro keywords ignored in 'macro name' command by difference() #43861

Closed
yaplej opened this issue Aug 9, 2018 · 7 comments
Closed
Assignees
Labels
affects_2.6 This issue/PR affects Ansible v2.6 bug This issue/PR relates to a bug. cisco Cisco technologies collection:cisco.ios collection Related to Ansible Collections work ios Cisco IOS community module This issue/PR relates to a module. needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md networking Network category support:community This issue/PR relates to code supported by the Ansible community.

Comments

@yaplej
Copy link
Contributor

yaplej commented Aug 9, 2018

SUMMARY

When using ios_config to push out 'macro' interface templates the '#macro keywords ...' line is ignored and triggers a change for the playbook run.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ios_config

ANSIBLE VERSION
ansible 2.6.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

CONFIGURATION

HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30

OS / ENVIRONMENT

N/A

STEPS TO REPRODUCE

Fix timeout issue with using 'macro name' command first.
#38420

Re-run playbook several time and will repeatedly apply because of the '#macro keywords' line.

---

- hosts: access_switches

  tasks:

  - name: MACRO PHONE
    ios_config:
      provider:
        timeout: 60
      lines:
      - 'switchport voice vlan 60'
      - 'switchport port-security maximum 5'
      - 'spanning-tree portfast'
      - 'no cdp enable'
      - 'no macro desc'
      - '#macro keywords $DESCRIPTION'
      before: no macro name PHONE
      after: '@'
      parents: macro name PHONE
      match: line
      replace: block
EXPECTED RESULTS

Playbook applies once and not again.

ACTUAL RESULTS

Playbook is applied for every run.

PLAY [access_switches] **********************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************
ok: [1.1.1.1]

TASK [MACRO PHONE] **************************************************************************************************************************************************************************
changed: [1.1.1.1]

PLAY RECAP **********************************************************************************************************************************************************************************
1.1.1.1                : ok=2    changed=1    unreachable=0    failed=0

[root@fccu24em ansible]#  ansible-playbook -i production ./roles/network/access/macros/MACRO_PHONE.yml --limit 1.1.1.1 -vvvv
ansible-playbook 2.6.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /etc/ansible/production inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: MACRO_PHONE.yml *******************************************************************************************************************************************************************
1 plays in ./roles/network/access/macros/MACRO_PHONE.yml

PLAY [access_switches] **********************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************
task path: /etc/ansible/roles/network/access/macros/MACRO_PHONE.yml:3
<1.1.1.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<1.1.1.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<1.1.1.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1533790895.89-113209771700314 `" && echo ansible-tmp-1533790895.89-113209771700314="` echo /root/.ansible/tmp/ansible-tmp-1533790895.89-113209771700314 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py
<1.1.1.1> PUT /root/.ansible/tmp/ansible-local-24746xz3QVR/tmpII9McO TO /root/.ansible/tmp/ansible-tmp-1533790895.89-113209771700314/setup.py
<1.1.1.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1533790895.89-113209771700314/ /root/.ansible/tmp/ansible-tmp-1533790895.89-113209771700314/setup.py && sleep 0'
<1.1.1.1> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1533790895.89-113209771700314/setup.py && sleep 0'
<1.1.1.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1533790895.89-113209771700314/ > /dev/null 2>&1 && sleep 0'
ok: [1.1.1.1]
META: ran handlers

TASK [MACRO PHONE] **************************************************************************************************************************************************************************
task path: /etc/ansible/roles/network/access/macros/MACRO_PHONE.yml:7
<1.1.1.1> using connection plugin network_cli (was local)
<1.1.1.1> starting connection from persistent connection plugin
<1.1.1.1> local domain socket does not exist, starting it
<1.1.1.1> control socket path is /root/.ansible/pc/43ee95be21
<1.1.1.1> <1.1.1.1> ESTABLISH CONNECTION FOR USER: service.ansible on PORT 22 TO 1.1.1.1
<1.1.1.1> <1.1.1.1> ssh connection done, setting terminal
<1.1.1.1> <1.1.1.1> loaded terminal plugin for network_os ios
<1.1.1.1> <1.1.1.1> loaded cliconf plugin for network_os ios
<1.1.1.1> <1.1.1.1> firing event: on_open_shell()
<1.1.1.1> <1.1.1.1> ssh connection has completed successfully
<1.1.1.1> connection to remote device started successfully
<1.1.1.1> local domain socket listeners started successfully
<1.1.1.1>
<1.1.1.1> local domain socket path is /root/.ansible/pc/43ee95be21
<1.1.1.1> socket_path: /root/.ansible/pc/43ee95be21
<1.1.1.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<1.1.1.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<1.1.1.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1533790903.65-64007230356365 `" && echo ansible-tmp-1533790903.65-64007230356365="` echo /root/.ansible/tmp/ansible-tmp-1533790903.65-64007230356365 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_config.py
<1.1.1.1> PUT /root/.ansible/tmp/ansible-local-24746xz3QVR/tmpWFXdCO TO /root/.ansible/tmp/ansible-tmp-1533790903.65-64007230356365/ios_config.py
<1.1.1.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1533790903.65-64007230356365/ /root/.ansible/tmp/ansible-tmp-1533790903.65-64007230356365/ios_config.py && sleep 0'
<1.1.1.1> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1533790903.65-64007230356365/ios_config.py && sleep 0'
<1.1.1.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1533790903.65-64007230356365/ > /dev/null 2>&1 && sleep 0'
changed: [1.1.1.1] => {
    "banners": {},
    "changed": true,
    "commands": [
        "no macro name PHONE",
        "macro name PHONE",
        "switchport voice vlan 60",
        "switchport port-security maximum 5",
        "spanning-tree portfast",
        "no cdp enable",
        "no macro desc",
        "#macro keywords $DESCRIPTION",
        "@"
    ],
    "invocation": {
        "module_args": {
            "after": [
                "@"
            ],
            "auth_pass": null,
            "authorize": null,
            "backup": false,
            "before": [
                "no macro name PHONE"
            ],
            "defaults": false,
            "diff_against": null,
            "diff_ignore_lines": null,
            "force": false,
            "host": null,
            "intended_config": null,
            "lines": [
                "switchport voice vlan 60",
                "switchport port-security maximum 5",
                "spanning-tree portfast",
                "no cdp enable",
                "no macro desc",
                "#macro keywords $DESCRIPTION"
            ],
            "match": "line",
            "multiline_delimiter": "@",
            "parents": [
                "macro name PHONE"
            ],
            "password": null,
            "port": null,
            "provider": {
                "auth_pass": null,
                "authorize": null,
                "host": null,
                "password": null,
                "port": null,
                "ssh_keyfile": null,
                "timeout": 60,
                "username": null
            },
            "replace": "block",
            "running_config": null,
            "save": false,
            "save_when": "never",
            "src": null,
            "ssh_keyfile": null,
            "timeout": null,
            "username": null
        }
    },
    "updates": [
        "no macro name PHONE",
        "macro name PHONE",
        "switchport voice vlan 60",
        "switchport port-security maximum 5",
        "spanning-tree portfast",
        "no cdp enable",
        "no macro desc",
        "#macro keywords $DESCRIPTION",
        "@"
    ]
}
META: ran handlers
META: ran handlers

PLAY RECAP **********************************************************************************************************************************************************************************
1.1.1.1                : ok=2    changed=1    unreachable=0    failed=0
@yaplej
Copy link
Contributor Author

yaplej commented Aug 9, 2018

Workaround by removing '#' from DEFAULT_COMMENT_TOKENS in module_utils/network/common/config.py to get desired results.

ok: [1.1.1.1] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "after": [
                "@"
            ],
            "auth_pass": null,
            "authorize": null,
            "backup": false,
            "before": [
                "no macro name PHONE"
            ],
            "defaults": false,
            "diff_against": null,
            "diff_ignore_lines": null,
            "force": false,
            "host": null,
            "intended_config": null,
            "lines": [
                "switchport voice vlan 60",
                "switchport port-security maximum 5",
                "spanning-tree portfast",
                "no cdp enable",
                "no macro desc",
                "#macro keywords $DESCRIPTION"
            ],
            "match": "line",
            "multiline_delimiter": "@",
            "parents": [
                "macro name PHONE"
            ],
            "password": null,
            "port": null,
            "provider": {
                "auth_pass": null,
                "authorize": null,
                "host": null,
                "password": null,
                "port": null,
                "ssh_keyfile": null,
                "timeout": 60,
                "username": null
            },
            "replace": "block",
            "running_config": null,
            "save": false,
            "save_when": "never",
            "src": null,
            "ssh_keyfile": null,
            "timeout": null,
            "username": null
        }
    }
}

@ansibot
Copy link
Contributor

ansibot commented Aug 9, 2018

@ansibot ansibot added affects_2.6 This issue/PR affects Ansible v2.6 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. networking Network category support:network This issue/PR relates to code supported by the Ansible Network Team. labels Aug 9, 2018
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Aug 13, 2018
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:network This issue/PR relates to code supported by the Ansible Network Team. labels Sep 17, 2018
@ansibot ansibot added support:network This issue/PR relates to code supported by the Ansible Network Team. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 3, 2018
@abenokraitis
Copy link
Contributor

Greetings, we are still reviewing this issue. Stay tuned! :-)

@yaplej
Copy link
Contributor Author

yaplej commented Feb 19, 2019

Thanks for the update. Looking forward to having this fixed so I no longer have to modify the DEFAULT_COMMENT_TOKENS each time I update.

@dagwieers dagwieers added ios Cisco IOS community cisco Cisco technologies labels Feb 22, 2019
@Qalthos Qalthos self-assigned this May 14, 2019
@ansibot
Copy link
Contributor

ansibot commented Jun 23, 2019

@pabelanger
Copy link
Contributor

@justjais do you have anything thoughts here? This was raised in our community meeting today

@ansibot ansibot added collection Related to Ansible Collections work collection:cisco.ios needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md support:community This issue/PR relates to code supported by the Ansible community. and removed support:network This issue/PR relates to code supported by the Ansible Network Team. labels Apr 29, 2020
@Qalthos
Copy link
Contributor

Qalthos commented Jun 23, 2020

Thank you very much for your interest in Ansible. This plugin is no longer maintained in this repository and has been migrated to https://github.com/ansible-collections/cisco.ios

Please re-submit this issue in the above repository.

If you have further questions please stop by IRC or the mailing list:

@Qalthos Qalthos closed this as completed Jun 23, 2020
@ansible ansible locked and limited conversation to collaborators Jul 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.6 This issue/PR affects Ansible v2.6 bug This issue/PR relates to a bug. cisco Cisco technologies collection:cisco.ios collection Related to Ansible Collections work ios Cisco IOS community module This issue/PR relates to a module. needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md networking Network category support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

No branches or pull requests

8 participants