Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Vultr collection #14707

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 14 additions & 12 deletions roles/cloud-vultr/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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 }}"
Expand All @@ -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) }}"
6 changes: 3 additions & 3 deletions roles/cloud-vultr/tasks/prompts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 %}
Loading