CentOS 7
Sponsored Link

Func : Use CommandModule2016/09/29

 
This is the basic Usage for CommandModule.
Actually it's possble to run mostly any commands with this module.
  ⇒ func target call command run "command"
[1] Install "wget" on all Minions.
[root@dlp ~]#
func "*" call command run "yum -y install wget" | sed 's/\\n/\n/g'

('node01.srv.world',
 [0,
  'Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-10.el7_0.1 will be installed
--> Finished Dependency Resolution
.....
.....
Installed:
  wget.x86_64 0:1.14-10.el7_0.1

Complete!
',
  ''])
('dlp.srv.world',
 [0,
  'Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-10.el7_0.1 will be installed
--> Finished Dependency Resolution
.....
.....
Installed:
  wget.x86_64 0:1.14-10.el7_0.1

Complete!
',
  ''])
[2] Run "ls /home" on all Minions.
[root@dlp ~]#
func "*" call command run "ls -l /home" | sed 's/\\n/\n/g'

('node01.srv.world',
 [0,
  'total 4
drwx------. 2 cent cent 59 Aug  8  2015 cent
-rw-r--r--. 1 root root 10 Sep 30 16:46 test.txt
',
  ''])
('dlp.srv.world',
 [0,
  'total 4
drwx------. 2 cent cent 59 Aug  8  2015 cent
-rw-r--r--. 1 root root 10 Sep 30 16:46 test.txt
',
  ''])
[3] Run "cat /etc/passwd" on specific Minions.
[root@dlp ~]#
func "node01.srv.world" call command run "cat /etc/passwd" | sed 's/\\n/\n/g'

('node01.srv.world',
 [0,
  'root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
.....
.....
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
',
  ''])
[4] Create a directory under /home on all Minions.
[root@dlp ~]#
func "*" call command run "mkdir /home/test.dir"

('node01.srv.world', [0, '', ''])
('dlp.srv.world', [0, '', ''])
[root@dlp ~]#
func "*" call command run "ls -ld /home/test.dir" | sed 's/\\n/\n/g'

('node01.srv.world',
 [0, 'drwx------. 2 root root 6 Sep 30 17:01 /home/test.dir
', ''])
('dlp.srv.world',
 [0, 'drwx------. 2 root root 6 Sep 30 17:01 /home/test.dir
', ''])
[5] Run Changing owner and permission to nobody:600 for /home/test.txt on all Minions.
[root@dlp ~]#
func "*" call command run "chown nobody. /home/test.txt;chmod 600 /home/test.txt"

('node01.srv.world', [0, '', ''])
('dlp.srv.world', [0, '', ''])
[root@dlp ~]#
func "*" call command run "ls -l /home/test.txt" | sed 's/\\n/\n/g'

('node01.srv.world',
 [0, '-rw-------. 1 nobody nobody 10 Sep 30 16:46 /home/test.txt
', ''])
('dlp.srv.world',
 [0, '-rw-------. 1 nobody nobody 10 Sep 30 16:46 /home/test.txt
', ''])
[6] Restart ntpd on all Minions.
[root@dlp ~]#
func "*" call command run "systemctl restart ntpd" | sed 's/\\n/\n/g'

('node01.srv.world', [0, '', ''])
('dlp.srv.world', [0, '', ''])
Matched Content