These states allow individual execution module calls to be made via states. To
call a single module function use a module.run
state:
mine.send:
module.run:
- name: network.interfaces
Note that this example is probably unnecessary to use in practice, since the
mine_functions
and mine_interval
config parameters can be used to
schedule updates for the mine (see here for more
info).
It is sometimes desirable to trigger a function call after a state is executed,
for this the module.wait
state can be used:
mine.send:
module.wait:
- name: network.interfaces
- watch:
- file: /etc/network/interfaces
All arguments that the module
state does not consume are passed through to
the execution module function being executed:
fetch_out_of_band:
module.run:
- name: git.fetch
- cwd: /path/to/my/repo
- user: myuser
- opts: '--all'
Due to how the state system works, if a module function accepts an
argument called, name
, then m_name
must be used to specify that
argument, to avoid a collision with the name
argument.
Here is a list of keywords hidden by the state system, which must be prefixed
with m_
:
For example:
disable_nfs:
module.run:
- name: service.disable
- m_name: nfs
Note that some modules read all or some of the arguments from a list of keyword arguments. For example:
mine.send:
module.run:
- func: network.ip_addrs
- kwargs:
interface: eth0
cloud.create:
module.run:
- func: cloud.create
- provider: test-provider
- m_names:
- test-vlad
- kwargs: {
ssh_username: 'ubuntu',
image: 'ami-8d6d9daa',
securitygroup: 'default',
size: 'c3.large',
location: 'ap-northeast-1',
delvol_on_destroy: 'True'
}
salt.states.module.
mod_watch
(name, **kwargs)This function is an alias of run
.
Run a single module function
name
- The module function to execute
returner
- Specify the returner to send the return of the module execution to
**kwargs
- Pass any arguments needed to execute the function
salt.states.module.
run
(name, **kwargs)Run a single module function
name
returner
**kwargs
salt.states.module.
wait
(name, **kwargs)Run a single module function only if the watch statement calls it
name
**kwargs
注解
Like the cmd.run
state, this state will
return True
but not actually execute, unless one of the following
two things happens:
watch_in
changes.