saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.16k stars 5.48k forks source link

require_in overrides excludes #6237

Closed josmardias closed 1 year ago

josmardias commented 11 years ago

I'm using Fedora 19

$ salt --versions-report
           Salt: 0.15.3
         Python: 2.7.5 (default, Jul  8 2013, 09:48:59)
         Jinja2: 2.6
       M2Crypto: 0.21.1
 msgpack-python: 0.1.13
   msgpack-pure: Not Installed
       pycrypto: 2.6
         PyYAML: 3.10
          PyZMQ: 13.0.0
            ZMQ: 3.2.3

State:

test1:
  file.managed:
    - name: /tmp/nothing

test2:
  file.managed:
    - name: /tmp/nothing2
    - require:
      - file: test1

exclude:
  - id: test1

Output

$ sudo salt-call state.highstate
[INFO    ] Configuration file path: /etc/salt/minion
[INFO    ] Executing command 'ps -efH' in directory '/root'
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file 'salt://top.sls'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/modules'
[INFO    ] Syncing modules for environment 'base'
[INFO    ] Loading cache from salt://_modules, for base)
[INFO    ] Caching directory '_modules/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/states'
[INFO    ] Syncing states for environment 'base'
[INFO    ] Loading cache from salt://_states, for base)
[INFO    ] Caching directory '_states/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/grains'
[INFO    ] Syncing grains for environment 'base'
[INFO    ] Loading cache from salt://_grains, for base)
[INFO    ] Caching directory '_grains/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/renderers'
[INFO    ] Syncing renderers for environment 'base'
[INFO    ] Loading cache from salt://_renderers, for base)
[INFO    ] Caching directory '_renderers/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/returners'
[INFO    ] Syncing returners for environment 'base'
[INFO    ] Loading cache from salt://_returners, for base)
[INFO    ] Caching directory '_returners/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/outputters'
[INFO    ] Syncing outputters for environment 'base'
[INFO    ] Loading cache from salt://_outputters, for base)
[INFO    ] Caching directory '_outputters/' for environment 'base'
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file 'salt://test.sls'
local:
----------
    State: - file
    Name:      /tmp/nothing2
    Function:  managed
        Result:    False
        Comment:   The following requisites were not found:
                   require: {'file': 'test1'}

        Changes:    
thatch45 commented 11 years ago

Yes, exclude will remove the item that is being excluded making it impossible to find, you have created a state, then told salt to remove it, resulting it is not being available to be required. Exclude does not rip out requisites.

josmardias commented 11 years ago

And it should not ript out? At least with me, i'm using it to "patch" some machines. For example, in production i want to a worker machine to have mongos installed, but in development i will not use mongos, so i'm doing something like this:

base:
  'roles:worker':
    - match: grain
    - php
    - mongodb.mongos
  'roles:nomongos':
    - match: grain
    - mongodb.nomongos

and my nomongos.sls

exclude:
  - sls: mongodb.mongos

In production my minion is someting like this:

grains:
  project: rockpigeon
  roles:
    - worker

In devel, my minion is like this:

grains:
  project: rockpigeon
  roles:
    - worker
    - nomongos

I'm doing this, cause worker with mongos is the default behavior, and i get problems before in separate them, in other words, forcing the minion to use a "mongos" grain.

jhenry82 commented 11 years ago

CentOS 6.4 64-bit

           Salt: 0.16.3
         Python: 2.6.6 (r266:84292, Jun 18 2012, 14:18:47)
         Jinja2: 2.2.1
       M2Crypto: 0.20.2
 msgpack-python: 0.1.9.final
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
         PyYAML: 3.10
          PyZMQ: 13.0.2
            ZMQ: 3.2.3

I too am experiencing what I perceive as a bug in exclude with requisites, but a little different. Note the require_in clause instead of require.

test1:
  file.managed:
    - name: /tmp/nothing
    - require_in:
      - file: /tmp/nothing2

test2:
  file.managed:
    - name: /tmp/nothing2

exclude:
  - id: test1

When I run a highstate I get an error like this:

----------
    State: - file
    Name:      /tmp/nothing2
    Function:  managed
        Result:    False
        Comment:   The following requisites were not found:
                   require:
                       file: /tmp/nothing

        Changes:

I believe that excluding the test1 SLS should exclude everything that SLS does, including the require_in. But it seems like the require_in is added to /tmp/nothing2 before the test1 SLS is ripped out, causing a failure.

basepi commented 11 years ago

Thanks for pointing this out, @jhenry82. I'm guessing that it's just an edge case that was not considered when we implemented exclude.

elx-will commented 8 years ago

Was this bug ever fixed? I'm experiencing it now with the below salt --versions-report:

gesadmin@ny5kmduatinit01:~ $ salt --versions-report Salt Version: Salt: 2015.8.8.2

Dependency Versions: Jinja2: 2.8 M2Crypto: Not Installed Mako: Not Installed PyYAML: 3.10 PyZMQ: 14.3.1 Python: 2.7.5 (default, Nov 20 2015, 02:00:19) RAET: Not Installed Tornado: 4.2.1 ZMQ: 3.2.5 cffi: Not Installed cherrypy: Not Installed dateutil: 2.5.3 gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed libgit2: Not Installed libnacl: Not Installed msgpack-pure: Not Installed msgpack-python: 0.4.8 mysql-python: 1.2.3 pycparser: Not Installed pycrypto: 2.6.1 pygit2: Not Installed python-gnupg: Not Installed smmap: Not Installed timelib: 0.2.4

System Versions: dist: centos 7.2.1511 Core machine: x86_64 release: 3.10.0-327.el7.x86_64 system: CentOS Linux 7.2.1511 Core

thatch45 commented 8 years ago

This has not been fixed and I am leaning towards not fixing it. I worry that having an exclude do this may result in unwanted side effects.....

elx-will commented 8 years ago

What would be the recommended workaround?

thatch45 commented 8 years ago

I would say to make a state that does not include the intended exclusion in the first place.

disaster123 commented 7 years ago

+1 for a fix. Still don't understand how to work around this. I've the same issue like @jhenry82

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

disaster123 commented 6 years ago

this issue is still valid

stale[bot] commented 6 years ago

Thank you for updating this issue. It is no longer marked as stale.

waynew commented 4 years ago

@josmardias your original issue is expected behavior, though the documentation isn't very clear. I've opened #55550 to track updating the docs/error message.

@jhenry82 this is a proper bug - if an exclude remove a state that has require_in then we should go ahead and just and remove the requisite, too.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

disaster123 commented 4 years ago

Still valid

stale[bot] commented 4 years ago

Thank you for updating this issue. It is no longer marked as stale.

sagetherage commented 4 years ago

@waynew is there a PR or another ticket for changing requistes/excludes?

waynew commented 4 years ago

@sagetherage this is the ticket for the buggy behavior and #55550 is the ticket to enhance the documentation/error messaging.

dwoz commented 1 year ago

@josmardias @disaster123 This issue is very old and has never gotten much traction. If this is still a priority for you please open a new issue against one of the currently supported versions.