# Director how-to merge vars.LISTs from different import sources

**URL:** <https://community.icinga.com/t/director-how-to-merge-vars-lists-from-different-import-sources/11511>\
**Category:** Icinga Director\
**Tags:** automation\
**Created:** [February 27, 2023, 8:54am UTC](https://community.icinga.com/t/director-how-to-merge-vars-lists-from-different-import-sources/11511 "2023-02-27T08:54:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PedroMSantosD](https://community.icinga.com/user_avatar/community.icinga.com/pedromsantosd/32/2435_2.png) [@PedroMSantosD](https://community.icinga.com/u/PedroMSantosD)\
**Post date:** [February 27, 2023, 8:54am UTC](https://community.icinga.com/t/director-how-to-merge-vars-lists-from-different-import-sources/11511/1 "2023-02-27T08:54:12Z")

</div>

Hi,

I´m trying to automate the creation of hosts on my Icinga-director by importing from a database the FQDN/OS version and a predefined set of vars;

and then I want to merge and replace some of those vars.

When I try to merge the vars, the latest imported takes prececende,

example:  
**Import source 1:**  
ColumnName: FQDN of the host  
Column vars:

```auto
{
  cpu_load_crit: "2,1.5,1",

  services: [
      "SNMP",
      "MySQL"
    ],
}

```

**Import source 2:**  
ColumnName: FQDN of the host  
Column custom\_variables:

```auto
{
  cpu_load_crit: "12,8,6",

}

```

**Import source 3:**  
ColumnName: FQDN of the host  
Column custom\_variables:

```auto
{
  services: [
    "MySQL-slave"
  ]
}

```

As per documentation, using a Sync rule (rule order 3) to  
replace ${vars.cpu\_load\_crit} should end tiwh the nes value of cpu\_load\_crit: “12,8,6”,  
and the Sync Rule to MERGE ${vars.services} should create the list:

```auto
[
      "SNMP",
      "MySQL",
      "MySQL-slave"
]

```

Sync Rule:

 ![image](https://community.icinga.com/uploads/default/original/2X/9/9153d38bfe9a6b341eda75e0107401b108c4f90e.png)

Yet the merge behaviour does not work, an I get a replacement with the latest value: namely a single mysql-slave service. (the cpu\_load does get replaced thought).

Preview:  
 ![image](https://community.icinga.com/uploads/default/original/2X/d/dd1f047afb35d7592e2e5b28575ddae8344848af.png)

![image](https://community.icinga.com/uploads/default/original/2X/d/d9a75ae04bf51c6b6e869c0f6ab5fce18ad0b6ef.png)

Can anyone share how to actually override data on the sync rules with the merge command… if at all possible?

Th  
Before you ask a question, you can check [the troubleshooting documentation](https://icinga.com/docs/icinga-2/latest/doc/15-troubleshooting/) ºfirst, maybe you can find an answer here.  
Checked automation, but this similar topics show no solution for my issue

- [How to Override automation using director](https://community.icinga.com/t/how-to-override-automation-using-director/4296)
- [Override automation in icinga](https://community.icinga.com/t/override-automation-in-icinga/4155)

Give as much information as you can, e.g.

- Director version (System - About): 1.10.2
- Icinga Web 2 version and modules (System - About): 2.11.4
- Icinga 2 version (`icinga2 --version`): icinga2-2.13.6-2.el7.x86\_64
- Operating System and version: CentOS 7.9.2009 : x86\_64
- Webserver, PHP versions: 7.3.29

---

<div class="post-metadata">

**Author:** ![rivad](https://community.icinga.com/user_avatar/community.icinga.com/rivad/32/5852_2.png) [@rivad](https://community.icinga.com/u/rivad)\
**Post date:** [February 27, 2023, 1:48pm UTC](https://community.icinga.com/t/director-how-to-merge-vars-lists-from-different-import-sources/11511/2 "2023-02-27T13:48:03Z")

</div>

I’m not sure but try to use the multiple import sources in one combined sync rule.

---

<div class="post-metadata">

**Author:** ![PedroMSantosD](https://community.icinga.com/user_avatar/community.icinga.com/pedromsantosd/32/2435_2.png) [@PedroMSantosD](https://community.icinga.com/u/PedroMSantosD)\
**Post date:** [March 1, 2023, 8:51am UTC](https://community.icinga.com/t/director-how-to-merge-vars-lists-from-different-import-sources/11511/3 "2023-03-01T08:51:51Z")

</div>

Hi Dominik, thanks for your reply,  
I am combining the 3 import source (data) into a single sync rule (to produce objects); that’s listed on the sync rule properties image, where the import sources are named:  
mysqlnodes, mysql\_laves and mysql\_overries

My concern is about the end result not merging a list property but replacing its value with the latest entry; as thought it were parsed as text, and not as an object.

---

<div class="post-metadata">

**Author:** ![rivad](https://community.icinga.com/user_avatar/community.icinga.com/rivad/32/5852_2.png) [@rivad](https://community.icinga.com/u/rivad)\
**Post date:** [March 1, 2023, 10:39am UTC](https://community.icinga.com/t/director-how-to-merge-vars-lists-from-different-import-sources/11511/4 "2023-03-01T10:39:23Z")

</div>

Sadly the documentation isn’t so good and I also have to experiment quite a lot until I get imports working the way I like.
