ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
822 stars 1.52k forks source link

community.general.rundeck_project: Rundeck response was not a valid JSON. Exception was: Expecting value: line 1 column 1 (char 0). Object was: b'''' #5403

Open ghost opened 2 years ago

ghost commented 2 years ago

Summary

We have problems with the Ansible modules community.general.rundeck_project and community.general.rundeck_acl_policy since the update from Ansible version 5.7.1 to 6.5.0 .

@nerzhul Can you support us here?

Issue Type

Bug Report

Component Name

community.general.rundeck_project community.general.rundeck_acl_policy

Ansible Version

ansible 6.5.0

Community.general Version

community.general 5.7.0

Configuration

OS / Environment

RHEL 8

Steps to Reproduce

How we use them: community.general.rundeck_acl_policy:

- name: "Create or update acl for application"
  community.general.rundeck_acl_policy:
    name: "{{ item.name }}"
    api_version: 14
    force: yes
    url: "https://{{ ansible_hostname }}.{{ option_domain }}:{{ option_tomcat_port }}/{{ option_ecordk_deployment }}"
    token: "{{ ecordk_admin_token }}"
    state: present
    project:
    policy:
      "{{ item.policy }}"
  with_items: "{{ rundeck_acls }}"

community.general.rundeck_project:

- name: "Create rundeck projects"
  community.general.rundeck_project:
    name: "{{ item.name }}"
    api_version: 18
    url: "https://{{ option_rundeck_url }}"
    token: "{{ ecordk_admin_token }}"
    state: present
  with_items:
    - "{{ rdk_ssh_projects }}"
    - "{{ rdk_winrm_projects }}"

We include the rundeck_acls and rdk_ssh_projects lists in our Ansible inventory:

rundeck_acls:
  - name: "admingroup"
    policy:
      description: "Access for admingroup"
      context:
        project: ".*"
      for:
        resource:
          - allow: "*"
        adhoc:
          - allow: "*"
        job:
          - allow: "*"
        node:
          - allow: "*"
      by:
        group: "admingroup"
rdk_ssh_projects:
  - name: "PROJECTNAME1"
    ... (other configs)
  - name: "PROJECTNAME2"
    ... (other configs)
  - name: "PROJECTNAME3"
    ... (other configs)
  - name: "PROJECTNAME4"
    ... (other configs)

Expected Results

ok: [SERVERNAME] => (item={'name': 'admingroup', 'policy': {'description': 'Access for admingroup', 'context': {'project': '.'}, 'for': {'resource': [{'allow': ''}], 'adhoc': [{'allow': ''}], 'job': [{'allow': ''}], 'node': [{'allow': '*'}]}, 'by': {'group': 'admingroup'}}})

ok: [SERVERNAME] => (item={'name': 'PROJECTNAME1'})

Actual Results

Error message for rundeck_acls:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: byte indices must be integers or slices, not str
failed: [SERVERNAME] (item={'name': 'admingroup', 'policy': {'description': 'Access for admingroup', 'context': {'project': '.*'}, 'for': {'resource': [{'allow': '*'}], 'adhoc': [{'allow': '*'}], 'job': [{'allow': '*'}], 'node': [{'allow': '*'}]}, 'by': {'group': 'admingroup'}}}) => changed=false 
  ansible_loop_var: item
  item:
    name: ecordk-eco-infra-project
    policy:
      by:
        group: ecordk-eco-infra
      context:
        project: .*
      description: Access for ecordk-eco-infra
      for:
        adhoc:
        - allow: '*'
        job:
        - allow: '*'
        node:
        - allow: '*'
        resource:
        - allow: '*'
  module_stderr: |-
    Traceback (most recent call last):
      File "<stdin>", line 107, in <module>
      File "<stdin>", line 99, in _ansiballz_main
      File "<stdin>", line 48, in invoke_module
      File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_community.general.rundeck_acl_policy_payload_1dyzur76/ansible_community.general.rundeck_acl_policy_payload.zip/ansible_collections/community/general/plugins/modules/web_infrastructure/rundeck_acl_policy.py", line 256, in <module>
      File "/tmp/ansible_community.general.rundeck_acl_policy_payload_1dyzur76/ansible_community.general.rundeck_acl_policy_payload.zip/ansible_collections/community/general/plugins/modules/web_infrastructure/rundeck_acl_policy.py", line 250, in main
      File "/tmp/ansible_community.general.rundeck_acl_policy_payload_1dyzur76/ansible_community.general.rundeck_acl_policy_payload.zip/ansible_collections/community/general/plugins/modules/web_infrastructure/rundeck_acl_policy.py", line 192, in create_or_update_acl
    TypeError: byte indices must be integers or slices, not str
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

Error message for rdk_ssh_projects:

failed: [SERVERNAME] (item={'name': 'PROJECTNAME1'}) => changed=false 
  ansible_loop_var: item
  item:
    name: PROJECTNAME1
  msg: 'Rundeck response was not a valid JSON. Exception was: Expecting value: line 1 column 1 (char 0). Object was: b'''''

Code of Conduct

ansibullbot commented 2 years ago

Files identified in the description:

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

click here for bot help

ansibullbot commented 2 years ago

cc @nerzhul click here for bot help

felixfontein commented 2 years ago

There seems to have been no functional change in these modules between Ansible 5.7.1 to 6.5.0 (which corresponds to community.general 4.8.0 and 5.7.0). In fact, if you compare https://github.com/ansible-collections/community.general/blob/5.7.0/plugins/modules/web_infrastructure/rundeck_acl_policy.py#L125 and https://github.com/ansible-collections/community.general/blob/4.8.0/plugins/modules/web_infrastructure/rundeck_acl_policy.py#L124, you can see that the only changes were in comments at the top, and in the module's documentation (casing of YAML booleans), which both have no effect on executing the module.

ghost commented 1 year ago

@felixfontein Are you using Rundeck and these modules? If so, with which Ansible version? Currently I can't use the modules anymore, because they don't work with Ansible 6.5.0 anymore.

felixfontein commented 1 year ago

@ronnie-hoffmann I don't use them. (I don't even know what Rundeck is.) I'm just saying that there was no code change in this repository for the modules, so the problem probably comes from shared code in ansible-core or from Rundeck or from some other random change on your system that happened at the same time.

ansibullbot commented 1 year ago

Files identified in the description:

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

click here for bot help