How to install Ansible with brew or pip

You can install Ansible quickly in your system with Homebrew( or PIP(Package manager for Python)

Install Ansible with Homebrew

If you are using macOS, then you can use Homebrew.

First, ensure that you have Homebrew installed in your system. Homebrew is a package manager for Mac OS. So if you want to learn more details about it, visit previous post below.

Run the following commands in your terminal without $ sign.

$ brew update
$ brew install ansible

Checking Ansible version

$ ansible --version

ansible 2.9.7
  config file = None
  configured module search path = ['/Users/kenanhancer/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/kenanhancer/.pyenv/versions/3.8.2/lib/python3.8/site-packages/ansible
  executable location = /Users/kenanhancer/.pyenv/versions/3.8.2/bin/ansible
  python version = 3.8.2 (default, May  6 2020, 12:47:50) [Clang 11.0.3 (clang-1103.0.32.59)]

Install Ansible with PIP

Ensure that you have Python and PIP in your system. Check the following page about Python installation.

$ pip install ansible
$ ansible --version

Updating Ansible

$ pip install --upgrade ansible

Installing specific Ansible version

$ pip install ansible==2.2.2.0
$ pip install ansible==2.0.1.0

How to install Python with pyenv version manager

I am using different programming languages like C#, Java, Node.js etc and need to manage runtime versions in my local. So, I like to use runtime version managers.

For example, there are some runtime version managers in Node.js community like nvm or n.

Let's say I work for one Node.js project in dev machine with Node v8.0.0 but other project needs Node v6.0.0

In order to handle, different versions in same machine, we may use runtime version managers.

I just want to find a way to switch between different Python runtime version so that found pyenv runtime version manager.

Pyenv is a simple, powerful and cross-platform tool for managing multiple versions of Python on a single machine. It is very useful when you need to switch between different Python versions for different projects, or when different applications on your system require different Python versions.

So, we can install, uninstall, list or switch between different versions.

Pyenv installation

Click pyenv link for more detailed installation.

Installing pyenv with Homebrew

First, ensure that you have Homebrew installed in your system. Homebrew is a package manager for Mac OS. So if you want to learn more details about it, visit my post.

Run the following commands in your terminal. But, just copy commands without $ sign.

$ brew update
$ brew install pyenv

Setting PATH

Checking shell

output of echo $SHELL can be bash, zsh or fish

$ echo $SHELL

/usr/local/bin/bash

# OR

/bin/zsh

Run the following command for bash, zsh, etc configuration.

$ echo 'eval "$(pyenv init -)"' >> ~/.zshrc

and restart your terminal manually or run the following command to restart automatically.

$ exec "$SHELL"

Upgrading pyenv

$ brew upgrade pyenv

Uninstall pyenv

$ rm -rf $(pyenv root)
$ brew uninstall pyenv

Pyenv commands

List all Python versions installed in system

$ pyenv versions

  system
  3.7.3
* 3.8.2 (set by /Users/kenanhancer/.pyenv/version)

Show current active Python version in system

$ pyenv version

3.8.2 (set by /Users/kenanhancer/.pyenv/version)
Continue reading

Homebrew package manager for Mac OS and Linux

Homebrew is a package manager for Mac OS and Linux. You can find more details in http://brew.sh . You can install and uninstall software that you need easily from Command Line Interface(CLI).

There are more than 8500 packages and casks(GUI installation packages) in Homebrew.

Homebrew Cask is the installation and management of GUI macOS applications such as Atom and Google Chrome.

I also posted Chocolatey Package Manager for Windows. Reach out from the following link.

Continue reading