--- - name: Fetch Linode instances linode.cloud.linode_instance_info: api_token: "{{ linode_token }}" register: linodes - 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 copy: dest: /tmp/linode_inventory.ini content: | [all] {{ linode_inventory }}