|
[root@chy ~]# ansible chy01 -m yum -a "name=httpd"//安装一个包
chy01 | SUCCESS => {
"changed": false,
"failed": false,
"msg": "",
"rc": 0,
"results": [
"httpd-2.4.6-67.el7.centos.6.x86_64 providing httpd is already installed"
]
}
[root@chy ~]# ansible chy01 -m yum -a "name=httpd state=removed" //卸载一个包直接后面增加state=removed
chy01 | SUCCESS => {
"changed": true,
"failed": false,
"msg": "",
"rc": 0,
"results": [
"已加载插件:fastestmirror\n正在解决依赖关系\n--> 正在检查事务\n---> 软件包 httpd.x86_64.0.2.4.6-67.el7.centos.6 将被 删除\n--> 正在处理依赖关系 httpd = 2.4.6-67.el7.centos.6,它被软件包 httpd-devel-2.4.6-67.el7.centos.6.x86_64 需要\n--> 正在检查事务\n---> 软件包 httpd-devel.x86_64.0.2.4.6-67.el7.centos.6 将被 删除\n--> 解决依赖关系完成\n\n依赖关系解决\n\n================================================================================\n Package 架构 版本 源 大小\n================================================================================\n正在删除:\n httpd x86_64 2.4.6-67.el7.centos.6 @updates 9.4 M\n为依赖而移除:\n httpd-devel x86_64 2.4.6-67.el7.centos.6 @updates 749 k\n\n事务概要\n================================================================================\n移除 1 软件包 (+1 依赖软件包)\n\n安装大小:10 M\nDownloading packages:\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n 正在删除 : httpd-devel-2.4.6-67.el7.centos.6.x86_64 1/2 \n 正在删除 : httpd-2.4.6-67.el7.centos.6.x86_64 2/2 \n 验证中 : httpd-2.4.6-67.el7.centos.6.x86_64 1/2 \n 验证中 : httpd-devel-2.4.6-67.el7.centos.6.x86_64 2/2 \n\n删除:\n httpd.x86_64 0:2.4.6-67.el7.centos.6 \n\n作为依赖被删除:\n httpd-devel.x86_64 0:2.4.6-67.el7.centos.6 \n\n完毕!\n"
]
}
[root@chy ~]# ansible chy01 -m service -a "name=httpd state=started enabled=no"
//启动一个服务,state=后面是启动, enabled后跟是否开机启动
[root@chy01 ~]# ps aux |grep httpd //查看已经开机启动
root 4588 0.0 0.3 221936 4984 ? Ss 02:28 0:00 /usr/sbin/httpd -DFOREGROUND
apache 4589 0.0 0.1 221936 2960 ? S 02:28 0:00 /usr/sbin/httpd -DFOREGROUND
apache 4590 0.0 0.1 221936 2960 ? S 02:28 0:00 /usr/sbin/httpd -DFOREGROUND
apache 4591 0.0 0.1 221936 2960 ? S 02:28 0:00 /usr/sbin/httpd -DFOREGROUND
apache 4592 0.0 0.1 221936 2960 ? S 02:28 0:00 /usr/sbin/httpd -DFOREGROUND
apache 4593 0.0 0.1 221936 2960 ? S 02:28 0:00 /usr/sbin/httpd -DFOREGROUND
root 4617 0.0 0.0 112648 960 pts/0 R+ 02:30 0:00 grep --color=auto httpd |
|
|