ansible / ansible-content-parser

Apache License 2.0
3 stars 4 forks source link

"No module name was found" error is thrown when a task with local_action is included in a playbook #38

Closed TamiTakamiya closed 4 months ago

TamiTakamiya commented 5 months ago

When a task that uses local_action is defined in a separate task file and a playbook includes the task file, running ansible-content-parser with -S option throws an error:

test_project/tasks.yml

- name: Run debug module with local_action
  local_action:
    module: debug
    msg: Run debug module with local_action
  become: false

test_project/playbook.yml

- name: Test
  hosts: all
  tasks:
    - name: Include tasks
      include_tasks:
        file: tasks.yml

(these two files are contained in test_project.zip)

$ ansible-content-parser test_project /var/tmp/test/out8 -S
INFO:pipeline:Running data pipeline
INFO:pipeline:Start scanning for 1 projects (total 3 files)
INFO:pipeline:Done
ERROR:ansible_content_parser.report:No module name was found in a task: {"py/object": "sage_scan.models.Task", "type": "task", "key": "task taskfile:tasks.yml#task:[0]", "name": "Run debug module with local_action", "source": {"data_source_description": "", "license": "", "repo_name": "test_project", "repo_url": "file:///home/ttakamiy/git/TamiTakamiya/test_project"}, "source_id": "{\"data_source_description\":\"\",\"license\":\"\",\"repo_name\":\"test_project\",\"repo_url\":\"file:///home/ttakamiy/git/TamiTakamiya/test_project\"}", "test_object": false, "annotations": {"module.suggested_fqcn": [], "module.suggested_dependency": [], "module.resolved_fqcn": "", "module.wrong_module_name": "", "module.not_exist": true, "module.correct_fqcn": "", "module.need_correction": true, "module.examples": "", "variable.undefined_vars": [], "variable.unknown_name_vars": []}, "variables": {}, "module": "", "index": 0, "play_index": -1, "filepath": "tasks.yml", "role": "", "collection": "", "become": {"py/object": "ansible_risk_insight.models.BecomeInfo", "enabled": false, "become": "", "user": "", "method": "", "flags": ""}, "module_defaults": {}, "registered_variables": {}, "set_facts": {}, "loop": {}, "options": {"name": "Run debug module with local_action", "local_action": {"module": "debug", "msg": "Run debug module with local_action"}, "become": false}, "module_options": {}, "executable": "", "executable_type": "Module", "collections_in_play": [], "yaml_lines": "- name: Run debug module with local_action\n  local_action:\n    module: debug\n    msg: Run debug module with local_action\n  become: false", "line_num_in_file": [1, 6], "resolved_name": "", "possible_candidates": [], "module_info": {}, "include_info": {}}
TamiTakamiya commented 5 months ago

@hirokuni-kitahara Could you take a look at this? sage-scan can the task file itself, but there seem some issues exist when such task file is icluded in a playbook. Thank you.

TamiTakamiya commented 4 months ago

I updated ansible-risk-insight to 0.2.7 with the following command:

pip install -U ansible-risk-insight

and verified the problem was no longer found. Closing the issue.