I am probably have my syntax wrong but I am trying to reduce the amount of 
code in my playbook when creating cloud block storage volumes using 
rax_cbs. Here is what it looks like currently and works great:

- name: Build a Block Storage Volume
  gather_facts: False
  hosts: localhost
  connection: local
  tasks:
    - name: Create glustor1
      local_action:
        module: rax_cbs
        name: glustor1
        description: brick2
        volume_type: SATA
        size: 100
        region: DFW
        wait: yes
        state: present
        meta:
          app: glustor1
      register: raxvolumes
    - name: Create glustor2
      local_action:
        module: rax_cbs
        name: glustor2
        description: brick2
        volume_type: SATA
        size: 100
        region: DFW
        wait: yes
        state: present
        meta:
          app: glustor2
      register: raxvolumes
    - name: Create glustor3
      local_action:
        module: rax_cbs
        name: glustor3
        description: brick3
        volume_type: SATA
        size: 100
        region: DFW
        wait: yes
        state: present
        meta:
          app: glustor3
      register: raxvolumes
    - name: Create glustor4
      local_action:
        module: rax_cbs
        name: glustor4
        description: brick4
        volume_type: SATA
        size: 100
        region: DFW
        wait: yes
        state: present
        meta:
          app: glustor4
      register: raxvolumes

And I have tried the following based on 
http://docs.ansible.com/playbooks_loops.html but it errors due to item not 
being defined:

- name: Build a Block Storage Volume # I also tried changing {{ item }} to 
{{ format }}
  gather_facts: False
  hosts: localhost
  connection: local
  tasks:
    - name: Create glustor bricks
      local_action:
        module: rax_cbs
        name: "{{ item }}"
        description: Glustor Brick
        volume_type: SATA
        size: 100
        region: DFW
        wait: yes
        state: present
        with_sequence: start=1 end=4 format=glustor%d
      register: raxvolumes

TASK: [Create glustor bricks] 
*************************************************
fatal: [localhost] => One or more undefined variables: 'item' is undefined

FATAL: all hosts have already failed -- aborting

Also tried the following:

- name: Build a Block Storage Volume
  gather_facts: False
  hosts: localhost
  connection: local
  tasks:
    - name: Create glustor bricks
      local_action:
        module: rax_cbs
        name: "{{ item }}"
        description: Glustor Brick
        volume_type: SATA
        size: 100
        region: DFW
        wait: yes
        state: present
        with_items:
          - glustor1
          - glustor2
          - glustor3
          - glustor4
      register: raxvolumes

TASK: [Create glustor bricks] 
*************************************************
fatal: [localhost] => One or more undefined variables: 'item' is undefined

FATAL: all hosts have already failed -- aborting

Thanks for pointing me in the right direction!

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/07a3acaf-3495-431d-b357-1657cda651ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to