Saltstack learning (f) - Development and execution module API use

First, the execution module development

saltstack python modules built storage path: /usr/lib/python2.7/site-packages/salt/modules

1.1, custom module

# Python modules prepared 
[the root-Master Salt @ ~] # mkdir -p / SRV / Salt / Base / _modules 
[the root-Master Salt @ ~] # CD / SRV / Salt / Base / _modules 
[the root-Master Salt @ _modules] Vim my_disk.py # 
DEF List (): 
    cmd = '-H DF' 
    RET = __salt __ [ 'cmd.run'] (cmd) 
    return RET 

# synchronization Minion 
[the root-Master Salt @ _modules] Salt # '*' saltutil. sync_modules saltenv = base # environment can be specified 

on #minion View 
[@ syndic of the modules the root] # pwd 
/ var / Cache / Salt / Minion / extmods / modules #MASTER pushed over the module file path 
[@ syndic of the modules the root] # LL 
-rw On Sep 80 the root the root. 1 -------. 1 14:24 my_disk.py 

# test is performed 
[the root-Master Salt @ _modules] Salt # '*' my_disk.list 
Salt-C7-minion1: 
    the Filesystem Size Used Avail the Use% Mounted ON
    /dev/sda2        48G  2.3G   46G   5% /
    devtmpfs        479M     0  479M   0% /dev
    tmpfs           489M   28K  489M   1% /dev/shm
    tmpfs           489M  6.7M  482M   2% /run
    tmpfs           489M     0  489M   0% /sys/fs/cgroup
    tmpfs            98M     0   98M   0% /run/user/0
salt-minion2-c7:
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda2        48G  2.3G   46G   5% /
    devtmpfs        479M     0  479M   0% /dev
    tmpfs           489M   12K  489M   1% /dev/shm
    tmpfs           489M  6.7M  482M   2% /run
    tmpfs           489M     0  489M   0% /sys/fs/cgroup
    tmpfs            98M     0   98M   0% /run/user/0

Guess you like

Origin www.cnblogs.com/hujinzhong/p/11442222.html