I’m doing a migration from Jenkins into Github actions, and a lot of the automations I’m running a re using ansible playbooks. The ansible needs an inventory file to determine hosts and vars under them. However, when attempting to run said ansible automation in github actions, I get the following error:
Warning: : * Failed to parse /__w/aws-infra/aws-
infra/inventories/hosts.yaml with auto plugin: no root 'plugin' key found,
'/__w/aws-infra/aws-infra/inventories/hosts.yaml' is not a
valid YAML inventory plugin config file
Warning: : * Failed to parse /__w/aws-infra/aws-
infra/inventories/hosts.yaml with yaml plugin: We were unable to read either as
JSON nor YAML, these are the errors we got from each: JSON: Expecting property
name enclosed in double quotes: line 1 column 25 (char 24) Syntax Error while
loading YAML. did not find expected ',' or '}' The error appears to be in
'<string>': line 2, column 40, but may be elsewhere in the file depending on
the exact syntax problem.
Warning: : * Failed to parse /__w/aws-infra/aws-
infra/inventories/hosts.yaml with ini plugin: We were unable to read either as
JSON nor YAML, these are the errors we got from each: JSON: Expecting property
name enclosed in double quotes: line 1 column 25 (char 24) Syntax Error while
loading YAML. did not find expected ',' or '}' The error appears to be in
'<string>': line 2, column 40, but may be elsewhere in the file depending on
the exact syntax problem.
Warning: : Unable to parse /__w/aws-infra/aws-
infra/inventories/hosts.yaml as an inventory source
Warning: : No inventory was parsed, only implicit localhost is available
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting property name enclosed in double quotes: line 1 column 25 (char 24)
My step inside the pipeline goes as follows:
- name: run ansible
run: |
ansible-playbook -i ./inventories/hosts.yaml
./create_cluster.yaml
Any help on the topic is much appriciated. If I had to guess at this point, it’s failing because some permission thing inside the container. I’m running this on my custom ubuntu-based dockerfile that’s build into ghcr and pulled at the beginning of the pipeline. The image contains everything that was used for running this inside Jenkins.
What has been tried so far:
- Bumped ancient ansible version to latest
- Run the ‘hosts.yaml’ trough yamllint, ansible-lint
- Run ansible-inventory –graph inside gha with success
- Raised pipeline permissions to write-all
- Tried different paths such as ${{ github.workspace }}/, ./ and simple path for the inventory file.
- Exhausted a lot of stackoverflow threads and google results.
Expected result: ansible reads inventory and starts running as normal.