salt icon indicating copy to clipboard operation
salt copied to clipboard

Add support for 'ignore_missing: True' option to states

Open ksoviero opened this issue 9 years ago • 1 comments

Description of Issue/Question

Our pillar/top.sls file looks like this:

{% set role = grains['ec2_tags']['role'] %}
{% set host = grains['id'].replace('.', '_') %}
{% set env = grains['ec2_tags']['env'] %}

base:
  '*':
    - roles.all

  'ec2_tags:role:{{ role }}':
    - match: grain
    - roles.{{ role }}
    - ignore_missing: True

  '{{ grains['id'] }}':
    - hosts.{{host}}
    - ignore_missing: True

  'ec2_tags:env:{{ env }}':
    - match: grain
    - envs.{{ env }}
    - ignore_missing: True

I'd like to do something very similar for states, however the states/top.sls file does not support the 'ignore_missing: True' attribute. As such, anytime we create a host with a new role, we have to make sure that the role is already defined in Salt. Otherwise, users won't even be able to login to the new hosts since the roles.all state will not have applied.

On top of that, host-specific states (edge cases can require this) are impossible since any host that doesn't need one will throw an error regardless since it will try to import it.

Versions Report

# salt --versions-report
Salt Version:
           Salt: 2016.11.1
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.4.2
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.3
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: Ubuntu 16.04 xenial
        machine: x86_64
        release: 4.4.0-59-generic
         system: Linux
        version: Ubuntu 16.04 xenial

ksoviero avatar Feb 06 '17 07:02 ksoviero

Marked as duplicate.

ksoviero avatar Feb 06 '17 18:02 ksoviero