Score:1

Multiple VM deployment via GCP Deployment Manager

jp flag

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:

  1. Has anyone done something similar i.e. (deploying multiple VMs instance while reading instance configuration from a csv)?
  2. Is there any public article that I can follow? Can't find anything on Google search
Alex G avatar
ar flag
I haven't tried using a CSV as config template but this [article](https://stackoverflow.com/questions/51969240/script-to-create-multiple-gce-vms-simultaneously) might help. With regards to GCP documentation for such use case, you can follow [this](https://cloud.google.com/deployment-manager/docs/at-scale) one.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.