# Configure 5 Linux servers with one block code in playbbok ansible\_local

**URL:** <https://forum.ansible.com/t/configure-5-linux-servers-with-one-block-code-in-playbbok-ansible-local/28438>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 28, 2018, 7:58am UTC](https://forum.ansible.com/t/configure-5-linux-servers-with-one-block-code-in-playbbok-ansible-local/28438 "2018-08-28T07:58:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenZ](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@BenZ](https://forum.ansible.com/u/BenZ)\
**Post date:** [August 28, 2018, 7:58am UTC](https://forum.ansible.com/t/configure-5-linux-servers-with-one-block-code-in-playbbok-ansible-local/28438/1 "2018-08-28T07:58:47Z")

</div>

Hi,  
I am using vagrant to create 5 servers and using ansible to configure each of them to install Nginx and add the the sentence "hello from web server{server number}.  
I am trying to understand what is best way to configure the playbook to configure the servers in one block. Now I use 5 blocks that have the same code only the server number is changed(web1, web2,web3, etc) and the number I write to the index file.I am using ansible\_local.

vagrantfile  
`

Vagrant.configure(“2”) do |config|

N = 5  
(1…N).each do |machine\_id|  
config.vm.define “web#{machine\_id}” do |machine|  
machine.vm.box = “ubuntu/trusty64”  
machine.vm.hostname = “web”  
machine.vm.network “private\_network”, ip: “10.0.0.#{10+machine\_id}”  
end

config.vm.provision “ansible\_local” do |ansible|  
ansible.playbook = “playbook.yml”  
ansible.become = true  
ansible.extra\_vars = { machine: “web#{machine\_id}” }  
ansible.groups = {  
“group1” =\> [“web”],  
}  
end  
end

`

playbook code

`

- hosts: web1  
become: true  
tasks:
- name: ensure nginx is at the latest version  
apt: name=nginx state=latest
- name: start nginx  
service:  
name: nginx  
state: started
- name: add server name to nginx html  
lineinfile:  
dest: /usr/share/nginx/html/index.html  
insertafter: “^

_Thank you for using nginx.”  
line:_

_hello from web server-1"_

  
_`_
