cyrus 发表于 2018-1-2 11:54:54

ansible.md

# ansible web -a 'rpm -qa httpd'  192.168.100.203 | SUCCESS | rc=0 >>
  httpd-2.2.15-55.el6.centos.2.x86_64
  192.168.100.202 | SUCCESS | rc=0 >>
  httpd-2.2.15-56.el6.centos.3.x86_64
  # ansible web -a 'chkconfig --list httpd'
  192.168.100.202 | SUCCESS | rc=0 >>
  httpd          0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭
  192.168.100.203 | SUCCESS | rc=0 >>
  httpd          0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭
  # ansible web -a '/etc/init.d/httpd status'
  192.168.100.202 | FAILED | rc=3 >>
  httpd 已停
  192.168.100.203 | FAILED | rc=3 >>
  httpd 已停
  # ansible web -m service -a 'name=httpd state=started enabled=yes'
  192.168.100.202 | SUCCESS => {
  "changed": true,
  "enabled": true,
  "name": "httpd",
  "state": "started"
  }
  192.168.100.203 | SUCCESS => {
  "changed": true,
  "enabled": true,
  "name": "httpd",
  "state": "started"
  }
  # ansible web -a '/etc/init.d/httpd status'
  192.168.100.203 | SUCCESS | rc=0 >>
  httpd (pid4901) 正在运行...
  192.168.100.202 | SUCCESS | rc=0 >>
  httpd (pid4688) 正在运行...
  # ansible web -a 'chkconfig --list httpd'
  192.168.100.202 | SUCCESS | rc=0 >>
  httpd          0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭
  192.168.100.203 | SUCCESS | rc=0 >>
  httpd          0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭
页: [1]
查看完整版本: ansible.md