controller_configuration icon indicating copy to clipboard operation
controller_configuration copied to clipboard

workflow error

Open djdanielsson opened this issue 3 years ago • 10 comments

I am trying to figure out if there is a bug in the role or if I have something wrong in the vars.

---
controller_workflows:
  - name: test_workflow
    description: testing issue
    extra_vars: ''
    survey_enabled: false
    allow_simultaneous: true
    ask_variables_on_launch: false
    ask_inventory_on_launch: false
    ask_scm_branch_on_launch: false
    ask_limit_on_launch: true
    webhook_service: ''
    organization: Default
    schedules: []
    simplified_workflow_nodes:
      - all_parents_must_converge: false
        identifier: node001
        unified_job_template: first_template
        credentials: []
        success_nodes: []
        failure_nodes:
          - node002
        always_nodes: []
      - all_parents_must_converge: false
        identifier: node002
        unified_job_template: second_template
        credentials: []
        success_nodes: []
        failure_nodes: []
        always_nodes: []
    notification_templates_started: []
    notification_templates_success: []
    notification_templates_error: []
    notification_templates_approvals: []
    survey_spec: {}
...

I get this error

FAILED! => {"msg": "The conditional check '__workflow_loop_item.state == \"present\"' failed. The error was: error while evaluating conditional (__workflow_loop_item.state == \"present\"): 'dict object' has no attribute 'state'\n\nThe error appears to be in '/home/user/.ansible/collections/ansible_collections/redhat_cop/controller_configuration/roles/workflow_job_templates/tasks/main.yml': line 62, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# Create links between workflow node\n- name: loop over nodes in schema to add to workflow templates\n  ^ here\n"}

I did test removing this line https://github.com/redhat-cop/controller_configuration/blob/8028d7105a183da44915714754ab8f2ebe0d7995/roles/workflow_job_templates/tasks/main.yml#L69 and that works but I am not sure if that is the correct fix or if something else is wrong.

djdanielsson avatar Mar 28 '22 18:03 djdanielsson

bad, never make changes to the main branch like that, and looks like your using the old thing. Change your simplified_workflow_nodes to workflow_nodes

Or put state: present on each node. is the fix.

sean-m-sullivan avatar Mar 29 '22 14:03 sean-m-sullivan

So I don't understand the comment about the main branch. I will try changing simplified_workflow_nodes to workflow_nodes and see if that fixes it.

djdanielsson avatar Mar 29 '22 15:03 djdanielsson

My bad, I misread the REPO, i thought you had made a change to rehdat_cop.controller configuration without a PR, not your own, why did it even alert us of that???

sean-m-sullivan avatar Mar 29 '22 15:03 sean-m-sullivan

it did it because in my commit message i referenced this issue number.

djdanielsson avatar Mar 29 '22 18:03 djdanielsson

when I tried changing from simplified_workflow_nodes to workflow_nodes, I now get.

