# Config multiple devices

**URL:** <https://forum.ansible.com/t/config-multiple-devices/27166>\
**Category:** Ansible Project\
**Created:** [April 1, 2018, 9:43am UTC](https://forum.ansible.com/t/config-multiple-devices/27166 "2018-04-01T09:43:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juraj\_Papic1](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@Juraj\_Papic1](https://forum.ansible.com/u/Juraj_Papic1)\
**Post date:** [April 1, 2018, 9:43am UTC](https://forum.ansible.com/t/config-multiple-devices/27166/1 "2018-04-01T09:43:08Z")

</div>

all,

I have to configure multiple devices with different configurations, how can I run a single playbook and separate the configurations for each device?

.

---

<div class="post-metadata">

**Author:** ![Oleg\_Gerasymchuk](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@Oleg\_Gerasymchuk](https://forum.ansible.com/u/Oleg_Gerasymchuk)\
**Post date:** [April 2, 2018, 7:02pm UTC](https://forum.ansible.com/t/config-multiple-devices/27166/2 "2018-04-02T19:02:15Z")

</div>

Hi Juraj.

I think, you might need to create [standard role structure](http://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#role-directory-structure) with something like this:

yourrole/

tasks/

main.yml

hostname1.yml

hostname2.yml

hostnameN.yml

files/

hostname1.config

hostname2.config

hostnameN.config

templates/

hostname1.yml.j2

hostname2.yml.j2

hostnameN.yml.j2

In proposed structure only tasks/main.yml file is necessary.

Other files may depends on your needs and might not be included.

In tasks/main.yml you may use something like this:

- name: Copy configuration for host

copy:

src: “{{ inventory\_hostname }}”

dest: /destination\_folder\_of your config

backup: yes

force: no

or this:

- name: Copy [template](https://docs.ansible.com/ansible/2.3/template_module.html#template-templates-a-file-out-to-a-remote-server) for host

template:

src: “{{ inventory\_hostname }}”

dest: /destination\_folder\_of your config

backup: yes

force: no

or this:

- name: Import task with host-specific configuration

import\_tasks: “{{ inventory\_hostname }}.yml”

This is only example describe one of many possible options, without additional details.

Configuration may depends not on hostname, but on other facts, defined by [setup](http://docs.ansible.com/ansible/latest/modules/setup_module.html) module.

Hope it will helps. If you’ll need additional details, feel free to ask and attach please some additional details of necessary configuration.

Regards,

---

<div class="post-metadata">

**Author:** ![Juraj\_Papic1](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@Juraj\_Papic1](https://forum.ansible.com/u/Juraj_Papic1)\
**Post date:** [April 3, 2018, 12:46pm UTC](https://forum.ansible.com/t/config-multiple-devices/27166/3 "2018-04-03T12:46:06Z")

</div>

Hello Oleg

Thanks for the tip that is what I was looking for!

Thanks!

---

<div class="post-metadata">

**Author:** ![Juraj\_Papic1](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@Juraj\_Papic1](https://forum.ansible.com/u/Juraj_Papic1)\
**Post date:** [April 3, 2018, 5:05pm UTC](https://forum.ansible.com/t/config-multiple-devices/27166/4 "2018-04-03T17:05:20Z")

</div>

Hello ,

I have the following playbook , this is to add acls to my cisco router. I get the template from my jinja2 file and the info is in the group\_vars/all.yml

I need this to be applied to Router1 and Router2 but both of them have different type of acls, with this playbook, how can I apply this ?

thanks

bkp.yml
