thaopv
thaopv

Reputation: 29

How can I execute Ansible module of python on windows?

I installed Ansible on windows server 2012 via python 3.7 (follow by instructions of this post: https://stackoverflow.com/a/52614973/7098543).

But, I got error: No module named ansible.main. How can I solve it?

I know that Ansible does not support to install control machine on Windows. But, I have to use Windows server 2012.

After I installed Ansible (version: 2.7.10) via python 3.7, I try to run:

python -m ansible --version

I got error: No module named ansible.main; 'ansible' is a package and cannot be directly executed.

Any workaround? Please help.

Upvotes: 2

Views: 987

Answers (1)

thaopv
thaopv

Reputation: 29

Actually, I have no idea or workaround to solve this issues. But, I found other solution to install Ansible with Cygwin.

    1. Open up a Cygwin Terminal
    2. alias cyg-get="/path/to/cygwin/setup/package/setup-x86_64.exe -q -P"
    3. cyg-get cygwin32-gcc-g++,gcc-core,gcc-g++,git,libffi-devel,nano,openssl,openssl-devel,python-crypto,python3,python3-devel,python3-openssl,python3-pip,python3-setuptools,python3-devel,tree,wget,zip,make,curl,git python-jinja2,python-six,python-yaml, cryptography
    4. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    5. python3 get-pip.py
    6. pip --version
    7. git clone --depth 1 git://github.com/ansible/ansible
    8. cd ansible
    9. python3 setup.py install

Hope this post help someone! Refrence link:

  1. Cygwin - How to install ansible?
  2. How to overcome - pip install ansible on windows failing with filename or extension too long on windows

Upvotes: 1

Related Questions