zoukankan      html  css  js  c++  java
  • ansible 小试

    安装:

    pip install ansible
    

    添加配置文件:

    配置文件查找顺序
    * ANSIBLE_CONFIG (环境变量)
    * ansible.cfg (当前目录下)
    * .ansible.cfg (用户家目录下)
    * /etc/ansible/ansible.cfg
    * -i filename (手动传入配置文件)
    
    # ansible config file
    [local]
    127.0.0.1
    
    

    运行:

    #查看远程主机是否存活
    ansible -i hosts all -m ping
    
    # 手动输入ssh账号密码 需要安装 sshpass
    sudo aptitude install sshpass
    ansible -i hosts all -a 'uptime' -u username --ask-pass password
    
    # 添加受信host方式直接运行
    ssh-keygen -t rsa
    cd ~/.ssh
    cp id_rsa.pub authorized_keys
    cd ..
    ansible -i hosts all -a 'uptime'
    
    -----------------------------------------------------
    说明:
      a).代码仅供学习交流
      b).本文根据自身经验及网络总结所作,如有错误,谢谢指教
      c).转载请注明出处。
    -----------------------------------------------------
  • 相关阅读:
    Dockerfile
    走进Docker
    liunx 设置定时任务
    《程序员自我修养》读书笔记
    Ubuntu换源
    liunx安装python2.7.12
    预习非数值数据的编码方式
    预习原码补码
    第三章预习
    预习非数值数据的编码方式
  • 原文地址:https://www.cnblogs.com/xqbumu/p/5394746.html
Copyright © 2011-2022 走看看