- How to install Ansible on Mac OS X
- Table of Contents
- How to install Ansible on Mac OS X using Homebrew
- How to install Ansible on Mac OS X using Python pip
- Confirm that pip is installed and upgrade it to the latest version
- Install Ansible
- Установка Ansible в Mac OS
- Установка с помощью Homebrew
- Нативная установка через Python:
- Нативная установка через Python — с подробностями:
- Убедитесь что Xcode у вас установлен
- Установите pip
- Установка Ansible
- Обновление Ansible
- Добавить комментарий Отменить ответ
- Install Ansible on OSX
- 4 Answers 4
- Installing Ansible
- Prerequisites
- Control node requirements
- Managed node requirements
- Selecting an Ansible artifact and version to install
- Installing the Ansible community package
- Installing ansible-core
- Installing and upgrading Ansible with pip
- Prerequisites: Installing pip
- Installing Ansible with pip
- Installing Ansible in a virtual environment with pip
- Upgrading Ansible with pip
- Upgrading from 2.9 or earlier to 2.10
- Upgrading from Ansible 3 or ansible-core 2.10
- Installing Ansible on specific operating systems
How to install Ansible on Mac OS X
Written by Percy Grunwald
— Last Updated February 22, 2019
Table of Contents
The two best methods for installing Ansible on Mac OS X are:
- Using Homebrew (best for beginners)
- Using Python pip (best for advanced users)
The official documentation states that their preferred method for installing Ansible on Mac OS X is using Python pip . I also agree that this is the best way to install Ansible and this is how I do it on my machine, however I think installing it by using Homebrew is probably the best way for beginners.
The main difference between the two methods is that using pip will give you more control over the Python version Ansible uses as well as any Python packages that Ansible depends on. This is especially useful if you’re using a version manager like asdf , which I highly recommend.
How to install Ansible on Mac OS X using Homebrew
First, ensure that you have Homebrew installed. Homebrew is a package manager for Mac OS X that allows you to install many packages useful for web/software development.
Installing Ansible on Mac OS X with Homebrew is as simple as running brew install ansible in Terminal (or your preferred terminal application):
After the installation has finished, you can confirm that Ansible has installed correctly by running ansible —version :
If ansible —version runs successfully, congratulations! You now have Ansible’s power at your fingertips and you’re ready to start managing your servers.
How to install Ansible on Mac OS X using Python pip
Confirm that pip is installed and upgrade it to the latest version
First, ensure that Python pip is installed on your system. You can check if pip is in your PATH by running which pip . If pip is found, run pip —version to confirm that everything is working as expected:
I use asdf to manage the Python versions on my system (and I suggest you do too). pip is automatically installed along with asdf Python installations.
If pip isn’t on your system and you’re using the default Python version on your system, you can usually install pip by running sudo easy_install pip .
I suggest running pip install —upgrade pip to update pip to the latest version before installing Ansible:
Install Ansible
Assuming pip is installed and working, installing Ansible is as simple as running pip install ansible :
Confirm that ansible is in your path and that it runs as expected:
If ansible —version runs successfully, congratulations! You now have Ansible’s power at your fingertips and you’re ready to start managing your servers.
Источник
Установка Ansible в Mac OS
Установка с помощью Homebrew
Если у вас уже установлен Homebrew то достаточно сделать следующее:
Если вы хотели бы использовать Python и pip для установки, прочтите далее…
Нативная установка через Python:
Ansible использует Python и к счастью Python всегда устанавливается на новых версиях Mac OS.
- Установим Xcode
- sudo easy_install pip
- sudo pip install ansible —quiet
Далее, если вы хотите обновить Ansible позже, нужно будет выполнить:
- sudo pip install ansible —upgrade
Нативная установка через Python — с подробностями:
Убедитесь что Xcode у вас установлен
Некоторые зависимости Ansible должны быть скомпилированы, соответственно вам необходимы средства разработчиков Xcode.
Вы можете проверить наличие установленных средств разработчика используя команду:
(До OSX Mavericks, вам необходимо проверять наличие пакета «com.apple.pkg.DeveloperToolsCLI»)
Если утилита не установлена, вы увидите следующее сообщение:
В этом случае вам необходимо установить Xcode отсюда.
Если утилита установлена, вы увидите следующее:
Установите pip
pip это менеджер пакетов для Python. Он по умолчанию не установлен в OSX, но вы можете использовать и другие менеджеры пакетов Python, выполните easy_install для установки:
Установка Ansible
Обновление Ansible
С выходом новых версий Ansible вы можете легко обновится до новой версии:
Добавить комментарий Отменить ответ
Для отправки комментария вам необходимо авторизоваться.
Источник
Install Ansible on OSX
I am using OSX.10.12.4 .
I downloaded ansible from github and trying to run it. Here is what I’ve got when execute ansible.
I got 2 version of python in local( 2.7.10 and 3.6.1 ). It could be a cause of this error? What should I do to fix this?
- I do want to install this with binary source, not with brew install ansible or pip install ansible
4 Answers 4
Probably you’re failing because of some dependency. Ansible provides a requirements.txt that you should use with pip install -r .
It works for me:
In alternative way, I solved with below.
- Install python3 , in order to use pip3
- sudo pip3 install pyyaml
- sudo pip3 install ansible
- sudo pip3 install ansible —upgrade
when you type pip , it will use the original system python .(Maybe 2.7.0 in my case)
For installing ansible in mac OSX, the recommended way is using pip.
First you need to install pip using command
Then install ansible with
After completion, you can check the version of ansible with
Now Ansible is installed successfully. Now to communicate with client machines, SSH authentication is required. I assume that SSH is setup.
Now ansible will look for hosts file which contains all IPs of clients. Go to /etc/ansible/ path. If the path doesn’t exist, go to /etc and create directory with name ‘ansible’ sudo mkdir ansible
cd in to that and create hosts file.
Edit your hosts file something like this.
Now try to ping all your clients
Expected output is something like this.
Now you can create and play with playbook files 🙂
Источник
Installing Ansible
Ansible is an agentless automation tool that you install on a control node. From the control node, Ansible manages machines and other devices remotely (by default, over the SSH protocol).
To install Ansible for use at the command line, simply install the Ansible package on one machine (which could easily be a laptop). You do not need to install a database or run any daemons. Ansible can manage an entire fleet of remote machines from that one control node.
Prerequisites
Before you install Ansible, review the requirements for a control node. Before you use Ansible, review the requirements for managed nodes (those end devices you want to automate). Control nodes and managed nodes have different minimum requirements.
Control node requirements
For your control node (the machine that runs Ansible), you can use any machine with Python 2 (version 2.7) or Python 3 (versions 3.5 and higher) installed. ansible-core 2.11 and Ansible 4.0.0 will make Python 3.8 a soft dependency for the control node, but will function with the aforementioned requirements. ansible-core 2.12 and Ansible 5.0.0 will require Python 3.8 or newer to function on the control node. Starting with ansible-core 2.11, the project will only be packaged for Python 3.8 and newer. This includes Red Hat, Debian, CentOS, macOS, any of the BSDs, and so on. Windows is not supported for the control node, read more about this in Matt Davis’s blog post.
Please note that some plugins that run on the control node have additional requirements. These requirements should be listed in the plugin documentation.
When choosing a control node, remember that any management system benefits from being run near the machines being managed. If you are using Ansible to manage machines in a cloud, consider using a machine inside that cloud as your control node. In most cases Ansible will perform better from a machine on the cloud than from a machine on the open Internet.
Ansible 2.11 will make Python 3.8 a soft dependency for the control node, but will function with the aforementioned requirements. Ansible 2.12 will require Python 3.8 or newer to function on the control node. Starting with Ansible 2.11, the project will only be packaged for Python 3.8 and newer.
Managed node requirements
Although you do not need a daemon on your managed nodes, you do need a way for Ansible to communicate with them. For most managed nodes, Ansible makes a connection over SSH and transfers modules using SFTP. If SSH works but SFTP is not available on some of your managed nodes, you can switch to SCP in ansible.cfg . For any machine or device that can run Python, you also need Python 2 (version 2.6 or later) or Python 3 (version 3.5 or later).
Please note that some modules have additional requirements that need to be satisfied on the ‘target’ machine (the managed node). These requirements should be listed in the module documentation.
If you have SELinux enabled on remote nodes, you will also want to install libselinux-python on them before using any copy/file/template related functions in Ansible. You can use the yum module or dnf module in Ansible to install this package on remote systems that do not have it.
By default, before the first Python module in a playbook runs on a host, Ansible attempts to discover a suitable Python interpreter on that host. You can override the discovery behavior by setting the ansible_python_interpreter inventory variable to a specific interpreter, and in other ways. See Interpreter Discovery for details.
Ansible’s raw module , and the script module , do not depend on a client side install of Python to run. Technically, you can use Ansible to install a compatible version of Python using the raw module , which then allows you to use everything else. For example, if you need to bootstrap Python 2 onto a RHEL-based system, you can install it as follows:
Selecting an Ansible artifact and version to install
Starting with version 2.10, Ansible distributes two artifacts: a community package called ansible and a minimalist language and runtime called ansible-core (called ansible-base in version 2.10). Choose the Ansible artifact and version that matches your particular needs.
Installing the Ansible community package
The ansible package includes the Ansible language and runtime plus a range of community curated Collections. It recreates and expands on the functionality that was included in Ansible 2.9.
You can choose any of the following ways to install the Ansible community package:
Install the latest release with your OS package manager (for Red Hat Enterprise Linux (TM), CentOS, Fedora, Debian, or Ubuntu).
Install with pip (the Python package manager).
Installing ansible-core
Ansible also distributes a minimalist object called ansible-core (or ansible-base in version 2.10). It contains the Ansible language, runtime, and a short list of core modules and other plugins. You can build functionality on top of ansible-core by installing collections from Galaxy, Automation Hub, or any other source.
You can choose any of the following ways to install ansible-core :
Install ansible-core (version 2.11 and greater) or ansible-base (version 2.10) with pip .
Install ansible-core from source from the ansible/ansible GitHub repository to access the development ( devel ) version to develop or test the latest features.
You should only run ansible-core from devel if you are modifying ansible-core , or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.
Ansible generally creates new releases twice a year. See Releases and maintenance for information on release timing and maintenance of older releases.
Installing and upgrading Ansible with pip
Ansible can be installed on many systems with pip , the Python package manager.
Prerequisites: Installing pip
If pip is not already available on your system, run the following commands to install it:
You may need to perform some additional configuration before you are able to run Ansible. See the Python documentation on installing to the user site for more information.
Installing Ansible with pip
If you have Ansible 2.9 or older installed or Ansible 3, see Upgrading Ansible with pip .
Once pip is installed, you can install Ansible 1:
In order to use the paramiko connection plugin or modules that require paramiko , install the required module 2:
If you wish to install Ansible globally, run the following commands:
Running pip with sudo will make global changes to the system. Since pip does not coordinate with system package managers, it could make changes to your system that leaves it in an inconsistent or non-functioning state. This is particularly true for macOS. Installing with —user is recommended unless you understand fully the implications of modifying global files on the system.
Older versions of pip default to http://pypi.python.org/simple, which no longer works. Please make sure you have the latest version of pip before installing Ansible. If you have an older version of pip installed, you can upgrade by following pip’s upgrade instructions .
Installing Ansible in a virtual environment with pip
If you have Ansible 2.9 or older installed or Ansible 3, see Upgrading Ansible with pip .
Ansible can also be installed inside a new or existing virtualenv :
Upgrading Ansible with pip
Upgrading from 2.9 or earlier to 2.10
Starting in version 2.10, Ansible is made of two packages. When you upgrade from version 2.9 and older to version 2.10 or later, you need to uninstall the old Ansible version (2.9 or earlier) before upgrading. If you do not uninstall the older version of Ansible, you will see the following message, and no change will be performed:
As explained by the message, to upgrade you must first remove the version of Ansible installed and then install it to the latest version.
Upgrading from Ansible 3 or ansible-core 2.10
ansible-base only exists for version 2.10 and in Ansible 3. In 2.11 and later, the package is called ansible-core . Before installing ansible-core or Ansible 4, you must uninstall ansible-base if you have installed Ansible 3 or ansible-base 2.10.
To upgrade to ansible-core :
To upgrade to Ansible 4:
Installing Ansible on specific operating systems
Follow these instructions to install the Ansible community package on a variety of operating systems.
Источник