failed: [localhost] (item={'started': 1, 'finished': 0, 'ansible_job_id': '609216460615.3335960', 'results_file': '/home/user/.ansible_async/609216460615.3335960', 'changed': False, 'failed': False, '__workflow_loop_item': {'name': 'test_workflow', 'description': 'testing issue', 'extra_vars': '', 'survey_enabled': False, 'allow_simultaneous': True, 'ask_variables_on_launch': False, 'ask_inventory_on_launch': False, 'ask_scm_branch_on_launch': False, 'ask_limit_on_launch': True, 'webhook_service': '', 'organization': 'Default', 'schedules': [], 'workflow_nodes': [{'all_parents_must_converge': False, 'identifier': 'node001', 'unified_job_template': 'first_template', 'credentials': [], 'success_nodes': [], 'failure_nodes': ['node002'], 'always_nodes': []}, {'all_parents_must_converge': False, 'identifier': 'node002', 'unified_job_template': 'second_template', 'credentials': [], 'success_nodes': [], 'failure_nodes': [], 'always_nodes': []}], 'notification_templates_started': [], 'notification_templates_success': [], 'notification_templates_error': [], 'notification_templates_approvals': [], 'survey_spec': {}}, 'ansible_loop_var': '__workflow_loop_item'}) => {"__workflows_job_async_results_item": {"__workflow_loop_item": {"allow_simultaneous": true, "ask_inventory_on_launch": false, "ask_limit_on_launch": true, "ask_scm_branch_on_launch": false, "ask_variables_on_launch": false, "description": "called from test_callback", "extra_vars": "", "name": "test_workflow", "notification_templates_approvals": [], "notification_templates_error": [], "notification_templates_started": [], "notification_templates_success": [], "organization": "Default", "schedules": [], "survey_enabled": false, "survey_spec": {}, "webhook_service": "", "workflow_nodes": [{"all_parents_must_converge": false, "always_nodes": [], "credentials": [], "failure_nodes": ["node002"], "identifier": "node001", "success_nodes": [], "unified_job_template": "first_template"}, {"all_parents_must_converge": false, "always_nodes": [], "credentials": [], "failure_nodes": [], "identifier": "node002", "success_nodes": [], "unified_job_template": "second_template"}]}, "ansible_job_id": "609216460615.3335960", "ansible_loop_var": "__workflow_loop_item", "changed": false, "failed": false, "finished": 0, "results_file": "/home/user/.ansible_async/609216460615.3335960", "started": 1}, "ansible_job_id": "609216460615.3335960", "ansible_loop_var": "__workflows_job_async_results_item", "attempts": 2, "changed": false, "cmd": "/home/user/.ansible/tmp/ansible-tmp-1648578006.924557-3335936-265499887576613/AnsiballZ_workflow_job_template.py", "data": "", "finished": 1, "msg": "Traceback (most recent call last):\n  File \"/tmp/ansible_ansible.legacy.async_wrapper_payload_7f4b2zk4/ansible_ansible.legacy.async_wrapper_payload.zip/ansible/modules/async_wrapper.py\", line 162, in _run_module\n  File \"/tmp/ansible_ansible.legacy.async_wrapper_payload_7f4b2zk4/ansible_ansible.legacy.async_wrapper_payload.zip/ansible/modules/async_wrapper.py\", line 90, in _filter_non_json_lines\nValueError: No start of json char found\n", "stderr": "Traceback (most recent call last):\n  File \"/home/user/.ansible/tmp/ansible-tmp-1648578006.924557-3335936-265499887576613/AnsiballZ_workflow_job_template.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/home/user/.ansible/tmp/ansible-tmp-1648578006.924557-3335936-265499887576613/AnsiballZ_workflow_job_template.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/user/.ansible/tmp/ansible-tmp-1648578006.924557-3335936-265499887576613/AnsiballZ_workflow_job_template.py\", line 41, in invoke_module\n    run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_workflow_job_template_payload_6r3szi96/ansible_workflow_job_template_payload.zip/ansible_collections/ansible/controller/plugins/modules/workflow_job_template.py\", line 837, in <module>\n  File \"/tmp/ansible_workflow_job_template_payload_6r3szi96/ansible_workflow_job_template_payload.zip/ansible_collections/ansible/controller/plugins/modules/workflow_job_template.py\", line 828, in main\n  File \"/tmp/ansible_workflow_job_template_payload_6r3szi96/ansible_workflow_job_template_payload.zip/ansible_collections/ansible/controller/plugins/modules/workflow_job_template.py\", line 484, in create_schema_nodes\nTypeError: string indices must be integers\n", "stderr_lines": ["Traceback (most recent call last):", "  File \"/home/user/.ansible/tmp/ansible-tmp-1648578006.924557-3335936-265499887576613/AnsiballZ_workflow_job_template.py\", line 100, in <module>", "    _ansiballz_main()", "  File \"/home/user/.ansible/tmp/ansible-tmp-1648578006.924557-3335936-265499887576613/AnsiballZ_workflow_job_template.py\", line 92, in _ansiballz_main", "    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)", "  File \"/home/user/.ansible/tmp/ansible-tmp-1648578006.924557-3335936-265499887576613/AnsiballZ_workflow_job_template.py\", line 41, in invoke_module", "    run_name='__main__', alter_sys=True)", "  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_workflow_job_template_payload_6r3szi96/ansible_workflow_job_template_payload.zip/ansible_collections/ansible/controller/plugins/modules/workflow_job_template.py\", line 837, in <module>", "  File \"/tmp/ansible_workflow_job_template_payload_6r3szi96/ansible_workflow_job_template_payload.zip/ansible_collections/ansible/controller/plugins/modules/workflow_job_template.py\", line 828, in main", "  File \"/tmp/ansible_workflow_job_template_payload_6r3szi96/ansible_workflow_job_template_payload.zip/ansible_collections/ansible/controller/plugins/modules/workflow_job_template.py\", line 484, in create_schema_nodes", "TypeError: string indices must be integers"]}

and when looking at the code it looks like it still is expecting simplified_workflow_nodes https://github.com/redhat-cop/controller_configuration/blob/8028d7105a183da44915714754ab8f2ebe0d7995/roles/workflow_job_templates/tasks/main.yml#L68

djdanielsson avatar Mar 29 '22 18:03 djdanielsson

we figured out the issue, README example needs to be updated. I will leave this issue open until that happens.

djdanielsson avatar Apr 01 '22 13:04 djdanielsson

if you look at the blog post linked in #304 it should help someone rewrite this example

djdanielsson avatar Jul 07 '22 21:07 djdanielsson

It's not the only example that is out of date, it seems. I used the templates.yml example. It refused to also create the survey until I wrapped the survey spec in a "related:" entry.

fvzwieten avatar Jul 21 '22 09:07 fvzwieten

@fvzwieten PRs are welcome, but I agree we do have a lot of examples that are currently out of data

djdanielsson avatar Jul 21 '22 13:07 djdanielsson

This appears to be related to the other issue that lead down the path of examples being added to the repo in the roles default/main.yml, README.md and perhaps other areas. It becomes really hard to maintain these all the time unless they are placed as actual playbooks in a tests folder that are triggered in CI pipeline (feature request for future).

Suggest referencing our module docs that provide examples at the bottom and are properly maintained. For example:

https://docs.ansible.com/ansible/latest/collections/awx/awx/workflow_job_template_module.html#examples

Understandably, we would have 2 links (for certified collection and community, but...) and having to deal with related versions. For example, version X of this collection should map or support version Y of the awx.awx collection (since we support those fields on those modules, etc).

ansiblejunky avatar Sep 21 '22 00:09 ansiblejunky