标签:salt自定义模块
salt默认模块路径
[root@node1 base]# ll /usr/lib/python2.6/site-packages/salt/modules/saltstack
自定义salt模块
[root@node1 _grains]# cd /srv/salt/base/ [root@node1 base]# mkdir _modules [root@node1 base]# cd _modules/ [root@node1 base]# salt ‘*‘ cmd.run ‘df -h‘ #将这个命令写成模块 [root@node1 _modules]# cat my_disk.py def list(): cmd = ‘df -h‘ ret = __salt__[‘cmd.run‘](cmd) return ret
将模块发到minion
[root@node1 _modules]# salt ‘*‘ saltutil.sync_modules node2: - modules.my_disk node1: - modules.my_disk
执行模块
[root@node1 _modules]# salt ‘*‘ my_disk.list node2: Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 8.3G 2.6G 5.3G 34% / tmpfs 495M 12K 495M 1% /dev/shm /dev/sda1 477M 28M 424M 7% /boot node1: Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 8.3G 2.7G 5.3G 34% / tmpfs 495M 16K 495M 1% /dev/shm /dev/sda1 477M 28M 424M 7% /boot
本文出自 “feng” 博客,请务必保留此出处http://fengxiaoli.blog.51cto.com/12104465/1958794
标签:salt自定义模块
原文地址:http://fengxiaoli.blog.51cto.com/12104465/1958794