玩龙天子 发表于 2018-7-29 09:11:22

Ansible 基础配置(Ⅱ)

# 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"
  
    ]
  
}
  
# 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删除:\nhttpd.x86_64 0:2.4.6-67.el7.centos.6                                          \n\n作为依赖被删除:\nhttpd-devel.x86_64 0:2.4.6-67.el7.centos.6                                    \n\n完毕!\n"
  
    ]
  
}
  
# ansible chy01 -m service -a "name=httpd state=started enabled=no"
  
//启动一个服务,state=后面是启动, enabled后跟是否开机启动
  
# ps aux |grep httpd //查看已经开机启动
  
root       45880.00.3 2219364984 ?      Ss   02:28   0:00 /usr/sbin/httpd -DFOREGROUND
  
apache   45890.00.1 2219362960 ?      S    02:28   0:00 /usr/sbin/httpd -DFOREGROUND
  
apache   45900.00.1 2219362960 ?      S    02:28   0:00 /usr/sbin/httpd -DFOREGROUND
  
apache   45910.00.1 2219362960 ?      S    02:28   0:00 /usr/sbin/httpd -DFOREGROUND
  
apache   45920.00.1 2219362960 ?      S    02:28   0:00 /usr/sbin/httpd -DFOREGROUND
  
apache   45930.00.1 2219362960 ?      S    02:28   0:00 /usr/sbin/httpd -DFOREGROUND
  
root       46170.00.0 112648   960 pts/0    R+   02:30   0:00 grep --color=auto httpd
页: [1]
查看完整版本: Ansible 基础配置(Ⅱ)