This guide shows the procedures for setting up to manage Windows Server with Ansible to do on the Ansible Controller.
At this time, I installed Ansible 7 to CentOS Stream 9.
This guide is also available offline (blocked internet access) situations.
Note: About setting up on the targets (Windows Server) is the following post.
>> Ansible: Setting up on targets (Windows Server)
Preparations
Install operating system
Install CentOS Stream 9. At this time I chose Workstation in the Base Environment option.
Make dnf (yum) command add packages from ISO (if offline)
If your environment is offline (blocked internet access), refer to the following post and make dnf (yum) command add packages from mounted DVD / ISO image.
>> How to add packages from DVD / ISO by dnf (yum) on Linux
Procedures
1. Install pip
(1) Run the following command to install pip.
dnf install python3-pip
(2) Run the following command to check the installation result.
pip -V
If it shows the following, no problems
pip 21.2.3 from /usr/lib/python3.9/site-packages/pip (python3.9)
2. Install Ansible
For online
Run the following command to install Ansible.
python3 -m pip install --user ansible
If it shows the following, no problems.
Successfully installed MarkupSafe-2.1.2 ansible-7.5.0 ansible-core-2.14.5 cffe-1.15.1 cryptography-40.0.2 jinja2-3.1.2 packaging-23.1 pycparser-2.21 resolvelib-0.8.1
For offline
(1) Download the following whl files on an online (internet-accessible) environment.
Note: File name is as of the day I installed.
- pycparser
https://pypi.org/project/pycparser/2.21/#files
file: pycparser-2.21-py2.py3-none-any.whl - MarkupSafe
https://pypi.org/project/MarkupSafe/2.1.2/#files
file: MarkupSafe-2.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - cffi
https://pypi.org/project/cffi/1.15.1/#files
file: cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - resolvelib
https://pypi.org/project/resolvelib/0.8.1/#files
file: resolvelib-0.8.1-py2.py3-none-any.whl - packaging
https://pypi.org/project/packaging/23.1/#files
file: packaging-23.1-py3-none-any.whl - Jinja2
https://pypi.org/project/Jinja2/3.1.2/#files
file: Jinja2-3.1.2-py3-none-any.whl - cryptography
https://pypi.org/project/cryptography/40.0.2/#files
file: cryptography-40.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - ansible-core
https://pypi.org/project/ansible-core/2.14.5/#files
file: ansible_core-2.14.5-py3-none-any.whl - ansible
https://pypi.org/project/ansible/7.5.0/#files
file: ansible-7.5.0-py3-none-any.whl
(2) Copy the downloaded whl files to the server that Ansible is to be installed on.
(3) Run the following command to install downloaded whl files in order.
pip install whl file
If it shows the following, no problems.
Successfully installed module name
(4) Run the following command to check that ansible is installed successfully.
ansible --version
If it shows the following, no problems.
ansible [core 2.14.5]
config file = Node
...
python version = 3.9.16 (main, Dec 8 2022, 00:00:00) [GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
4. Install pywinrm
Install pywinrm so that Ansible Controller can connect to Windows Server by WinRM.
For online
Run the following command to install pywinrm.
pip install pywinrm
If it shows the following, no problems.
Successfully installed pywinrm-0.4.3
For offline
(1) Download the following whl files on an online (internet-accessible) environment.
Note: File name is as of the day I installed.
- xmltodict
https://pypi.org/project/xmltodict/0.13.0/#files
file: xmltodict-0.13.0-py2.py3-none-any.whl - pyspnego
https://pypi.org/project/pyspnego/0.9.0/#files
file: pyspnego-0.9.0-py3-none-any.whl - requests-ntlm
https://pypi.org/project/requests-ntlm/1.2.0/#files
file: requests_ntlm-1.2.0-py3-none-any.whl - pywinrm
https://pypi.org/project/pywinrm/0.4.3/#files
file: pywinrm-0.4.3-py2.py3-none-any.whl
(2) Copy the downloaded whl files to the server that Ansible is to be installed on.
(3) Run the following command to install downloaded whl files in order.
pip install whl file
If it shows the following, no problems.
Successfully installed module name
5. Install requests_credssp
Install requests_credssp if you use CredSSP when Ansible Controller connect to Windows Server.
For online
Run the following command to install requests_credssp.
pip install requests_credssp
If it shows the following, no problems.
Successfully installed requests_credssp-2.0.0
For offline
(1) Download the following whl files on an online (internet-accessible) environment.
Note: File name is as of the day I installed.
- requests_credssp
https://pypi.org/project/requests_credssp/2.0.0/#files
file: requests_credssp-2.0.0-py2.py3-none-any.whl
(2) Copy the downloaded whl files to the server that Ansible is to be installed on.
(3) Run the following command to install downloaded whl files.
pip install whl file
If it shows the following, no problems.
Successfully installed module name
6. ansible.cfg preparation
Since ansible-core 2.12, /etc/ansible/ansible.cfg no longer exists.
Run the following command to create the template of ansible.cfg if you need.
ansible-config init --disabled > ansible.cfg
On the Ansible Controller, that’s about it.
If you proceed to set up on the Windows Server targets, refer to the following post.
>> Ansible: Setting up on targets (Windows Server)