generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdroplet.yml
29 lines (26 loc) · 818 Bytes
/
droplet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
- name: Create SSH key and Droplet
hosts: localhost
connection: local
gather_facts: true
vars:
digitalocean_token: "{{ lookup('ansible.builtin.env', 'DIGITALOCEAN_TOKEN') }}"
public_key: "{{ lookup('ansible.builtin.file', ansible_env['HOME'] ~ '/.ssh/sammy.key.pub') }}"
tasks:
- name: Create SSH key
digitalocean.cloud.ssh_key:
state: present
token: "{{ digitalocean_token }}"
public_key: "{{ public_key }}"
name: sammy
register: ssh_key
- name: Create Droplet
digitalocean.cloud.droplet:
state: present
token: "{{ digitalocean_token }}"
name: sammy-droplet
region: nyc3
size: s-1vcpu-2gb
image: ubuntu-22-04-x64
ssh_keys: ["{{ ssh_key.ssh_key.id }}"]
unique_name: true