Duplicate sls in multi-environment while using include

59 views
Skip to first unread message

ty...@ospreyinformatics.com

unread,
Mar 10, 2015, 8:01:24 PM3/10/15
to salt-...@googlegroups.com
We're using salt along with Vagrant to try and manage both our production and development environments. 

We have states laid out similar to: 

top.sls:


base:
 
'*':
   
- core


 
'G@roles:target_role and environment:production':
   
- match: compound
   
- target_state




dev
/top.sls


dev
:
 
'G@roles:target_role and envirionment:dev':
   
- match: compound
   
- target_state


Both the target_state  and core are located in the base environment and has an include statement for core as some of the target_state require things like git and pip to be installed. The production state works without issue. 

However when we try and build our vagrant machine we get an error:


Detected conflicting IDs, SLS IDs need to be globally unique.
The conflicting ID is 'git' and is found in SLS 'base:core' and SLS 'dev:core'


Removing the wildcard targeting core to all machines from the base environment resolves the problem. 

Is there a way to ensure that core is installed on our all production machines while still including it in states to ensure the pre-requisites are installed? 

Cheers,

Tyler

Colton Myers

unread,
Mar 13, 2015, 12:13:10 PM3/13/15
to salt-...@googlegroups.com
So the problem here is that your dev environment minions end up with two copies of `core.sls` in their state run. One from the '*' targeting in the base environment, and one from the include on the dev `target_state.sls`. (I assume you have a copy of `core.sls` in the dev environment that's being included by `target_state.sls)

I think the answer is for the dev version of `target_state.sls` to include the base version of `core.sls`. The include will look like this:

include:
  - base: core

Keep me posted if that doesn't solve your issue.

--
Colton Myers
Platform Engineer, SaltStack
@basepi on Github/Twitter/IRC

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

ty...@ospreyinformatics.com

unread,
Mar 13, 2015, 1:00:15 PM3/13/15
to salt-...@googlegroups.com
Hi Colton, 

Thanks for the reply and the suggestion. 

Switching the include to base: core resolves the duplicate sls issue but I'm now getting an error:

No matching sls found for 'core.sls' in env 'base'

We do not have a copy of core in our dev environment. (Core is actually a folder with an init.sls if that makes a difference). I was hoping to avoid having to duplicate the code. Our states our laid out like this:

└── salt
   
├── core
   
  └── init.sls
   
├── dev
   
  ├── state_b
   
    └── init.sls
   
  └── top.sls
   
├── target_state
   
  └── init.sls
   
└── top.sls



The file_roots looks like this: 

file_roots:
 
base:
   
- /srv/salt
  dev
:
   
- /srv/salt/dev
   
- /srv/salt

I'm not sure if it will make a difference but the Vagrant machines are being provisioned as standalone minions, to avoid having to accept keys from ephemeral development machines. 

Thanks again for the help, 

Cheers,
Tyler

Colton Myers

unread,
Mar 24, 2015, 4:11:15 PM3/24/15
to salt-...@googlegroups.com
Thanks for the update Tyler.

I think you're running into this bug: https://github.com/saltstack/salt/issues/14733

Keep me posted if you agree.

--
Colton Myers
Platform Engineer, SaltStack
@basepi on Github/Twitter/IRC

Tyler Field

unread,
Mar 27, 2015, 2:07:35 PM3/27/15
to salt-...@googlegroups.com
Hi Colton, 

It looks very similar. Our work-around for the time being has been to remove the global targeting in base for our core states and ensure that they are included in a more targeted manner. 

Cheers,
Tyler

You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/DTSqH3xZyj8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Tyler Field
Dev/Ops Specialist
--------------------------
This e-mail and any attachments may contain information that is confidential and/or privileged. If you are not the intended recipient and appear to have received this e-mail in error, please notify us immediately and then delete all copies from your computer system. Any unauthorized use, copying or further distribution is prohibited. Please also note that if you send us e-mails containing time-sensitive or important instructions, you should ensure that receipt has been timely acknowledged in view of the potential for misdirection or inadvertent interception. Thank you.
Reply all
Reply to author
Forward
0 new messages