zoukankan      html  css  js  c++  java
  • ansible 自动化运维(三)

    copy模块

    下发配置文件到管控机上。

    ansible  web  -m copy   -a  'conternt=12121212'   dest='/tmp/1 ower=root mode 660'

    把内容加入1 文件汇总

    ansibke web -m   copy -a  ' src=/tmp/1     dest=tmp/2 remote src=yes ower=root mode=660'

    远程拷贝文件

    file模块

    经常使用的 创建文件 或者创建目录

     

     

     lineinfile  模块

    修改配置文件

    如修改appchi服务

     修改监听端口号

    1.修改文件的路径

    使用copy 对配置文件进行备份

    ansible web -m   copy  -a      ‘src =/etc/httpd/conf/httod.conf       dest=/etc/httpd/conf/httpd.conf_org  remote src=yes’

    使用lineinfile模块修改配置文件

    1 ansible web -m  lineinfile -a ‘path=/etc/httpd/httpd.conf  line="0000"’

    增加一行

    2.ansible web -m lineinfile -a 'path=etc/httpd/httpd.conf  regexp ="Listen 80" line="Listten 8080"'

    严格匹配 替换

    3.ansible web -m lineinfle -a ‘path=/etc/httpd/httpd.conf regexp="0000"  state=absent’

    删除指定

    启动服务

    ansible web -m service  -a ‘ name=httpd state =restarted’

     建立周期性任务

    ansbile web -m   cron -a   ‘ minute=“*/10”    job="/bin/echo hello"  name="test cron job"’

    hour  

    present   创建

    absent   删除

    parted 对硬盘进行分区

     synchronize模块

     yum的模块

    关闭服务 

    ansible   web   -m  service -a ‘name=vsftpd   state=stoped’

    卸载服务

    ansible web -m   yum -a ‘name=vsftpd   state=absent’

    安装服务

    anbsible web  -m   yum -a ‘name=vsftpd   state  present’

  • 相关阅读:
    使用node 创建一个新项目
    安装node 及相关配置
    Java面试查漏补缺
    科学计算软件——Octave安装
    Wine——在Linux上运行Windows软件
    windows和linux中搭建python集成开发环境IDE——如何设置多个python环境
    Ubuntu安装Gnome3
    ubuntu自定义分辨率
    Ubuntu添加开机自动启动程序方法
    sublime Text3及其插件的使用
  • 原文地址:https://www.cnblogs.com/yanglc/p/13969034.html
Copyright © 2011-2022 走看看