saltStack status module (the relationship between states)

unless: condition judgment between states, the main user state module cmd

Common methods:

  onlyif: Check command, only when returning true 'onlyif' option when a command execution point name defined life

       unless: command check, only when the 'unless' option command returns false point name defined in command execution

 

( 1 ) modify the configuration file, adding authentication function 
[the root @ Linux -node1 Apache] Files # Vim / the httpd.conf 
 <Directory " / var / WWW / HTML / ADMIN " > 
        the AllowOverride All 
        the Order the allow, the deny 
        the Allow All from 
        AuthType Basic 
        the AuthName " haha " 
        the AuthUserFile / etc / the httpd / the conf / htpasswd_file 
        the Require User ADMIN
 </ Directory> 

( 2 ) modify the status file init.sls 
[the root Linux @ - node1 Apache] # Vim init.sls 
Apache - the install : 
  pkg.installed:
    - name: httpd 

the Apache - config:
   File .managed:
     - name: / etc / httpd / conf / the httpd.conf
     - Source: Salt: // the Apache / Files / the httpd.conf 
    - the User: root
     - Group: root
     - the MODE: 644 

Apache - the auth: 
  pkg.installed:
     - name: httpd- Tools 
  cmd.run: ------> using modules run method cmd
     - name: htpasswd -bc / etc / httpd / conf / htpasswd_file admin admin-- -> generate the password file
     - unless: test -f / etc / httpd / conf / htpasswd_file ----> unless judgment conditions, test -f judgment is false is executed. Htpasswd file that is executed if there is no password generation

 

   

Guess you like

Origin www.cnblogs.com/ajaxa/p/11411536.html