zoukankan      html  css  js  c++  java
  • ansible

    rpm -qa | grep python #查看软件包是否安装成功

    ss -tnlp 查看启动的端口呢

    ansible 命令格式

    -a MODULE_ARGS  模块参数

    -C, --check 检查语法

    -f FORKS 并发

    -- list -hosts 列出主机列表

    -m MODULE_NAME 模块名字

    ssh认证方式

    -密码

    -秘钥

       - ssh-keygen 生成秘钥对

       - ssh-copy-id 复制公钥到远程主机

       - 私钥加密,公钥解密

    查看ansible生成的文件

    rpm -ql ansible | more

    ping 走的ICMP协议 

    host-pattern格式

    - 单个机器

    - 多个机器

    - 全部机器 all

    - 可以写一个分组

    - 可以写多个分组

       -- 并集,逗号隔开,冒号隔开

      -- 交集,:&隔开

      -- 差集 , :!隔开

     ansible-doc 查看模块帮助信息

    ansible-doc  [-l | -F | -s] [options]  [-t <plugin type>] [plugin]

    -j 以json格式显示所有模块信息

    -l 列出所有的模块

    -s 显示模块的摘要信息

    命令相关

    command

    ansible web -a 'ls'   

    ansible web -a 'chdir=/tmp pwd'   #先切换目录,在执行相应的命令,一般情况下在编译时候使用

    ansible web -a 'creates=/tmp pwd'  #如果creates的文件存在,则不执行

    ansible web -a 'removes=/tmp pwd'  #如果removes的文件不存在,则不执行  #请出按照create和removes 的字面意思理解

     copy

    ansible web -m copy  -a 'dest=    src=    backup=yes  owner=    moder='

    ansible web -m copy -a 'content=    dest= '

    file

    ln -s  原文件地址  目标文件地址   创建软连接

    ln  源文件地址   目标文件地址 创建硬链接

    ansible web -m file -a "path=  state=directory" 创建一个目录

    ansible web  -m file -a "path=  state=touch"  创建新文件

    ansible web -m file -a "path= state=link   src=" 创建软连接

    ansible web -m  file -a ‘ptah= state=absent’ 删除文件

    命令相关模块

    command 不支持特殊字符

    shell

    script  执行管控机上的脚本

    文件相关的模块

    copy

        content

     dest

     src

     onwer

       group

       mode

       backup

    file

       path

       state  

          directory

          touch

          file

          absent

          link 

          hard

     fetch 拉去被管控机的文件或者目录

    yum 安装

    ansible web -m yum -a "name="

  • 相关阅读:
    celery异步任务
    redis过期策略与内存淘汰机制分析
    爬虫数据去重-布隆过滤器
    scrapy-redis数据去重与分布式框架
    redis哨兵机制
    C#从零单排上王者系列---元组
    玩转VSCode插件之Remote-SSH
    C#从零单排上王者系列---数据类型
    Cassandra之Docker环境实践
    centos7安装nginx并配置前端环境
  • 原文地址:https://www.cnblogs.com/Lucifer77/p/10760165.html
Copyright © 2011-2022 走看看