# Help how to achieve the same like in Chef

**URL:** <https://forum.ansible.com/t/help-how-to-achieve-the-same-like-in-chef/18551>\
**Category:** Ansible Project\
**Created:** [June 19, 2015, 4:18pm UTC](https://forum.ansible.com/t/help-how-to-achieve-the-same-like-in-chef/18551 "2015-06-19T16:18:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [June 19, 2015, 4:18pm UTC](https://forum.ansible.com/t/help-how-to-achieve-the-same-like-in-chef/18551/1 "2015-06-19T16:18:57Z")

</div>

Hi,

I’m trying to migrate from Chef a recipe for HAProxy.

In the bellow config one of the pool groups are considered to be coming from slow server connections and we isolate them to use certain number of web servers and not all of them as when you have lot’s of requests with relatively higher timeouts it could cause other servers with normal latency to starve.

In order to accomplish this in Chef we assign 1 of every 5 servers to the slow\_pool\_members and every 4 server to the normal\_pool\_members :

```auto
slow_pool_members = []
normal_pool_members = []

```

```auto
pool_members.each_with_index do |member, i|
  if i % 5 == 4
    slow_pool_members << member
  else
    normal_pool_members << member
  end
end

```

The above in Chef is Ruby code, can someone help me how can I do something similar in Ansible ?

Regards,  
N.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 19, 2015, 4:39pm UTC](https://forum.ansible.com/t/help-how-to-achieve-the-same-like-in-chef/18551/2 "2015-06-19T16:39:10Z")

</div>

many ways to do this, I would just use a configuration template:

# in slow pool part of config  
{% for host in fullpool %}  
{% if loop.index % 5 == 4 %}  
{{host}}  
{% endif%}  
{% endfor %}

# in normal pool part of config  
{% for host in fullpool %}  
{% if loop.index % 5 != 4 %}  
{{host}}  
{% endif%}  
{% endfor %}

---

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [June 21, 2015, 11:59pm UTC](https://forum.ansible.com/t/help-how-to-achieve-the-same-like-in-chef/18551/3 "2015-06-21T23:59:08Z")

</div>

Thank you , that worked very well.
