как установить ansible на windows

How to install Ansible on Windows?

как установить ansible на windows

Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.

Love Ansible, but wondering how to get it running on Windows?

Ansible is one of the most popular configuration administration and infrastructure automation tools. It helps to automate infrastructure configuration/provisioning, software deployments, and general infrastructure management.

Ansible was initially available on Linux. However, with Microsoft’s new viewpoint on open source, their community improvements, and their acceptance of a more agile, DevOps-minded software development method, Windows support is gradually catching up with the pace.

Although Windows support requires a slight bit more configuration, it’s not very bad once the initial setup is done. There are two possible ways to get it installed.

Using Cygwin

It is a POSIX-compatible environment to run on Windows. This means – you can run many things on Windows, which you usually do on UNIX-based OS.

If its the first time you heard about Cygwin then I would refer to their official website to get more understanding.

The default Cygwin installation doesn’t cover Ansible. Hence, you got to select them during installation, as explained below manually.

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

Congratulation! You have installed Cygwin with Ansible on Windows. Let’s verify it.

как установить ansible на windows

And, as you can see, it has successfully installed.

Go ahead and play around with it. If you are interested in learning Ansible, then check out this Udemy course.

Using Ubuntu on Windows 10

Thanks to Microsoft. Now it is possible to install Ubuntu on Windows 10.

Let’s get it started.

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

как установить ansible на windows

After the installation, let’s test whether by creating and running a demo playbook.

как установить ansible на windows

And, finally, run the playbook.

Conclusion

I hope this helps you to install Ansible on Windows. Check out this blog post to learn about the playbook to automate the tasks.

Источник

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

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.

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 from source from the ansible/ansible GitHub repository to access the development ( devel ) version to develop or test the latest features.

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 

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 

Once pip is installed, you can install Ansible 1:

If you wish to install Ansible globally, run the following commands:

Installing Ansible in a virtual environment 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

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.

Источник

Ansible под Windows с костылями, подпорками и интеграцией с Vagrant

Если обстоятельства таковы, что вам нужно использовать Ansible под Windows (что, в принципе, не так уж и напряжно, хоть и нигде толком не описано) и, чего доброго, интегрировать это дело с Vagrant под Windows — прошу под кат.

Начну, пожалуй, с предупреждения. Если вы выбираете провиженер для автоматизации развертывания проектной инфраструктуры и в качестве мастера хотите использовать свою рабочую станцию на Windows и только её — лучше не используйте Ansible. Вот что написано в его документации по установке: “Currently Ansible can be run from any machine with Python 2.6 installed (Windows isn’t supported for the control machine)”. Всё описанное ниже — система костылей и подпорок на крайний случай. И если всё же крайний случай наступил или вы не ищете легких путей, поехали.

Установка

В общем, тут ничего удивительного нету. Если сабж не поддерживает Windows из коробки, а нормально работает только под *nix — можно попытаться устроить в винде небольшой *nix при помощи Cygwin. Более того, можно нагуглить уже готовые инстукции о том, как поднять Ansible под Cygwin, но мне удалось сделать это, как мне кажется, проще и чище, чем, например, автору этой инструкции.

Забегая вперед, скажу, что для меня это был первый опыт работы с Cygwin’ом (сам я давно на Linux’е, эта инстукция в целом — попытка дать возможность команде работать с опрометчиво выбранным без скидки на Windows инстументом) и установка пакетов там оказалась штукой не совсем для меня очевидной. Пришлось загуглить: оказывается, чтобы установить пакет, нужно, найдя его в списке, нажать вот на эту иконку как установить ansible на windows— тогда изменится его статус; чтобы добавить или удалить пакеты, нужно запустить инсталлятор и идти тем же путем, что и при начальной установке.

