• Ansible安装配置及使用


    Ansible工具的安装与配置

    Ansible基于SSH,不需要在远程端安装任何软件,只需要在管理端安装ansible及其组件即可。

    Ansible使用前提是已配置ssh密钥免登陆。

    一、安装组件:

    yum install python-devel

    pip install setuptools pip install pycrypto pip install PyYAML pip install Jinja2 pip install paramiko pip install simplejson

    安装setuptools如果遇到这个错误:

    Traceback (most recent call last):
      File "/usr/bin/pip", line 5, in <module>
        from pkg_resources import load_entry_point
      File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
        import packaging.requirements
      File "/usr/lib/python2.7/site-packages/packaging/requirements.py", line 59, in <module>
        MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
    TypeError: __call__() takes exactly 2 arguments (1 given)

    解决:

    vim /usr/lib/python2.7/site-packages/packaging/requirements.py

    修改:

    #MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
    MARKER_EXPR = originalTextFor(MARKER_EXPR)("marker")

    下载ansible源码:http://releases.ansible.com/ansible/

    安装:

    tar zxvf ansible-2.2.0.0
    
    cd ansible-2.2.0.0
    
    python setup.py install

    安装完毕后,设置配置文件:

    mkdir /etc/ansible
    
    cp ansible
    -2.2.0.0/examples/ansible.cfg /etc/ansible/ cp ansible-2.2.0.0/examples/hosts /etc/ansible/

    在hosts文件中定义远程操作的主机

    ansible默认远程连接端口号为22,用户名为root,可以在hosts文件中自定义:

     [servers]
     192.168.0.2 ansible_ssh_port=1234 ansible_ssh_user=ahaii

    Ansible中playbooks的使用:

    参考文档:

    1、http://www.jianshu.com/p/41c4ed3ce779

    2、http://www.mamicode.com/info-detail-951675.html

  • 相关阅读:
    Redis——发布/订阅
    Redis——任务队列
    GOF设计模式——Builder模式
    GOF设计模式——Prototype模式
    GOF设计模式——Singleton模式
    shell 脚本中的数学计算表达
    shell $'somestring'
    shell if-elif-elif-fi
    vim 使用
    疑问:为什么要使用href=”javascript:void(0);”?
  • 原文地址:https://www.cnblogs.com/ahaii/p/6225380.html
Copyright © 2020-2023  润新知