diff --git a/roles/inventory/linode/tasks/main.yaml b/roles/inventory/linode/tasks/main.yaml index 0cec889..68d7bfd 100644 --- a/roles/inventory/linode/tasks/main.yaml +++ b/roles/inventory/linode/tasks/main.yaml @@ -1,20 +1,11 @@ --- -- name: Fetch Linode instances - linode.cloud.linode_instance_info: - api_token: "{{ linode_token }}" - register: linodes +- name: Get Linode inventory using local module + linode_inventory: + register: linode_result -- name: Build inventory lines - set_fact: - linode_inventory: | - {% for linode in linodes.data %} - {{ linode.label }} ansible_host={{ linode.ipv4[0] }} {% for tag in linode.tags %}group_{{ tag }}=true {% endfor %} - {% endfor %} - -- name: Write dynamic inventory to file +- name: Write inventory to file copy: - dest: /tmp/linode_inventory.ini - content: | - [all] - {{ linode_inventory }} + dest: /tmp/linode_inventory.json + content: "{{ linode_result | to_nice_json }}" + mode: '0644'