コマンドはこんな感じ
[root@centos7 ansible]# ansible -i production common-servers -m shell -a "ntpq -p"cent7-1 | SUCCESS | rc=0 >>remote refid st t when poll reach delay offset jitter
やっぱり、ansible便利だな~==============================================================================+cbr-jp-1.dn42.e 133.243.238.163 2 u 22 64 377 8.398 11.943 7.764*date.no-such-ag 103.1.106.69 2 u 25 64 377 7.369 11.609 5.619-b.hnd.pobot.net 71.80.83.115 2 u 35 64 377 9.420 6.175 4.915+extendwings.com 133.243.238.164 2 u 101 64 376 11.825 12.024 40.148cent7-2 | SUCCESS | rc=0 >>remote refid st t when poll reach delay offset jitter==============================================================================+ntp1.jst.mfeed. 133.243.236.17 2 u 125 128 377 7.749 0.235 0.327*ntp2.jst.mfeed. 133.243.236.17 2 u 32 128 377 7.388 -0.415 0.900[root@centos7 ansible]#
ちなみに、インベントリ"-i"で指定している production ファイルはこんな感じに対象サーバを登録しています。
[common-servers]cent7-2 ansible_host=192.168.1.82cent7-1 ansible_host=192.168.1.80[all:vars]ansible_ssh_port=22ansible_ssh_user=user02ansible_ssh_pass=************ansible_become=yesansible_become_pass=************