# ジョブ: 最小構成 (macOS)

**想定読者:** macOSエンドポイントへカスタム実行ファイルをデプロイする統合担当者。

本例は[ジョブ: 最小構成 (Windows)](/keeperpam/jp/endpoint-privilege-manager/integrations/examples/job-minimal-windows.md) のmacOS向け版です。構造は同じで、違いはバイナリのパス、`osFilter`、およびmacOS特有の署名・公証の前提です。異種OSが混在するフリートでは、Windows版およびLinux版とあわせてデプロイしてください。

## ジョブのJSON <a href="#the-job-json" id="the-job-json"></a>

```json
{
  "id": "my-tool",
  "name": "My Tool",
  "description": "Runs MyTool on a 60-minute interval.",
  "enabled": true,

  "schedule": {
    "intervalMinutes": 60
  },

  "osFilter": {
    "windows": false,
    "linux": false,
    "macOS": true
  },

  "mqttTopics": {
    "allowedPublications": ["KeeperLogger"],
    "allowedSubscriptions": []
  },

  "parameters": [],

  "tasks": [
    {
      "id": "run-tool",
      "name": "Run tool",
      "ExecutionType": "Service",
      "command": "MyTool",
      "executablePath": "/usr/local/KeeperPrivilegeManager/Jobs/bin/MyTool/MyTool",
      "arguments": "--keeper-api-base={KeeperApiBaseUrl}",
      "timeoutSeconds": 3600,
      "continueOnFailure": false,
      "scriptType": "Auto"
    }
  ]
}
```

## 変更する箇所 <a href="#what-to-change" id="what-to-change"></a>

| フィールド                      | 内容                                                                                                                                                         |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                       | 本ジョブを一意に識別する文字列。ハイフンを使い、アンダースコアは使いません。ファイル名は `id` と一致させます (例: `"id": "my-tool"` のときは `my-tool.json`)。異種OSが混在するフリートへ展開する場合は、Windows版およびLinux版と同じIDに揃えてください。 |
| `name`                     | ログや管理画面に表示する名称                                                                                                                                             |
| `tasks[0].command`         | パスや拡張子なしの実行ファイル名                                                                                                                                           |
| `tasks[0].executablePath`  | 実行ファイルのフルパス。macOSでのエージェントのデフォルトインストールルートは `/usr/local/KeeperPrivilegeManager`。別パスで展開している場合は管理者へ確認                                                          |
| `tasks[0].arguments`       | 実行ファイルが受け付けるフラグ。`{KeeperApiBaseUrl}` は削除せず残す。エージェントが実行時にローカルのHTTPS APIベースURLへ差し替え                                                                          |
| `schedule.intervalMinutes` | 実行間隔 (分)                                                                                                                                                   |
| `tasks[0].timeoutSeconds`  | エージェントがタスクを強制終了するまでの最大実行時間                                                                                                                                 |

**`.exe` は付けない:** macOSの実行ファイルに拡張子はありません。`command` と `executablePath` の両方に、拡張子なしの名前を使います。

**ファイルのパーミッション:** バイナリはエージェントのサービスアカウントから実行可能である必要があります。

```bash
chmod +x /usr/local/KeeperPrivilegeManager/Jobs/bin/MyTool/MyTool
```

**署名と公証 (ノータライズ):** Mac App Store以外へ配布するバイナリは、Apple Developer ID証明書で署名し、Appleに公証する必要があります。未署名または未公証のバイナリは、エージェントがジョブタスクとして実行する前にGatekeeperによってブロックされます。リリース工程の一環として署名と公証を行ってください。これはmacOSプラットフォームの要件であり、KEPM固有の要件ではありません。

署名後、ジョブ起動以外の文脈でもMQTTやプラグイン設定へアクセスさせる必要がある場合は、`appsettings.json` の `Settings:AlternativeSignatures` に証明書のサムプリントを追加します。通常のジョブタスク実行では、エージェントがバイナリを起動したタイミングでプロセス信頼により認証が行われます。

**`osFilter` と検証:** WindowsおよびLinux上のエージェントは本ジョブをスキップします。`osFilter` が現在のOSと一致しない場合、バリデータはバイナリ存在チェックも行わないため、macOS以外のホストから登録しても、macOS用のパスがディスク上にあるかどうかは検証されません。

## デプロイ前に <a href="#before-you-deploy" id="before-you-deploy"></a>

1. **バイナリに署名し公証する:** macOSエンドポイントへ配布する前に実施します。未署名のバイナリはOSレベルでGatekeeperによりブロックされます。
2. **先にバイナリをデプロイする:** `POST /api/Jobs` の呼び出し前に `executablePath` へ配置します。バリデータは呼び出し時点で存在を確認します。
3. **実行権限を付与する:** コピー後にバイナリに対して `chmod +x` を実行します。
4. **インストールルートを確認する:** `/usr/local/KeeperPrivilegeManager` がmacOSでの一般的なデフォルトです。デプロイ前に管理者へ確認してください。
5. **ファイル名は `id` と一致させる:** `"id"` が `"my-tool"` なら `my-tool.json` として保存します。

## デプロイ <a href="#deploy" id="deploy"></a>

保存前に検証します。

```bash
curl -s -X POST https://127.0.0.1:6889/api/Jobs/validate \
  --cert /path/to/client.pem \
  --key /path/to/client.key \
  --cacert /path/to/ca.pem \
  -H "Content-Type: application/json" \
  -d @my-tool.json
```

ジョブを作成します。

```bash
curl -s -X POST https://127.0.0.1:6889/api/Jobs \
  --cert /path/to/client.pem \
  --key /path/to/client.key \
  --cacert /path/to/ca.pem \
  -H "Content-Type: application/json" \
  -d @my-tool.json
```

手動トリガーで確認します。

```bash
curl -s -X POST https://127.0.0.1:6889/api/Jobs/my-tool/trigger \
  --cert /path/to/client.pem \
  --key /path/to/client.key \
  --cacert /path/to/ca.pem \
  -H "Content-Type: application/json" \
  -d "{}"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/endpoint-privilege-manager/integrations/examples/job-minimal-macos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
