This article uses ConEmu, MSYS2 and Python2 and Docker Toolbox installed on Windows. Please read the user name as appropriate.
Is it the easiest way to execute the ansible command from a terminal on Windows? I tried and errored aiming for this, but it didn't work. After all, I found that using Docker and Vagrant for each purpose was the easiest. The following is a summary of the results of trial and error. Finally, write down how to reuse Ansible's Role using Docker on Windows.
First of all, I would like to install Ansible as a native windows program. MSYS2 launches the shell with MSYSTEM = mingw64. The installation was done via pip. Python2 and pip used the ones published in the mingw64 repository. On the way, the library may be insufficient when building pycrypto or cryptography. In such a case, if you set CFLAGS, you can correct the include path when compiling gcc.
As a result, I managed to install it. You have generated a Windows native binary. However, when I tried it, I got ʻImportError: No module named fcntl` and it failed.
Then start the shell with MSYSTEM = msys. Python2 and pip used the ones published in the msys repository. However, when I tried it, it became ʻImportError: No module named fcntl` and it failed again.
I installed Python2 from the Windows installer and tried to install Ansible. The Windows compiler that Python2 uses to build is thankfully provided by Microsoft.
And you can install Ansible brilliantly. However, when I tried it, it became ʻImportError: No module named fcntl` and it failed again.
$ /c/Python27/Scripts/ansible --version
Traceback (most recent call last):
File "C:/Python27/Scripts/ansible", line 45, in <module>
from ansible.utils.display import Display
File "C:\python27\lib\site-packages\ansible\utils\display.py", line 21, in <module>
import fcntl
ImportError: No module named fcntl
After that, I tried using Anaconda2, but it was impossible with the same error.
I think there is provisioning as a usage scene of Ansible. Vagrant provides Ansible Provisioner as a provisioning method.
Since Ansible has not been installed on Windows, use Ansible Local. I was able to provision it with Ansible.
Ansible has an ansible-galaxy command. It is provided for the purpose of reusing Roles, so I would like to create Roles. However, on Windows, Ansible can only be used in the provisioning scene.
Finally, I will try how to reuse Role using Docker. Use Docker Machine to prepare for using docker commands.
$ docker run --rm -v "//c/Users/<username>/ansible/roles:/etc/ansible/roles" ansible/ansible-container-builder:0.3 ansible-galaxy install geerlingguy.apache
After that, you can use the ansible-galaxy command for Role reuse like the above. Docker usage seems to be the best in scenes other than provisioning.
That's all about how to use Ansible on Windows.
Please teach me in that case because there is a lack of knowledge about MSYS2 and it may be wrong. It's a development on Windows that often stumbles, but I hope it helps someone.
Recommended Posts