Skip to content

Commit e657c94

Browse files
committed
Use two-step fact assignment for Vultr startup script
Changed to set the cloud-init script as a fact first, then reference that fact in the startup_script module. This follows the pattern used by the Linode provider and avoids JSON serialization issues with nested template lookups. This approach ensures the template is fully evaluated and stored as a string before being passed to the vultr.cloud.startup_script module, which then base64-encodes it for the API. Related to: JSON serialization with "tagless" profile in Ansible 2.19+
1 parent 5bf9a58 commit e657c94

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

roles/cloud-vultr/tasks/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import_tasks: prompts.yml
44

55
- block:
6+
- name: Set cloud-init script as fact
7+
set_fact:
8+
algo_cloud_init_script: "{{ lookup('template', 'files/cloud-init/base.yml') }}"
9+
610
- name: Creating a firewall group
711
vultr.cloud.firewall_group:
812
name: "{{ algo_server_name }}"
@@ -28,7 +32,7 @@
2832
- name: Upload the startup script
2933
vultr.cloud.startup_script:
3034
name: algo-startup
31-
script: "{{ lookup('template', 'files/cloud-init/base.yml') | string }}"
35+
script: "{{ algo_cloud_init_script }}"
3236

3337
- name: Creating a server
3438
vultr.cloud.instance:

0 commit comments

Comments
 (0)