Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to install Ansible to Windows

Requirements

  • Cygwin
  • gcc-core
  • openssh
  • python
  • python-setuptools

Install pip and Ansible

easy_install pip
pip install ansible

Troubleshooting

ssh error

If you encounter ssh error, put ansible.cfg to your script root.

ansible.cfg

[defaults]
inventory = ./hosts

[ssh_connection]
ssh_args = -o ControllMaster=no
@alberttwong

This comment has been minimized.

Copy link

alberttwong commented Jan 25, 2019

No python in cgywin. I'm going to assume python2 or python3

@alberttwong

This comment has been minimized.

Copy link

alberttwong commented Jan 25, 2019

Also your instructions still didn't work. It says easy_install not found. That is because if you install more than one python, it'll append version number to the end like easy_install-3.6

$ easy_install pip
-bash: easy_install: command not found
@alberttwong

This comment has been minimized.

Copy link

alberttwong commented Jan 25, 2019

$ easy_install-3.6 pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Downloading https://files.pythonhosted.org/packages/c8/89/ad7f27938e59db1f0f55ce214087460f65048626e2226531ba6cb6da15f0/pip-19.0.1.tar.gz#sha256=e81ddd35e361b630e94abeda4a1eddd36d47a90e71eb00f38f46b57f787cd1a5
Best match: pip 19.0.1
Processing pip-19.0.1.tar.gz
Writing /tmp/easy_install-lu2djt_q/pip-19.0.1/setup.cfg
Running pip-19.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-lu2djt_q/pip-19.0.1/egg-dist-tmp-f4m3bqyi
warning: no files found matching 'docs/docutils.conf'
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.appveyor.yml'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching 'tox.ini'
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching '*.bat' under directory 'docs'
warning: no previously-included files found matching 'src/pip/_vendor/six'
warning: no previously-included files found matching 'src/pip/_vendor/six/moves'
warning: no previously-included files matching '*.pyi' found under directory 'src/pip/_vendor'
no previously-included directories found matching '.github'
no previously-included directories found matching '.azure-pipelines'
no previously-included directories found matching 'docs/build'
no previously-included directories found matching 'news'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
no previously-included directories found matching 'tools'
creating /usr/lib/python3.6/site-packages/pip-19.0.1-py3.6.egg
Extracting pip-19.0.1-py3.6.egg to /usr/lib/python3.6/site-packages
Adding pip 19.0.1 to easy-install.pth file
Installing pip script to /usr/bin
Installing pip3 script to /usr/bin
Installing pip3.6 script to /usr/bin

Installed /usr/lib/python3.6/site-packages/pip-19.0.1-py3.6.egg
Processing dependencies for pip
Finished processing dependencies for pip

Albert@DESKTOP-A5CB2UM ~
$ pip install ansible
Collecting ansible
  Using cached https://files.pythonhosted.org/packages/db/3e/04d67f7798432542dcf0258b59634f4f60f1f9ba9505cc71d69af88673d6/ansible-2.7.6.tar.gz
Collecting jinja2 (from ansible)
  Using cached https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl
Collecting PyYAML (from ansible)
  Using cached https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz
Collecting paramiko (from ansible)
  Using cached https://files.pythonhosted.org/packages/cf/ae/94e70d49044ccc234bfdba20114fa947d7ba6eb68a2e452d89b920e62227/paramiko-2.4.2-py2.py3-none-any.whl
Collecting cryptography (from ansible)
  Using cached https://files.pythonhosted.org/packages/69/ed/5e97b7f54237a9e4e6291b6e52173372b7fa45ca730d36ea90b790c0059a/cryptography-2.5.tar.gz
  Installing build dependencies ... error
  Complete output from command /usr/bin/python3 /usr/lib/python3.6/site-packages/pip-19.0.1-py3.6.egg/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6vowwppx/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=18.5 wheel "cffi>=1.8,!=1.11.3; python_implementation != 'PyPy'":
  Collecting setuptools>=18.5
    Using cached https://files.pythonhosted.org/packages/37/06/754589caf971b0d2d48f151c2586f62902d93dc908e2fd9b9b9f6aa3c9dd/setuptools-40.6.3-py2.py3-none-any.whl
  Collecting wheel
    Using cached https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl
  Collecting cffi!=1.11.3,>=1.8
    Using cached https://files.pythonhosted.org/packages/e7/a7/4cd50e57cc6f436f1cc3a7e8fa700ff9b8b4d471620629074913e3735fb2/cffi-1.11.5.tar.gz
  Collecting pycparser (from cffi!=1.11.3,>=1.8)
    Using cached https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz
  Installing collected packages: setuptools, wheel, pycparser, cffi
    Running setup.py install for pycparser: started
      Running setup.py install for pycparser: finished with status 'done'
    Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-luj0s1yi/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-q44clrvv/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-6vowwppx/overlay --compile:
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      running install
      running build
      running build_py
      creating build
      creating build/lib.cygwin-2.11.2-x86_64-3.6
      creating build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/api.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/backend_ctypes.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/cffi_opcode.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/commontypes.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/cparser.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/error.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/ffiplatform.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/lock.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/model.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/recompiler.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/setuptools_ext.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/vengine_cpy.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/vengine_gen.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/verifier.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/__init__.py -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/_cffi_include.h -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/parse_c_type.h -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/_embedding.h -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      copying cffi/_cffi_errors.h -> build/lib.cygwin-2.11.2-x86_64-3.6/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.cygwin-2.11.2-x86_64-3.6
      creating build/temp.cygwin-2.11.2-x86_64-3.6/c
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python3/python3-3.6.4-1.x86_64/build=/usr/src/debug/python3-3.6.4-1 -fdebug-prefix-map=/usr/src/ports/python3/python3-3.6.4-1.x86_64/src/Python-3.6.4=/usr/src/debug/python3-3.6.4-1 -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python3/python3-3.6.4-1.x86_64/build=/usr/src/debug/python3-3.6.4-1 -fdebug-prefix-map=/usr/src/ports/python3/python3-3.6.4-1.x86_64/src/Python-3.6.4=/usr/src/debug/python3-3.6.4-1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.6m -c c/_cffi_backend.c -o build/temp.cygwin-2.11.2-x86_64-3.6/c/_cffi_backend.o
      c/_cffi_backend.c:2:10: fatal error: Python.h: No such file or directory
       #include <Python.h>
                ^~~~~~~~~~
      compilation terminated.
      error: command 'gcc' failed with exit status 1

      ----------------------------------------
  Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-luj0s1yi/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-q44clrvv/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-6vowwppx/overlay --compile" failed with error code 1 in /tmp/pip-install-luj0s1yi/cffi/

  ----------------------------------------
Command "/usr/bin/python3 /usr/lib/python3.6/site-packages/pip-19.0.1-py3.6.egg/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6vowwppx/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=18.5 wheel "cffi>=1.8,!=1.11.3; python_implementation != 'PyPy'"" failed with error code 1 in None


@tailDASHeF

This comment has been minimized.

Copy link

tailDASHeF commented Apr 6, 2019

You need to install python3-devel first. apt-cyg install python3-devel

To fix this

gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python3/python3-3.6.4-1.x86_64/build=/usr/src/debug/python3-3.6.4-1 -fdebug-prefix-map=/usr/src/ports/python3/python3-3.6.4-1.x86_64/src/Python-3.6.4=/usr/src/debug/python3-3.6.4-1 -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python3/python3-3.6.4-1.x86_64/build=/usr/src/debug/python3-3.6.4-1 -fdebug-prefix-map=/usr/src/ports/python3/python3-3.6.4-1.x86_64/src/Python-3.6.4=/usr/src/debug/python3-3.6.4-1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.6m -c c/_cffi_backend.c -o build/temp.cygwin-2.11.2-x86_64-3.6/c/_cffi_backend.o
c/_cffi_backend.c:2:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.