Skip to content

Support require and watch under the same state dec #552

@jhutchins

Description

@jhutchins

Running salt 0.9.5 on master and client with a simple sate file like the following

postfix:
  pkg:
    - installed
  service:
    - enable: True
    - running
    - watch:
      - file: /etc/postfix/main.cf

/etc/postfix/main.cf:
  file:
    - managed
    - source: salt://pbx/postfix/main.cf
    - template: jinja
    - mode: 644
    - require:
      - pkg: postfix

A trivial change to the main.cf file produces the following output:

----------
    State: - file
    Name:      /etc/postfix/main.cf
    Function:  managed
        Result:    True
        Comment:   File /etc/postfix/main.cf updated
        Changes:   diff: ---  
+++  
@@ -1,3 +1,4 @@
+#Test
 queue_directory = /var/spool/postfix
 command_directory = /usr/sbin
 daemon_directory = /usr/libexec/postfix


----------
    State: - service
    Name:      postfix
    Function:  running
        Result:    True
        Comment:   Service restarted
        Changes:   postfix: True

However is you add a requires declaration for the postfix service state then the service no longer restarts.

State file:

postfix:
  pkg:
    - installed
  service:
    - enable: True
    - running
    - require:
      - pkg: postfix    
    - watch:
      - file: /etc/postfix/main.cf

/etc/postfix/main.cf:
  file:
    - managed
    - source: salt://pbx/postfix/main.cf
    - template: jinja
    - mode: 644
    - require:
      - pkg: postfix

Output:

----------
    State: - file
    Name:      /etc/postfix/main.cf
    Function:  managed
        Result:    True
        Comment:   File /etc/postfix/main.cf updated
        Changes:   diff: ---  
+++  
@@ -1,4 +1,3 @@
-#Test
 queue_directory = /var/spool/postfix
 command_directory = /usr/sbin
 daemon_directory = /usr/libexec/postfix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions