In this tutorial you will lean the steps to install Ansible on Mac OSX. You will also learn the step by step process of ansible post installation. To learn How to Install Ansible on Mac OSX please follow this tuttorial post on install Ansible on OSX.

Brew Install On MAC OSX

If you already have Homebrew installed, then it is as simple as:

> brew install ansible
That’s it!If you prefer to use Python and pip for the install, then read on.

Native Python Install – Summary:

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

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

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

  • sudo pip install ansible --upgrade

Native Python Install – 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_Executable
(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

Install pip on Mac OSX

> 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 on Mac OSX

> 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 on Mac OSX

sudo pip install ansible --upgrade

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@child1.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

Also Read:

http://techhowdy.com/wp-content/uploads/2017/12/Ansible-on-Mac-OSX.pnghttp://techhowdy.com/wp-content/uploads/2017/12/Ansible-on-Mac-OSX-150x150.pngDemonHow ToIn this tutorial you will lean the steps to install Ansible on Mac OSX. You will also learn the step by step process of ansible post installation. To learn How to Install Ansible on Mac OSX please follow this tuttorial post on install Ansible on OSX. Brew Install On MAC...Latest technology news