Thanks Matt! On Tuesday, May 27, 2014 11:44:28 AM UTC-5, Matt Martz wrote: > > Your with_items or with_sequence is indented too far. It should match the > indentation of "register" and "name". > > Also be aware of how register and with_ works. There are some docs on the > playbooks loops page in the docs. > > On Tuesday, May 27, 2014, Jimmy Prescott <[email protected]<javascript:>> > wrote: > >> 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 [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/07a3acaf-3495-431d-b357-1657cda651ba%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/07a3acaf-3495-431d-b357-1657cda651ba%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Matt Martz > [email protected] <javascript:> > http://sivel.net/ >
-- 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/e46a983f-2e35-4558-a19d-df3ee641ac91%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
