semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

Fix project export to include inventory repository references

Open Copilot opened this issue 1 month ago • 2 comments

Project exports were dropping the repository reference from file-type inventories, forcing manual reconfiguration after import.

Changes

services/project/types.go

  • Added Repository field to BackupInventory struct

services/project/backup.go

  • Extract repository name when building inventory backups (similar to existing SSHKey/BecomeKey handling)

services/project/restore.go

  • Resolve repository name back to ID during restore
  • Verify repository exists during validation

services/project/backup_test.go

  • Added TestBackup_InventoryWithRepository covering export/import cycle

Result

Exported inventories now preserve repository associations:

"inventories": [
  {
    "inventory": "inventory/bast-inventory.aws_ec2.yaml",
    "name": "bastion-hat-global",
    "repository": "bastion-build",
    "ssh_key": "ansible",
    "type": "file"
  }
]
Original prompt

This section details on the original issue you should resolve

<issue_title>Problem: Project export does not contain repository for an inventory</issue_title> <issue_description>### Issue

When exporting a project that contains an ansible inventory that refers to a file held in a repository the exported project does not contain reference to the repository - E.g:

"inventories": [
    {
      "inventory": "inventory/bast-inventory.aws_ec2.yaml",
      "name": "bastion-hat-global",
      "ssh_key": "ansible",
      "type": "file"
    }
  ],

Have tried adding the repository into the project template as follows:

"inventories": [
        {
            "inventory": "inventory/bast-inventory.aws_ec2.yaml",
            "name": "bastion-hat-global",
            "ssh_key": "ansible",
            "type": "file",
            "repository": "bastion-build"
        }
    ],

However, this does not work.

I have attached a screenshot of the inventory config in the UI. This means currently we have to change this setting manually in the UI or then make an additional API call to update the inventory.

Image

Impact

Semaphore Project

Installation method

Package

Database

Postgres

Browser

No response

Semaphore Version

2.16.16-4066a1e-1755360390

Ansible Version


Logs & errors

No response

Manual installation - system information

No response

Configuration

No response

Additional information

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes semaphoreui/semaphore#3369

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Nov 04 '25 20:11 Copilot

@codex review

fiftin avatar Nov 04 '25 21:11 fiftin

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".