Ansible: How to install ansible 7 (available offline (blocked internet access) situations)

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.

(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.

(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.

(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)