What I want to achieve: I want to be able to create multiple VM instance using AWX playbook or Deployment Manager. The script will read instance configuration in a csv uploaded to gcloud or bitbucket, then create the resources as the values in the csv.
What I did:
I have created a csv with value such as the instance name, disk size, and image family and it doesn't seem to be working. This is what my var file look like. The code is in the jinja template
Var file contains
---
rname: "{{ item.name }}"
#reading csv
Main.yaml:
- name: Read instances from CSV file and return a list
read_csv:
fieldnames: name,image
path: ./roles/autocreate-vm/templates/instances.csv
delimiter: ','
register: instances
- include_tasks: <<path for jinja template>>
loop: "{{ instances.list }}"
Error I received:
ERROR: (gcloud.deployment-manager.deployments.create) ResponseError: code=400,
message=Invalid value for field 'resource.name': 'instance-1'.
Must be a match of regex '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?'
Question:
- Has anyone done something similar i.e. (deploying multiple VMs instance while reading instance configuration from a csv)?
- Is there any public article that I can follow? Can't find anything on Google search