Skip to content

ensure this works if there are no servers defined yet #7

Description

@felbinger

I had this in my history with a comment to test it, not sure what this actually was about.

--- a/tasks/local/hetzner-cloud.yaml
+++ b/tasks/local/hetzner-cloud.yaml
@@ -5,7 +5,7 @@
 
 - name: "Map response of hcloud_server_info to list of server names"
   ansible.builtin.set_fact:
-    existing_cloud_servers: "{{ output.hcloud_server_info | map(attribute='name') | list }}"
+    existing_cloud_servers: "{{ output.hcloud_server_info | default([]) | selectattr('name', 'defined') | map(attribute='name') | list }}"
 
 - name: "Determine cloud servers that are no longer defined in the ansible inventory"
   ansible.builtin.set_fact:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions