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

asa_og: When using integers in task for port-object group types getting errors #58258

Open
jvanderaa opened this issue Jun 23, 2019 · 7 comments

Comments

Projects
None yet
5 participants
@jvanderaa
Copy link
Contributor

commented Jun 23, 2019

SUMMARY

First attempt of using asa_og for port-group creation and you are using integers in the task parameter port_eq the module comes back with a concatenation error.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

asa_og

ANSIBLE VERSION
ansible --version
ansible 2.8.1
  config file = /Users/joshv/Github/ansible-asa_work/ansible.cfg
  configured module search path = ['/etc/ansible/library']
  ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.2 (default, Feb 10 2019, 15:44:18) [Clang 10.0.0 (clang-1000.11.45.5)]
CONFIGURATION
DEFAULT_HOST_LIST(/Users/joshv/Github/ansible-asa_work/ansible.cfg) = ['/Users/joshv/Github/ansible-asa_work/hosts']
DEFAULT_MODULE_PATH(/Users/joshv/Github/ansible-asa_work/ansible.cfg) = ['/etc/ansible/library']
HOST_KEY_CHECKING(/Users/joshv/Github/ansible-asa_work/ansible.cfg) = False
INTERPRETER_PYTHON(/Users/joshv/Github/ansible-asa_work/ansible.cfg) = /usr/local/bin/python3
OS / ENVIRONMENT

Mac OS as command host
ASAv in lab environment

STEPS TO REPRODUCE
    - name: "TASK 3: Add Port Group"
      asa_og:
        name: SVC_OBJ_DNS_NTP
        group_type: port-object
        state: present
        description: DNS and NTP ports
        protocol: udp
        port_eq:
          - 53
          - 123
      register: output3

Workaround task setup:

    - name: "TASK 3: Add Port Group"
      asa_og:
        name: SVC_OBJ_DNS_NTP
        group_type: port-object
        state: present
        description: DNS and NTP ports
        protocol: udp
        port_eq:
          - "53"
          - "123"
      register: output3
EXPECTED RESULTS

I'd expect that the object group would be created.

ACTUAL RESULTS

The module errors out on playbook execution.

Workaround: Change the integers to strings to avoid integer/string concatenation issues

fatal: [asa1]: FAILED! => {"changed": false, "module_stderr": "/Users/joshv/.ansible/tmp/ansible-local-49807bxzhne75/ansible-tmp-1561309596.022644-207996390419631/AnsiballZ_asa_og.py:18: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Traceback (most recent call last):
  File \"/Users/joshv/.ansible/tmp/ansible-local-49807bxzhne75/ansible-tmp-1561309596.022644-207996390419631/AnsiballZ_asa_og.py\", line 114, in <module>
    _ansiballz_main()
  File \"/Users/joshv/.ansible/tmp/ansible-local-49807bxzhne75/ansible-tmp-1561309596.022644-207996390419631/AnsiballZ_asa_og.py\", line 106, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/Users/joshv/.ansible/tmp/ansible-local-49807bxzhne75/ansible-tmp-1561309596.022644-207996390419631/AnsiballZ_asa_og.py\", line 49, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File \"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py\", line 234, in load_module
    return load_source(name, filename, file)
  File \"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py\", line 169, in load_source
    module = _exec(spec, sys.modules[name])
  File \"<frozen importlib._bootstrap>\", line 630, in _exec
  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module
  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed
  File \"/var/folders/cf/m5ysrq0j1vn8y0s8_67j4hyw0000gn/T/ansible_asa_og_payload_8oc36h_s/__main__.py\", line 801, in <module>
  File \"/var/folders/cf/m5ysrq0j1vn8y0s8_67j4hyw0000gn/T/ansible_asa_og_payload_8oc36h_s/__main__.py\", line 788, in main
  File \"/var/folders/cf/m5ysrq0j1vn8y0s8_67j4hyw0000gn/T/ansible_asa_og_payload_8oc36h_s/__main__.py\", line 735, in map_obj_to_commands
  File \"/var/folders/cf/m5ysrq0j1vn8y0s8_67j4hyw0000gn/T/ansible_asa_og_payload_8oc36h_s/__main__.py\", line 557, in present
TypeError: can only concatenate str (not \"int\") to str
", "module_stdout": "", "msg": "MODULE FAILURE
See stdout/stderr for the exact error", "rc": 1}
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 23, 2019

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 23, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 23, 2019

@jvanderaa, 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

@NilashishC

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2019

cc @FedericoOlivieri - could you have a look at this? :)

@ansibot ansibot removed the needs_triage label Jul 1, 2019

@justjais

This comment has been minimized.

Copy link
Contributor

commented Jul 2, 2019

@FedericoOlivieri please update the module file with your correct Github username, currently, it's federico87 which is wrong I suppose.

@FedericoOlivieri

This comment has been minimized.

Copy link
Contributor

commented Jul 2, 2019

Hi guys. I' ll be on road trip until end of September so I won' t be able to work on this :)

@jvanderaa

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2019

Would an appropriate fix be change the concatenation to being more of a string replacement?

Python 3.7.1 (default, Nov  6 2018, 18:46:03)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> commands = []
>>> i = 5
>>> commands.append("port-object eq " + i)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "int") to str
>>> commands.append("port-object eq %s" % i)
>>> commands
['port-object eq 5']

@jvanderaa jvanderaa referenced a pull request that will close this issue Jul 14, 2019

Open

Changed concatentation to string formatting. #59073

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.