> For the complete documentation index, see [llms.txt](https://thorstenkramm.gitbook.io/saltstack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thorstenkramm.gitbook.io/saltstack/salt-cloud/digitalocean.md).

# Digitalocean

### SSH Schlüsselpaar erzeugen

```bash
mkdir /etc/salt/cloud.keys.d 
ssh-keygen -N "" -t ed25519 -C "salt@digitalocean" \ 
-f /etc/salt/cloud.keys.d/digitalocean
```

### Account vorbereiten

Erzeugen Sie einen API-Token. Klicken Sie im linken Menü den Bereich »API« an.

Hinterlegen Sie den zuvor erzeugen öffentlichen Schlüssel. Dazu wählen Sie auf der linken Seite den Menüpunkt »Settings« aus.

<div><figure><img src="/files/fxn185IsyMmu5q6ai3mj" alt=""><figcaption><p>API Token erzeugen</p></figcaption></figure> <figure><img src="/files/p5os0EpXw9r51QOTtlha" alt=""><figcaption><p>SSH Schlüssel hinterlegen</p></figcaption></figure></div>

### Konfigurationsdateien anlegen

#### Cloud Provider

{% code title="/etc/salt/cloud.providers.d/digitalocean.conf " %}

```
digitalocean:
  driver: digitalocean
  personal_access_token: <TOKEN>
  ssh_key_file: /etc/salt/cloud.keys.d/digitalocean
  ssh_key_names: salt # Must match the name of your SSH pub key
  location: Frankfurt 1
  minion:
    master: <MASTER-IP-OR-FQDN>
    master_port: <MASTER-PORT>    # omit to use default 4506
    publish_port: <PUBLISH-PORT>  # omit to use default 4505
    # Make connection more fault tolerant
    tcp_keepalive_idle: 60
    tcp_keepalive_cnt: 2
    tcp_keepalive_intvl: 60
```

{% endcode %}

Testen Sie mit `salt-cloud --list-images digitalocean`, ob die Konfiguration funktioniert

#### Cloud Profile

{% code title="/etc/salt/cloud.profiles.d/digitalocean.conf " %}

```
ubuntu-s@do:
  provider: digitalocean
  image: 22.04 (LTS) x64
  size: s-1vcpu-1gb
  private_networking: False
  backups_enabled: False
  ipv6: True
  create_dns_record: False
```

{% endcode %}

### VM verwalten

Legen Sie nun eine neue VM an

```
salt-cloud -p ubuntu-s@do umar -l debug
salt umar test.ping
```

VM können mit `salt-cloud -d <MINION-ID>` wieder gelöscht werden.