Еще одна заметка. Если вы из Беларуси, используйте зеркало Белтелекома (http://ftp.mgts.by/pub/cygwin) — по опыту это единственный способ установить всё быстро. Для этого введите указанный адрес в поле под списком зеркал и нажмите Add, после чего выберите его в списке.

Чем объясняется этот набор? Нормально поставить Ansible можно только через питоновский пакетный менеджер pip, а он не работает без libuuid-devel, по меньшей мере на версии Cygwin для x86_64. binutils позволяет pip’у использовать Cygwin’овскую реализацию libuuid. Остальное, думаю, понятно — для самого Ansible.

Почему именно 1.5.3, спросите? Это последняя на данный момент версия, работающая под Windows и не имещая некоторых назойливых багов.

В общем и целом, это всё. После этого из Cygwin можно использовать ansible-playbook как и в *nix.

Ansible с Vagrant: свяо атмосфреа

В теории, Vagrant интегрируется с Ansible красиво и прозрачно. Но только не под Windows. При первой же попытке запустить vagrant provision с Ansible в качестве провиженера под Windows вы получите какую-нибудь замысловатую ошибку. Причина достаточно проста: Ansible будет работать только под Cygwin. Найти простой способ заставить vagrant вызывать его нужным способом мне не удалось. Казалось бы, велика ли беда: соорудить батник по имени ansible-playbook.bat, который будет запускать уже реальный ansible-playbook в Cygwin, положить его в %Path% так, чтобы Vagrant попадал на него — всего-то! Но не тут-то было.

Vagrant под Windows — это такая же системы костылей и подпорок со своим bash’ем и коллекцией *nix утилит. Соответственно, просто написать bash не получится: Vagrant разбавит %Path% путем к своей директории с *nix-утилитами (кстати, тем же грешен и GitBash), а нам нужен именно Cygwin и именно его утилиты.

В итоге всё вышеописанное уложилось буквально в несколько достаточно кратких инстукций в шагах по развертыванию проекта и было более-менее успешно обкатано на вновь пришедших на проект разработчиках разного уровня.

Источник

How to Install and Configure Ansible on Windows

Home » SysAdmin » How to Install and Configure Ansible on Windows

Ansible is an Infrastructure as Code tool used for managing and monitoring remote servers.

Ansible requires a Linux-based system to run. This can be a problem if you want to use its features on a Windows 10 system. However, there are ways to install Ansible on Windows.

This tutorial will cover different ways you can install Ansible on Windows 10.

как установить ansible на windows

Install Ansible on Windows

There are three ways to run Ansible on Windows 10:

We shall explain all three methods of installing Ansible on Windows.

Method 1: Using Cygwin

Cygwin is a POSIX-compatible environment that lets you run tools and code designed for Unix-like operating systems on Microsoft Windows.

Even though the default Cygwin installation contains hundreds of tools for Unix-based systems, Ansible is not one of them. You must manually add Ansible during the installation process.

To install Ansible on Windows using Cygwin, follow these steps:

1. Download the Cygwin installation file. This file is compatible with both the 32-bit and 64-bit versions of Windows 10. It automatically installs the right version for your system.

2. Run the Cygwin installation file. On the starting screen of the installation wizard, click Next to continue.

как установить ansible на windows

3. Select Install from Internet as the download source and click Next.

как установить ansible на windows

4. In the Root Directory field, specify where you want the application installed, then click Next.

как установить ansible на windows

5. In the Local Package Directory field, select where you want to install your Cygwin packages, then click Next.

как установить ansible на windows

6. Choose the appropriate Internet connection option.

If you aren’t using a proxy, select Direct Connection.

как установить ansible на windows

If you are using a proxy, select Use System Proxy Settings or enter the proxy settings manually with the Use HTTP/FTP Proxy.

как установить ansible на windows

Click Next to continue.

7. Choose one of the available mirrors to download the installation files, then click Next.

как установить ansible на windows

8. On the Select Packages screen, change the View option to Full and type ‘ansible’ in the search bar.

Select both Ansible and Ansible Doc by checking the boxes under Src? and click Next to continue.

как установить ansible на windows

9. This screen lets you review the installation settings. To confirm and begin the install process, click on Next.

как установить ansible на windows

10. The install wizard will download and install all the selected packages, including Ansible.

11. Once the installation is complete, select whether you want to add a Cygwin desktop and Start Menu icon, then click on Finish to close the wizard.

как установить ansible на windows

Method 2: Using a Linux Virtual Machine

Another way to install Ansible on Windows 10 is to use a virtualization tool and a Linux virtual box.

In this example, we will use Oracle VM VirtualBox to set up an Ubuntu virtual machine and install Ansible.

Step 1: Setting Up VirtualBox

2. Run the VirtualBox installation file.

On the starting screen of the installation wizard, click Next to continue.

как установить ansible на windows

3. Use this screen to select which features of VirtualBox you want to install. This is also where you can set the install location. Click Next to continue.

как установить ansible на windows

4. Choose whether you want to add Desktop, Start Menu, and Quick Launch Bar shortcuts and add file associations. Click Next to continue.

как установить ansible на windows

5. A new screen will warn you that the install wizard needs to reset your network connection. Click Yes to continue.

как установить ansible на windows

6. On the next screen, click Install to begin the installation process.

как установить ansible на windows

7. The install wizard might prompt you to add a VirtualBox USB device. Click Yes to continue.

8. Click Finish to complete the installation.

как установить ansible на windows

Step 2: Creating an Ubuntu 20.04 Virtual Box

2. On the VirtualBox starting screen, click New.

как установить ansible на windows

3. Type in the name of your virtual machine. If the name contains the word ‘Ubuntu’, the operating system dropdown menu will automatically update to Ubuntu (64-bit). If not, you can select the operating system manually using the dropdown menu. Click Next to continue.

как установить ansible на windows

4. Set the amount of RAM you want the virtual machine to have.

Click Next to continue.

как установить ansible на windows

Note: By default, Oracle VM VirtualBox assigns 1024MB of RAM to every virtual box. Make sure you assign enough RAM to your new virtual box, or it will not work properly.

5. Select a hard disk option for your virtual machine.

Choose Create a virtual hard disk now if you are creating a brand new VM. Click Create to continue.

как установить ansible на windows

6. Choose the type of virtual hard disk you want to create. Click Next.

как установить ansible на windows

7. Choose if the new virtual hard disk has a fixed amount of space or if you want it to allocate space dynamically. Select Fixed size and click Next.

как установить ansible на windows

8. Select the location of the virtual hard disk on your computer and enter the size limit.

For this example, we will set the size limit to 10GB. Click Create to continue.

как установить ansible на windows

Note: Just like with RAM, you need to make sure you assign enough hard disk space to your virtual machine. VirtualBox sets the fixed-size hard disk at 10GB by default.

9. Select the new virtual machine you just created on the left-hand side of the VirtualBox starting screen. Click Start to run the new VM.

как установить ansible на windows

10. VirtualBox will prompt you to select a start-up disk. Click on the button next to the drop-down menu to open the optical Disk Selector.

как установить ansible на windows

11. In the Optical Disk Selector, click Add.

как установить ansible на windows

12. Find the Ubuntu 20.04 desktop image you downloaded in a previous step. Select the image and click Open.

как установить ansible на windows

13. In the Optical Disk Selector, highlight the image you just added and click Choose.

как установить ansible на windows

14. Click Start to begin the install process for Ubuntu 20.04.

Step 3: Installing Ansible

1. Once you are done installing Ubuntu 20.04, open the command terminal.

2. In the command terminal, enter the following command:

This command refreshes the system’s package index and allows you to Install Ansible.

как установить ansible на windows

3. To install Ansible, use the command:

как установить ansible на windows

The rest of the install process is automated.

After you install it on you virtual machine, you can configure Ansible by setting up the hosts inventory file and checking the connections.

Method 3: Enabling Ubuntu on Windows 10

The third option is to use the Windows Subsystem for Linux to start up the Ubuntu terminal without setting up a virtual machine:

1. Open the Start menu and search for Turn Windows features on or off. Click on the shortcut when it appears.

как установить ansible на windows

2. Scroll down through the list of features until you see Windows Subsystem for Linux. Click on the checkbox, and then click OK to enable the feature.

как установить ansible на windows

3. Open the Microsoft Store. Search for Ubuntu and click on Get to install the latest version.

как установить ansible на windows

4. Once the installation is complete, click on Launch to start up the Ubuntu command terminal.

5. To install Ansible, enter the following set of commands:

Note: Check out our tutorial on How to Install Ubuntu on Windows with Hyper-V. Hyper-V allows you to install a distribution of Linux on Windows 10, including Ubuntu.

If you followed the steps in this guide, you now have a copy of Ansible installed on your Windows 10 system.

Now you can use Ansible to manage and configure remote servers, and plan your CI/CD process.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *