From 0d1be722a1fa91e03227b24006577caa567880b0 Mon Sep 17 00:00:00 2001 From: Jack Ivanov <17044561+jackivanov@users.noreply.github.com> Date: Thu, 14 Mar 2024 02:25:09 -0600 Subject: [PATCH 1/2] Fix hetzner module (#14698) --- roles/cloud-hetzner/tasks/main.yml | 4 ++-- roles/cloud-hetzner/tasks/prompts.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/cloud-hetzner/tasks/main.yml b/roles/cloud-hetzner/tasks/main.yml index c533164c9..e30ae008e 100644 --- a/roles/cloud-hetzner/tasks/main.yml +++ b/roles/cloud-hetzner/tasks/main.yml @@ -6,7 +6,7 @@ import_tasks: prompts.yml - name: Create an ssh key - hcloud_ssh_key: + hetzner.hcloud.ssh_key: name: algo-{{ 999999 | random(seed=lookup('file', SSH_keys.public)) }} public_key: "{{ lookup('file', SSH_keys.public) }}" state: present @@ -14,7 +14,7 @@ register: hcloud_ssh_key - name: Create a server... - hcloud_server: + hetzner.hcloud.server: name: "{{ algo_server_name }}" location: "{{ algo_hcloud_region }}" server_type: "{{ cloud_providers.hetzner.server_type }}" diff --git a/roles/cloud-hetzner/tasks/prompts.yml b/roles/cloud-hetzner/tasks/prompts.yml index 5f240df29..3663b7e67 100644 --- a/roles/cloud-hetzner/tasks/prompts.yml +++ b/roles/cloud-hetzner/tasks/prompts.yml @@ -13,13 +13,13 @@ algo_hcloud_token: "{{ hcloud_token | default(_hcloud_token.user_input|default(None)) | default(lookup('env','HCLOUD_TOKEN'), true) }}" - name: Get regions - hcloud_datacenter_facts: + hetzner.hcloud.datacenter_info: api_token: "{{ algo_hcloud_token }}" register: _hcloud_regions - name: Set facts about the regions set_fact: - hcloud_regions: "{{ hcloud_datacenter_facts | sort(attribute='location') }}" + hcloud_regions: "{{ _hcloud_regions.hcloud_datacenter_info | sort(attribute='location') }}" - name: Set default region set_fact: From a4a9d6d7c81ebf505737d7d4179794f0ba44e62b Mon Sep 17 00:00:00 2001 From: Jack Ivanov <17044561+jackivanov@users.noreply.github.com> Date: Sat, 16 Mar 2024 13:21:12 -0600 Subject: [PATCH 2/2] Fix Vultr collection (#14707) --- config.cfg | 2 +- roles/cloud-vultr/tasks/main.yml | 26 ++++++++++++++------------ roles/cloud-vultr/tasks/prompts.yml | 6 +++--- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/config.cfg b/config.cfg index e8b6559bc..27cb29d6a 100644 --- a/config.cfg +++ b/config.cfg @@ -217,7 +217,7 @@ cloud_providers: disk: 10 vultr: os: Ubuntu 22.04 LTS x64 - size: 1024 MB RAM,25 GB SSD,1.00 TB BW + size: vc2-1c-1gb linode: type: g6-nanode-1 image: linode/ubuntu22.04 diff --git a/roles/cloud-vultr/tasks/main.yml b/roles/cloud-vultr/tasks/main.yml index 2aa1b8daf..ccbcd13b6 100644 --- a/roles/cloud-vultr/tasks/main.yml +++ b/roles/cloud-vultr/tasks/main.yml @@ -4,16 +4,17 @@ - block: - name: Creating a firewall group - vultr_firewall_group: + vultr.cloud.firewall_group: name: "{{ algo_server_name }}" - name: Creating firewall rules - vultr_firewall_rule: + vultr.cloud.firewall_rule: group: "{{ algo_server_name }}" protocol: "{{ item.protocol }}" port: "{{ item.port }}" - ip_version: "{{ item.ip }}" - cidr: "{{ item.cidr }}" + ip_type: "{{ item.ip }}" + subnet: "{{ item.cidr.split('/')[0] }}" + subnet_size: "{{ item.cidr.split('/')[1] }}" with_items: - { protocol: tcp, port: "{{ ssh_port }}", ip: v4, cidr: 0.0.0.0/0 } - { protocol: tcp, port: "{{ ssh_port }}", ip: v6, cidr: "::/0" } @@ -25,13 +26,13 @@ - { protocol: udp, port: "{{ wireguard_port }}", ip: v6, cidr: "::/0" } - name: Upload the startup script - vultr_startup_script: + vultr.cloud.startup_script: name: algo-startup script: | {{ lookup('template', 'files/cloud-init/base.yml') }} - name: Creating a server - vultr_server: + vultr.cloud.instance: name: "{{ algo_server_name }}" startup_script: algo-startup hostname: "{{ algo_server_name }}" @@ -40,17 +41,18 @@ region: "{{ algo_vultr_region }}" firewall_group: "{{ algo_server_name }}" state: started - tag: Environment:Algo - ipv6_enabled: true - auto_backup_enabled: false - notify_activate: false + tags: + - Environment:Algo + enable_ipv6: true + backups: false + activation_email: false register: vultr_server - set_fact: - cloud_instance_ip: "{{ vultr_server.vultr_server.v4_main_ip }}" + cloud_instance_ip: "{{ vultr_server.vultr_instance.main_ip }}" ansible_ssh_user: algo ansible_ssh_port: "{{ ssh_port }}" cloudinit: true environment: - VULTR_API_CONFIG: "{{ algo_vultr_config }}" + VULTR_API_KEY: "{{ lookup('ini', 'key', section='default', file=algo_vultr_config) }}" diff --git a/roles/cloud-vultr/tasks/prompts.yml b/roles/cloud-vultr/tasks/prompts.yml index 1245b719f..7813b0f5b 100644 --- a/roles/cloud-vultr/tasks/prompts.yml +++ b/roles/cloud-vultr/tasks/prompts.yml @@ -42,7 +42,7 @@ What region should the server be located in? (https://www.vultr.com/locations/): {% for r in vultr_regions %} - {{ loop.index }}. {{ r['name'] }} + {{ loop.index }}. {{ r['name'] }} ({{ r['regioncode'] | lower }}) {% endfor %} Enter the number of your desired region @@ -54,5 +54,5 @@ set_fact: algo_vultr_region: >- {% if region is defined %}{{ region }} - {%- elif _algo_region.user_input %}{{ vultr_regions[_algo_region.user_input | int -1 ]['name'] }} - {%- else %}{{ vultr_regions[default_region | int - 1]['name'] }}{% endif %} + {%- elif _algo_region.user_input %}{{ vultr_regions[_algo_region.user_input | int -1 ]['name'] | lower }} + {%- else %}{{ vultr_regions[default_region | int - 1]['regioncode'] | lower }}{% endif %}