zoukankan      html  css  js  c++  java
  • Install Ansible on Mac OSX

    from: https://devopsu.com/guides/ansible-mac-osx.html

    and : https://devopsu.com/guides/ansible-post-install.html

    Install Ansible on Mac OSX

    Ansible uses Python and fortunately Python is already installed on modern versions of OSX.

    Quick summary:

    • Install Xcode
    • sudo easy_install pip
    • sudo pip install ansible --quiet

    Then, if you would like to update Ansible later, just do:

    • sudo pip install ansible --upgrade

    Full explanation...

    Ensure Xcode is installed first

    Some of Ansible's dependencies need to be compiled, so you'll need the developer tools that come with Xcode.

    You can check if you already have the developer tools by running this:

    > pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

    (note: Before OSX Mavericks, the package to check for was "com.apple.pkg.DeveloperToolsCLI")

    If the tools are not installed, you will see this output:

    > pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
    No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

    In that case, download and install Xcode from here.

    If the tools are installed, you should see output similar to this:

    > pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
    package-id: com.apple.pkg.CLTools_Executables
    version: 5.1.0.0.1.1396320587
    volume: /
    location: /
    install-time: 1397415256
    groups: com.apple.FindSystemFiles.pkg-group com.apple.DevToolsBoth.pkg-group com.apple.DevToolsNonRelocatableShared.pkg-group

    Install pip

    pip is Python's package manager. It isn't installed on OSX by default, but you can use Python's other package manager easy_install to install it:

    > sudo easy_install pip
    Password:
    Searching for pip
    Reading http://pypi.python.org/simple/pip/
    Best match: pip 1.4.1
    Downloading https://pypi.python.org/packages/source/p/pip/pip-1.4.1.tar.gz#md5=6afbb46aeb48abac658d4df742bff714
    Processing pip-1.4.1.tar.gz
    Running pip-1.4.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-hVr8Pt/pip-1.4.1/egg-dist-tmp-BY70iY
    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
    Adding pip 1.4.1 to easy-install.pth file
    Installing pip script to /usr/local/bin
    Installing pip-2.7 script to /usr/local/bin
    Installed /Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg
    Processing dependencies for pip
    Finished processing dependencies for pip

    Install Ansible

    > sudo pip install ansible
    ...lots of output and warnings you can ignore...
    Successfully installed ansible paramiko jinja2 PyYAML pycrypto ecdsa markupsafe
    Cleaning up...

    Upgrade Ansible

    When a new release of Ansible comes out, you can easily upgrade to the new version like this:

    > sudo pip install ansible --upgrade

    Post-Install Setup

    Next, see the post-install steps...

    Ansible: Post-Install Setup

    Inventory hosts file

    After you've installed Ansible, then you'll want Ansible to know which servers to connect to and manage.

    Ansible's inventory hosts file is used to list and group your servers. Its default location is /etc/ansible/hosts

    If you want to have your Ansible hosts file in another location, then you can set this environment variable:

    > export ANSIBLE_HOSTS=/root/ansible_hosts

    Or you can specify the Ansible hosts location when running commands with the --inventory-file= (or -i) flag:

    > ansible all --inventory-file=/root/ansible_hosts -m ping

    For more on the inventory hosts file, see: http://docs.ansible.com/intro_inventory.html

    Set up connectivity to the servers

    For this example, I'll assume you have servers with the hostnames child1.dev and child2.dev. When doing your own install, replace those hostnames with your own.

    Your /etc/ansible/hosts file would look like this:

    child1.dev
    child2.dev

    You want to be able to connect to your servers without having to enter a password every time. If you don't already have ssh key authentication set up to your children nodes, then do the following...

    Generate the ssh key on the master node:

    root@master:~# ssh-keygen -t rsa -C "name@example.org"

    Then copy your public key to the servers with ssh-copy-id:

    root@master:~# ssh-copy-id user@child1.dev
    root@master:~# ssh-copy-id user@child2.dev

    Now you can test the connectivity:

    root@master:~# ansible all -m ping
    child1.dev | success >> {
        "changed": false, 
        "ping": "pong"
    }
    
    child2.dev | success >> {
        "changed": false, 
        "ping": "pong"
    }

    Next...

    Now you're ready to actually manage your servers with Ansible's playbooks: http://docs.ansible.com/playbooks_intro.html

  • 相关阅读:
    some ideas
    zz 牛人啊
    zz 史上最全--各银行借记卡的年费、小额管理费、转账费等!
    哪裡可以買郵票
    : 求靠谱灭蟑螂的方法
    zz 【见闻八卦】《金融时报》年度商业书单:互联网题材占一半
    IOS开发基础知识--碎片6
    IOS开发基础知识--碎片5
    IOS开发基础知识--碎片4
    IOS中关于KVC与KVO知识点
  • 原文地址:https://www.cnblogs.com/yaoliang11/p/4485392.html
Copyright © 2011-2022 走看看