Skip to content

Instantly share code, notes, and snippets.

@alexhayes
Last active August 29, 2015 14:11
Show Gist options
  • Save alexhayes/118120bbfbb3828fc9f9 to your computer and use it in GitHub Desktop.
Save alexhayes/118120bbfbb3828fc9f9 to your computer and use it in GitHub Desktop.
SLS require that only has an include fails

It appears that if you have a require with sls: foo and foo.sls itself only has include: statements the requirement fails.

When the command salt \* state.highstate test=True the following is output;

example.com:
----------
          ID: eggs
    Function: cmd.run
        Name: echo "I should be required..."

      Result: None
     Comment: Command "echo "I should be required..."
              " would have been executed
     Started: 00:39:21.139595
    Duration: 5.831 ms
     Changes:   
----------
          ID: bar
    Function: cmd.run
        Name: echo "I require foo.sls, which includes eggs.sls"

      Result: False
     Comment: The following requisites were not found:
                                 require:
                                     sls: foo
     Started: 
    Duration: 
     Changes:   

Summary
------------
Succeeded: 1 (unchanged=1)
Failed:    1
------------
Total states run:     2

If one replaces the contents of foo.sls with eggs.sls the requirement works as expected;

example.com:
----------
          ID: eggs
    Function: cmd.run
        Name: echo "I should be required..."

      Result: None
     Comment: Command "echo "I should be required..."
              " would have been executed
     Started: 00:43:08.872786
    Duration: 0.312 ms
     Changes:   
----------
          ID: bar
    Function: cmd.run
        Name: echo "I require foo.sls, which includes eggs.sls"

      Result: None
     Comment: Command "echo "I require foo.sls, which includes eggs.sls"
              " would have been executed
     Started: 00:43:08.873174
    Duration: 2.522 ms
     Changes:   

Summary
------------
Succeeded: 2 (unchanged=2)
Failed:    0
------------
Total states run:     2

Therefore, is this a bug, feature, not supported in Salt or (I'd imagine more the case) am I just doing something wrong.

This is a trivialised example, ideally I'd be putting multiple includes in foo.sls that I can reference in multiple requires throughout my states.

include:
- foo
bar:
cmd.run:
- name: |
echo "I require foo.sls, which includes eggs.sls"
- cwd: /tmp
- shell: /bin/bash
- timeout: 300
- require:
- sls: foo
eggs:
cmd.run:
- name: |
echo "I should be required..."
- cwd: /tmp
- shell: /bin/bash
- timeout: 300
include:
- eggs
base:
'*':
- bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment