hetzner_cloud/hetzner_basic.yml
2023-06-12 17:29:18 +02:00

73 lines
1.8 KiB
YAML
Executable File

---
- hosts: localhost
connection: local
gather_facts: False
become: True
vars:
sshkey: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBNyMTbcbTDZ7RJQtet7R6RrJogk9sDEAfO6+j5RGFL0 justine@squi.fr
apikey: !vault |
$ANSIBLE_VAULT;1.1;AES256
39303466366266326464646639663763306161373035646231643535613436616138306261623861
3266326437343531653666633065353230663831333237380a643661376239333631613536363133
35363531393161323463353162386430313566363132663732623563633838383036333266376635
6639663565336162630a343362633164383064663532343732393264306133656638326639623137
38626563363631376231623163376638323762363836653434363332396162636133
tasks:
#SHOW INFO
- name: Gather hcloud image infos
hcloud_image_info:
api_token: "{{ apikey }}"
register: output
- name: dbg
debug:
var: output
- name: Gather hcloud location infos
hcloud_location_info:
api_token: "{{ apikey }}"
register: output
- name: dbg
debug:
var: output
#SSH KEY MANAGEMENT
- name: Create my ssh key
hcloud_ssh_key:
api_token: "{{ apikey }}"
name: justine@squi.fr
public_key: "{{ sshkey }}"
state: present
#CREATE SERVER
- name: Create a server
hcloud_server:
api_token: "{{ apikey }}"
name: squi
server_type: cx11
image: debian-11
location: fsn1
state: started
ssh_keys: ["justine@squi.fr"]
user_data: |
#cloud-config
packages:
- zsh
- vim
- fail2ban
package_update: true
package_upgrade: true
- name: Gather server infos
hcloud_server_info:
api_token: "{{ apikey }}"
register: outp
- name: Show
debug:
var: outp