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 sync from ini file in git repo/project fails when submodules are tracked #14687

Open
6 of 11 tasks
fuggla opened this issue Nov 24, 2023 · 9 comments
Open
6 of 11 tasks

Comments

@fuggla
Copy link

fuggla commented Nov 24, 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 AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to [email protected] instead.)

Bug Summary

Syncing an inventory from a git project fails, if the git submodules are tracked. The project itself syncs regardless if submodule tracking is enabled or disabled. The problem is only the inventory source job.

Example repo/project containing an inventory file and a submodule. The parse of inventory.ini fails if the submodule is tracked.

  • inventory.ini
  • roles/my-submodule

AWX version

2.7.2

Select the relevant components

  • UI
  • UI (tech preview)
  • API
  • Docs
  • Collection
  • CLI
  • Other

Installation method

kubernetes

Modifications

no

Ansible version

ansible [core 2.15.4]

Operating system

AlmaLinux 9.3

Web browser

Firefox

Steps to reproduce

  1. create a git repository
  2. add a inventory ini
  3. add a submodule to the repository
  4. add the repository as a project in AWX
  5. Enable track submodules
  6. Create a new inventory
  7. add the inventory ini from the project as a source
  8. sync

Expected results

Hosts from the file should be added to the AWX inventory.

Actual results

The sync fails.

Additional information

Output from job:

Previous Task Failed: {"job_type": "project_update", "job_name": "USERNAME/REPO @ inventory-tests", "job_id": "993"}

Traceback (most recent call last):
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 500, in run
    self.build_project_dir(self.instance, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 1634, in build_project_dir
    self.sync_and_copy(source_project, private_data_dir, scm_branch=inventory_update.inventory_source.scm_branch)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 791, in sync_and_copy
    return self.sync_and_copy_without_lock(project, private_data_dir, scm_branch=scm_branch)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 747, in sync_and_copy_without_lock
    sync_task.run(local_project_sync.id)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 94, in _wrapped
    return f(self, *args, **kwargs)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/signals.py", line 81, in _wrapped
    return f(*args, **kwargs)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 665, in run
    raise AwxTaskError.TaskError(self.instance, rc)
Exception: project_update 993 (failed) encountered an error (rc=None), please see task stdout for details.
@jessicamack
Copy link
Member

Hello, can you set up a public project repo for us to try out this set up? This will ease troubleshooting.

@fuggla
Copy link
Author

fuggla commented Nov 30, 2023

Thanks for looking into this. I've setup two public repos. Ansible_base with the ansible_role as a submodule. Ansible_base contains a hosts.ini with IP 1.2.3.4

@michten-atos
Copy link

We have the same issue with sourcing inventory from submodules in AAP2.3
@AlanCoding According to:
#7900
#5248
#12356
this supposed to be fixed.

@utoplenick
Copy link

Having same issue AWX 24.6.2

@rommanio
Copy link

Same issue

@kpi-nourman
Copy link

kpi-nourman commented Dec 16, 2024

same issue
failed inventory sync from yaml file in github when track submodules

@chrismeyersfsu
Copy link
Member

I'm not seeing a hosts.ini file in https://github.com/fuggla/ansible_base

Regardless, I think I'm able to recreate the project update failure

stdout: |
  Entering 'roles/ansible_role'
  origin/master
stderr: >
  fatal: ambiguous argument 'origin/master': unknown revision or path not in the
  working tree.

  Use '--' to separate paths from revisions, like this:

  'git <command> [<revision>...] -- [<file>...]'

  fatal: run_command returned non-zero status for roles/ansible_role

  .
rc: 128
msg: Unable to determine hashes of submodules
invocation:
  module_args:
    dest: >-
      /home/3ci/aap/controller/data/projects/_17__httpsgithubcomfugglaansible_base
    repo: https://github.com/fuggla/ansible_base
    version: 9ab720f1128851933092b853ea9989593d162b6e
    force: false
    track_submodules: true
    remote: origin
    clone: true
    update: true
    verify_commit: false
    gpg_whitelist: []
    accept_hostkey: false
    accept_newhostkey: false
    bare: false
    recursive: true
    single_branch: false
    refspec: null
    reference: null
    depth: null
    key_file: null
    ssh_opts: null
    executable: null
    umask: null
    archive: null
    archive_prefix: null
    separate_git_dir: null
stdout_lines:
  - Entering 'roles/ansible_role'
  - origin/master
stderr_lines:
  - >-
    fatal: ambiguous argument 'origin/master': unknown revision or path not in
    the working tree.
  - 'Use ''--'' to separate paths from revisions, like this:'
  - '''git <command> [<revision>...] -- [<file>...]'''
  - 'fatal: run_command returned non-zero status for roles/ansible_role'
  - .
_ansible_no_log: false
changed: false

@pb82
Copy link
Contributor

pb82 commented Jan 14, 2025

@chrismeyersfsu I believe the problem is this: fatal: ambiguous argument 'origin/master': unknown revision or path

The submodule repository uses main and not master, but master is hardcoded in the ansible core git module: https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/git.py#L965

@rommanio
Copy link

@pb82 Yes, and there is issue about this problem.

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

9 participants