Hello,

I am trying to launch/create multiple instances and attach multiple
volumes with a loop but not having much luck. I can get it to work if
I define each instance/volume but who wants to do that? Ideally I
would set a var that says something like make 100 instances. Below is
an example of what I currently have. How to I transfor these into
loops?

---
- name: launch compute instances
  hosts: localhost
  vars:
     auth_url: "http://controller:35357/v2.0/";
     username:
     password:
     project:
     image: CentOS-7-x86_64-GenericCloud-1601
     key: key
     timeout: 200
     flavor: m1.large
     security: default
     volume_size: 1
     volumes_storage1:
       - storage1_vdb
       - storage1_vdc
       - storage1_vdd
       - storage1_vde
       - storage1_vdf
       - storage1_vdg
       - storage1_vdh
       - storage1_vdi
       - storage1_vdj
       - storage1_vdk

  tasks:
  - name: create {{ volume_size }}g storage1_vdb
    os_volume:
      state: present
      auth:
        auth_url: "{{ auth_url }}"
        username: "{{ username }}"
        password: "{{ password }}"
        project_name: "{{ project }}"
      size: "{{ volume_size }}"
      display_name: storage1_vdb

  - name: launch sql
    os_server:
      state: present
      auth:
        auth_url: "{{ auth_url }}"
        username: "{{ username }}"
        password: "{{ password }}"
        project_name: "{{ project }}"
      name: sql1
      image: "{{ image }}"
      key_name: "{{ key }}"
      timeout: "{{ timeout }}"
      flavor: "{{ flavor }}"
      security_groups: "{{ security }}"

  - name: launch storage1
    os_server:
      state: present
      auth:
        auth_url: "{{ auth_url }}"
        username: "{{ username }}"
        password: "{{ password }}"
        project_name: "{{ project }}"
      name: storage1
      image: "{{ image }}"
      key_name: "{{ key }}"
      timeout: "{{ timeout }}"
      flavor: "{{ flavor }}"
      security_groups: "{{ security }}"
      volumes:
        "{{ volumes_storage1 }}"

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKsMCEQ_Dy_ZDJbrY1jG24%3Di4oaRG2OsHNu5tOOAS_5Pvx27uQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to