> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/aikido-debaisu/deploying-aikido-endpoint/device-protection-mdm-guides/linux/deploy-device-protection-with-puppet.md).

# Puppet を使用してデバイス保護を展開する

Puppet クラスを使って、Puppet エージェントがすでに管理している Linux ノードに Device Protection をインストールします。下のクラスはプラットフォームごとに適切なパッケージを選び、ユーザーグループのトークンでインストールし、実行のたびにサービスを起動したままにします。

読む [Linux 用 Device Protection をインストールする](/docs/docs-ja/aikido-debaisu/deploying-aikido-endpoint/device-protection-mdm-guides/linux/install-device-protection-for-linux.md) まず、トークン、パッケージ、そして各方式で使われるインストールオプションについて。 [Linux 展開リファレンス](/docs/docs-ja/aikido-debaisu/deploying-aikido-endpoint/device-protection-mdm-guides/linux/linux-rollout-reference.md) では、トークンの扱い、再起動、繰り返し実行、デバイス ID について残りを説明します。

## モジュール構成

```
modules/aikido_device_protection/
└── manifests/init.pp
data/
└── groups/developers.yaml
```

## クラスを設定する

{% stepper %}
{% step %}
**トークンを Hiera eyaml に保存する**

Aikido のユーザーグループに対応するノードグループ向けに、トークンを暗号化します:

{% code overflow="wrap" %}

```bash
eyaml encrypt -l 'aikido_device_protection::token' -s '<your-token>'
```

{% endcode %}

出力を対応する Hiera レイヤーに貼り付けます:

{% code title="data/groups/developers.yaml" %}

```yaml
---
aikido_device_protection::token: >
  ENC[PKCS7,MIIBiQYJKoZIhvcNAQcDoIIBejCCAXYCAQAxggEhMIIBHQIBADAFMAACAQEw...]
```

{% endcode %}

クラスのパラメータは `Sensitive`型で、Puppet は Hiera から来る値を自動的にラップするため、他には何も必要ありません。
{% endstep %}

{% step %}
**クラスを追加する**

{% code title="modules/aikido\_device\_protection/manifests/init.pp" %}

```puppet
class aikido_device_protection (
  Sensitive[String[1]] $token,
  String[1] $release_url = 'https://github.com/AikidoSec/safechain-internals/releases/latest/download',
) {
  $arch = $facts['os']['architecture'] ? {
    /^(aarch64|arm64)$/ => 'arm64',
    default             => 'amd64',
  }

  case $facts['os']['family'] {
    'Debian': {
      $package_file    = "EndpointProtection-${arch}.deb"
      $install_command = 'apt-get install -y'
      $installed_check = "dpkg-query -W -f='\${db:Status-Status}' aikido-endpoint-protection 2>/dev/null | grep -qx installed"
    }
    'RedHat': {
      $package_file    = "EndpointProtection-${arch}.el${facts['os']['release']['major']}.rpm"
      $install_command = 'dnf install -y'
      $installed_check = 'rpm -q aikido-endpoint-protection'
    }
    default: {
      fail("Aikido Device Protection は ${facts['os']['family']} をサポートしていません")
    }
  }

  $package_path = "/var/cache/aikido/${package_file}"

  file { '/var/cache/aikido':
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0700',
  }

  exec { 'download aikido-endpoint-protection':
    command  => "curl -fsSLo ${package_path} ${release_url}/${package_file}",
    provider => shell,
    path     => ['/usr/bin', '/bin'],
    creates  => $package_path,
    unless   => $installed_check,
    require  => File['/var/cache/aikido'],
  }

  $install_script = @("SCRIPT")
    #!/bin/sh
    set -e
    export AIKIDO_TOKEN='${$token.unwrap}'
    exec ${install_command} ${package_path}
    | SCRIPT

  file { '/usr/local/sbin/aikido-install':
    ensure  => file,
    owner   => 'root',
    group   => 'root',
    mode    => '0700',
    content => Sensitive($install_script),
  }

  exec { 'install aikido-endpoint-protection':
    command  => '/usr/local/sbin/aikido-install',
    provider => shell,
    path     => ['/usr/bin', '/bin', '/usr/sbin', '/sbin'],
    unless   => $installed_check,
    require  => [
      Exec['download aikido-endpoint-protection'],
      File['/usr/local/sbin/aikido-install'],
    ],
  }

  service { 'aikido-endpoint-protection':
    ensure  => running,
    enable  => true,
    require => Exec['install aikido-endpoint-protection'],
  }
}
```

{% endcode %}

このクラスで知っておくべき点は 4 つあります:

* インストールは、root 専用スクリプトを `Sensitive()`でラップして実行されます。パッケージが [`AIKIDO_TOKEN` を環境変数として必要とし、](/docs/docs-ja/aikido-debaisu/deploying-aikido-endpoint/device-protection-mdm-guides/linux/linux-rollout-reference.md#how-the-token-reaches-the-package) Puppet は `exec`の `environment` 属性をマスキングしないためです。
* [`unless => $installed_check`](/docs/docs-ja/aikido-debaisu/deploying-aikido-endpoint/device-protection-mdm-guides/linux/linux-rollout-reference.md#make-repeat-runs-cheap) はダウンロードとインストールを防ぐため、すでにエージェントを実行しているノードでは何も行われません。
* `provider => shell` は、Debian のチェックがパイプラインであり、 `exec` はデフォルトではシェルを使用しないためです。
* ダウンロードでは `curl`を使います。最小構成のイメージではこれが含まれないことがあります。含まれていない場合は、このクラスと一緒にインストールしてください。

{% hint style="warning" %}
トークンは、root 専用の 2 か所にディスク上へ保存されます: `/usr/local/sbin/aikido-install`、これはガードがなくインストール後も残り、さらに `/opt/puppetlabs/puppet/cache`配下のキャッシュ済みカタログです。エージェントはリソースを適用するためにこれを必要とします。どちらも機密として扱い、レポートへのアクセスは制限してください。

ノードグループが一度インストールされたら、 `ファイル` resource を `ensure => absent` に切り替えると、そこからスクリプトがすべて削除されます。次にそのグループへ新しいノードが参加する前に、元に戻してください。
{% endhint %}
{% endstep %}

{% step %}
**ノードを分類する**

roles と profiles、Puppet Enterprise コンソール、または `site.pp`:

```puppet
でノードを分類する場所にクラスを宣言します。
```

次回のエージェント実行でインストールされます。まずは 1 つのグループを分類し、その後に範囲を広げてください。

Puppet には組み込みの再起動リソースがないため、ユーザーがログアウトして再度ログインすると保護が有効になります。代わりに監視対象でないノードを再起動するには、インストールから [puppetlabs-reboot](https://forge.puppet.com/modules/puppetlabs/reboot) に通知してください `exec`. 参照 [保護が有効になるとき](/docs/docs-ja/aikido-debaisu/deploying-aikido-endpoint/device-protection-mdm-guides/linux/linux-rollout-reference.md#when-protection-becomes-active).
{% endstep %}
{% endstepper %}

## 展開を検証する

次を実行したノードで:

{% code overflow="wrap" %}

```bash
systemctl is-active aikido-endpoint-protection
aikido-doctor version
```

{% endcode %}

その後、デバイスは [デバイス一覧](https://app.aikido.dev/endpoint-protection/devices) に **Active** ステータスで表示されます。

## トラブルシューティング

| 問題                                                   | 対処                                                                                                                                                                                                                         |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| パッケージはインストールされるが、デバイスがダッシュボードに表示されない                 | `AIKIDO_TOKEN` インストールコマンドに対して設定されていませんでした。構成管理ツールはローカル環境をホストに引き継がないため、変数はタスク自体に設定し、その後パッケージをもう一度インストールしてください                                                                                                               |
| `apt` または `dnf` ファイルをインストールするのではなく、リポジトリ内でパッケージを探します | 名前ではなくパスを指定してください： `apt install ./EndpointProtection-amd64.deb`。先頭の `./` が、パッケージマネージャーにそれをローカルファイルとして扱わせます                                                                                                                 |
| Red Hat系ホストでインストールが失敗する                              | ビルドをメジャーバージョンに合わせてください。 `el9` バージョン9ではこのパッケージを、そして `el10` バージョン10ではこのパッケージを                                                                                                                                                |
| サービスが実行されていません                                       | 実行してください `systemctl status aikido-endpoint-protection`、次に `sudo aikido-doctor diagnostics` 詳細を送信するには                                                                                                                       |
| Node.js または uv が引き続き Aikido の証明書を拒否する                | インストールすると設定される `NODE_EXTRA_CA_CERTS` と `UV_SYSTEM_CERTS` システム全体に適用され、既に起動しているシェルはそれらを読み込みません。新しいログインシェルを開くか、デバイスを再起動してください                                                                                                 |
| トークンが実行結果やログに表示される                                   | ツールの秘匿機能を使用してください： `no_log` Ansible では、 `sensitive true` Chef では、 `Sensitive()` Puppet では                                                                                                                                  |
| 複数のマシンがデバイス一覧の1つのエントリを共有している                         | 同じものを使って起動しました `/etc/machine-id`。Linux のデバイスIDはそのファイルに従うため、複製元のイメージでそれを削除し、初回起動時に systemd に新しいものを書き込ませてください                                                                                                                |
| トレイアイコンが表示されない                                       | Ubuntu 以外の GNOME では想定内で、見た目だけの問題です。参照： [Linux でのトレイアイコンのサポート](/docs/docs-ja/aikido-debaisu/deploying-aikido-endpoint/device-protection-mdm-guides/linux/install-device-protection-for-linux/tray-icon-support-on-linux.md) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/docs/docs-ja/aikido-debaisu/deploying-aikido-endpoint/device-protection-mdm-guides/linux/deploy-device-protection-with-puppet.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
