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

Inventory Script parsed but job status is error #13396

Closed
3 tasks done
0x7081 opened this issue Jan 3, 2023 · 3 comments
Closed
3 tasks done

Inventory Script parsed but job status is error #13396

0x7081 opened this issue Jan 3, 2023 · 3 comments

Comments

@0x7081
Copy link

0x7081 commented Jan 3, 2023

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that the AWX Operator is open source software provided for free and that I might not receive a timely response.

Bug Summary

I have created a Python script that acts as an inventory script.
For this a normal Inventory was created and a Source "Sourced from a Project", also a new Execution Environment was created, but this is completely standard and contains only additionally the Python "requests" Package.

When I now start a sync of the inventory source, the script runs and I get at the end the message Parsed /runner/project/[Scriptname].py inventory source with script plugin but the status of the job is Error and no hosts were added to the inventory.

I have already tested the script locally with the ansible-inventory command, also it works on an old AWX environment (14.1.0) without problems.
I have also already checked if the script delivers any output at all and display it, it generates a JSON, only the operator can't do anything with it or doesn't process it further.

The script was written to accept the parameters --list and --host and generate a JSON output.
The script includes about 1200 hosts and 63 groups.

Does anyone know where the problem is? Is it the number of hosts?
The AWX Operator environment is running on AWS EKS.

AWX Operator version

1.1.3

AWX version

21.10.3

Kubernetes platform

kubernetes

Kubernetes/Platform version

1.24

Modifications

no

Steps to reproduce

Unfortunately it is a bit complicated to recreate the whole thing, because it is a self-written Python script.

To reproduce it you have to create a new inventory, with a source "Sourced from a project", here I put a Python script, which takes the parameters --list and --host.

The whole thing is executed on a new execution environment, based on the default image including the Python package "requests".

At the end the script outputs a JSON file with about 1200 hosts and 63 groups. Each of these hosts has about 8-10 hostvars set.

Expected results

The expected result would be that all groups and hosts with the corresponding hostvars are stored in the inventory.

Actual results

The job displays the message Parsed /runner/project/[Scriptname].py inventory source with script plugin, but the job itself has the status "Error" without further description and no hosts are added to the inventory.

Additional information

No response

Operator Logs

No response

@shanemcd shanemcd transferred this issue from ansible/awx-operator Jan 4, 2023
@0x7081
Copy link
Author

0x7081 commented Jan 4, 2023

I found out what was causing the problem and was able to successfully implement a solution.
The problem arose because after 16k characters a new timestamp was added to the output. Thus the generated zip file could not be parsed correctly.

With the fix in ansible/receptor#683 I was able to fix the problem and the inventory script is now parsing correctly.

I just had to redeploy the AWX operator with these options:

apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx
  namespace: awx
spec:
  …
  ee_extra_env: |
    - name: RECEPTOR_KUBE_SUPPORT_RECONNECT
      value: disabled

If I understood correctly, the problem should be solved with Kubernetes version 1.26, but an update is not possible for me due to the use of AWS EKS.
So until this version gets released, this workaround should fix the problem.

@rsindar
Copy link

rsindar commented Feb 9, 2023

Hello,

I have the same issue, but the workaround does not work for me.

I can see the variable in the awx-ee container. I can run the script inside the container directly or via ansible-inventory - everything is OK.

But inventory sync job fails:
yaml declined parsing /runner/project/inventories/inventory.py as it did not pass its verify_file() method
toml declined parsing /runner/project/inventories/inventory.py as it did not pass its verify_file() method
[WARNING]: * Failed to parse /runner/project/inventories/inventory.py with
script plugin: Inventory script (/runner/project/inventories/inventory.py) had
an execution error:
File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 290, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/local/lib/python3.8/site-packages/ansible/plugins/inventory/script.py", line 150, in parse
raise AnsibleParserError(to_native(e))
[WARNING]: * Failed to parse /runner/project/inventories/inventory.py with ini
plugin: /runner/project/inventories/inventory.py:3: Expected key=value host
variable assignment, got: os
File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 290, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/local/lib/python3.8/site-packages/ansible/plugins/inventory/ini.py", line 136, in parse
raise AnsibleParserError(e)
[WARNING]: Unable to parse /runner/project/inventories/inventory.py as an
inventory source
ERROR! No inventory was parsed, please check your configuration and options.

@emoshaya
Copy link

I found out what was causing the problem and was able to successfully implement a solution. The problem arose because after 16k characters a new timestamp was added to the output. Thus the generated zip file could not be parsed correctly.

With the fix in ansible/receptor#683 I was able to fix the problem and the inventory script is now parsing correctly.

I just had to redeploy the AWX operator with these options:

apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx
  namespace: awx
spec:
  …
  ee_extra_env: |
    - name: RECEPTOR_KUBE_SUPPORT_RECONNECT
      value: disabled

If I understood correctly, the problem should be solved with Kubernetes version 1.26, but an update is not possible for me due to the use of AWS EKS. So until this version gets released, this workaround should fix the problem.

How do I set RECEPTOR_KUBE_SUPPORT_RECONNECT to disabled for a custom pod spec?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants