Đây là cách sử dụng cơ bản của CommandModule. Trên thực tế, có thể chạy hầu hết mọi lệnh với mô-đun này. â‡' lệnh gọi mục tiêu func chạy "lệnh" | |
[1] | Cài đặt "wget" trên tất cả Minion. |
[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] | Chạy "ls /home" trên tất cả 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] | Chạy "cat /etc/passwd" trên các Minions cụ thể. |
[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] | Tạo một thư mục trong /home trên tất cả các 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] | Chạy Thay đổi chủ sở hữu và quyền thành không ai: 600 cho /home/test.txt trên tất cả 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] | Khởi động lại ntpd trên tất cả Minion. |
[root@dlp ~]# func "*" call command run "systemctl restart ntpd" | sed 's/\\n/\n/g' ('node01.srv.world', [0, '', '']) ('dlp.srv.world', [0, '', '']) |