feat: add Semaphore Sync job
Fetches Semaphore project inventory via Bearer auth, parses the Ansible INI format to extract hostnames, and sets semaphore=1/0 on matching instances. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -585,4 +585,21 @@ describe('POST /api/jobs/:id/run', () => {
|
||||
const res = await request(app).post(`/api/jobs/${id}/run`)
|
||||
expect(res.status).toBe(500)
|
||||
})
|
||||
|
||||
it('semaphore_sync: parses ansible inventory and updates instances', async () => {
|
||||
const semaphoreJob = {
|
||||
key: 'semaphore_sync', name: 'Semaphore Sync', description: 'test',
|
||||
enabled: 0, schedule: 60,
|
||||
config: JSON.stringify({ api_url: 'http://semaphore:3000/api/project/1/inventory/1', api_token: 'bearer-token' }),
|
||||
}
|
||||
createJob(semaphoreJob)
|
||||
const id = (await request(app).get('/api/jobs')).body[0].id
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({ inventory: '[production]\nplex\nhomeassistant\n' }),
|
||||
}))
|
||||
const res = await request(app).post(`/api/jobs/${id}/run`)
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.body.summary).toMatch(/updated of/)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user