# rax module creates new server every time

**URL:** <https://forum.ansible.com/t/rax-module-creates-new-server-every-time/15142>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [May 2, 2014, 2:29pm UTC](https://forum.ansible.com/t/rax-module-creates-new-server-every-time/15142 "2014-05-02T14:29:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [May 2, 2014, 2:29pm UTC](https://forum.ansible.com/t/rax-module-creates-new-server-every-time/15142/1 "2014-05-02T14:29:07Z")

</div>

When using the rax module everytime I run it it creates a new server with the same name. Shouldn’t it just say “ok” if the server name already exists?

- name: Server build request  
rax:  
credentials: “{{ bamboo\_build\_working\_directory }}/.rackconnect”  
name: “q-helios-test-{{ item.name }}”  
flavor: performance1-1  
image: ubuntu-1204-lts-precise-pangolin  
wait: yes  
state: present  
auto\_increment: False  
wait\_timeout: 600  
networks:
- private
- public  
group: “{{ item.groups }}”  
with\_items:
- { name: ‘web01’, groups: ‘web’ }
- { name: ‘web02’, groups: ‘web’ }

If this is how its supposed to work how can I change my task so it only creates the server if it hasn’t already been created?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 2, 2014, 2:54pm UTC](https://forum.ansible.com/t/rax-module-creates-new-server-every-time/15142/2 "2014-05-02T14:54:21Z")

</div>

Unless, you specify an ‘exact\_count: yes’ when using ‘group’, this is the expected behavior.

If you omit ‘group’, it will not continue creating new servers.

Also, the way that I would recommend using the module for what you are attempting is:

- name: Server build request  
rax:  
credentials: “{{ bamboo\_build\_working\_directory }}/.rackconnect”  
name: “q-helios-test-web%02d”  
flavor: performance1-1  
image: ubuntu-1204-lts-precise-pangolin  
wait: yes  
state: present  
wait\_timeout: 600  
networks:
- private
- public  
group: web  
exact\_count: yes  
count: 2

This will create 2 servers, named q-helios-test-web01 and q-helios-test-web02, with group=web. It will always ensure a count of 2.

This will also be faster to build than your previous method, as it creates the servers in parallel, instead of serially. It also utilizes printf style formatting to define the name of the servers, which alleviates you having to manually increment the number in the host name.

Also, if you are indeed utilizing rackconnect, you may want to look at my example playbooks, that appropriately wait for RackConnect and Managed Cloud automation to complete before configuring the servers:

[https://github.com/sivel/ansible-samples/tree/master/rackconnect](https://github.com/sivel/ansible-samples/tree/master/rackconnect)

Those examples will be added to the Rackspace Guide in the Ansible docs in the near future.

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [May 2, 2014, 2:58pm UTC](https://forum.ansible.com/t/rax-module-creates-new-server-every-time/15142/3 "2014-05-02T14:58:17Z")

</div>

Thanks Matt! That wasn’t clear in the module documentation. Also thank you for the samples.

I would much rather spin the servers up in parallel. Is there a way I can spin up different server names like the list below in parallel? Or do I need different tasks for each group?

- { name: ‘web01’, groups: ‘web’ }
- { name: ‘web02’, groups: ‘web’ }
- { name: ‘app01’, groups: ‘app’ }
- { name: ‘app02’, groups: ‘app’ }
- { name: ‘app03’, groups: ‘app’ }
- { name: ‘pgm01’, groups: ‘pgm’ }
- { name: ‘pgm02’, groups: ‘pgm’ }
- { name: ‘pgm03’, groups: ‘pgm’ }
- { name: ‘services01’, groups: ‘services’ }

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 2, 2014, 3:07pm UTC](https://forum.ansible.com/t/rax-module-creates-new-server-every-time/15142/4 "2014-05-02T15:07:20Z")

</div>

You will have to spin up servers in groups. Each group will happen in parallel. There is no existing functionality to spin up servers of different groups/names in parallel currently.

So you will have to do ‘web’, ‘app’, ‘pgm’ and ‘services’ as 4 different ‘rax’ invocations.
