# Rocky9 & Ansible + community collections

**URL:** <https://forums.rockylinux.org/t/rocky9-ansible-community-collections/10779>\
**Category:** Rocky Linux Help & Support\
**Created:** [July 23, 2023, 1:21pm UTC](https://forums.rockylinux.org/t/rocky9-ansible-community-collections/10779 "2023-07-23T13:21:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikle](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Mikle](https://forums.rockylinux.org/u/Mikle)\
**Post date:** [July 23, 2023, 1:21pm UTC](https://forums.rockylinux.org/t/rocky9-ansible-community-collections/10779/1 "2023-07-23T13:21:24Z")

</div>

**Itroductory data:**

1. **management machine** Rocky 9.2 with installed Ansible and python

> **Ansible & python version**
>
> ```auto
> [svc_ansible@srv-ansible01 playbooks]$ ansible --version
> ansible [core 2.14.2]
> config file = /etc/ansible/ansible.cfg
> configured module search path = ['/home/svc_ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
> ansible python module location = /usr/lib/python3.11/site-packages/ansible
> ansible collection location = /home/svc_ansible/.ansible/collections:/usr/share/ansible/collections
> executable location = /usr/bin/ansible
> python version = 3.11.2 (main, May 24 2023, 00:00:00) [GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] (/usr/bin/python3.11)
> jinja version = 3.1.2
> libyaml = True
> 
> ```

1. **managed stations** with Rocky 9.2
2. **managed mikrotiks** with RouterOS

Typical operations between _management machine_ and _managed stations_ - **work fine**.

> **example of typical operation**
>
> ```auto
> [svc_ansible@srv-ansible01 playbooks]$ ansible linux_servers -m shell -a "cat /etc/rocky-release"
> vh-rock01.abc.lab CHANGED | rc=0 >>
> Rocky Linux release 9.2 (Blue Onyx)
> srv-zabbix01.abc.lab | CHANGED | rc=0 >>
> Rocky Linux release 9.2 (Blue Onyx)
> srv-dbs02.abc.lab | CHANGED | rc=0 >>
> Rocky Linux release 9.2 (Blue Onyx)
> srv-app01.abc.lab | CHANGED | rc=0 >>
> Rocky Linux release 9.2 (Blue Onyx)
> srv-fs01.abc.lab | CHANGED | rc=0 >>
> Rocky Linux release 9.2 (Blue Onyx)
> 
> ```

**Problem:** Typical operations between _management machine_ and _managed mikrotiks_ - give a error:

> **error**
>
> ```auto
> [svc_ansible@srv-ansible01 playbooks]$ ansible-playbook test.yml
> PLAY [Show users] *************************************************************************
> 
> TASK [get users] **************************************************************************
> [WARNING]: ansible-pylibssh not installed, falling back to paramiko
> fatal: [r02.abc.lab]: FAILED! => {"changed": false, "msg": "paramiko is not installed: No module named 'paramiko'"}
> 
> PLAY RECAP ********************************************************************************
> r02.abc.lab : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
> 
> ```

Config files:

> **/etc/ansible/hosts**
>
> ```auto
> # This is the ansible 'hosts' file.
> 
> [linux_servers:children]
> rocky_linux
> 
> [routers]
> r02.abc.lab
> 
> [routers:vars]
> ansible_network_os=community.routeros.routeros
> ansible_user=svc_anslibe
> ansible_connection=ansible.netcommon.network_cli
> 
> [rocky_linux]
> vh-rock01.abc.lab
> srv-zabbix01.abc.lab
> srv-dbs02.abc.lab
> srv-app01.abc.lab
> srv-fs01.abc.lab
> 
> ```

> **/etc/ansible/ansible.cfg**
>
> [in connection with the character limit in the topic posted on pastebin](https://pastebin.com/Lp3jFnXz)

> **test.yml**
>
> ```auto
> - name: "Show users"
> hosts: routers
> gather_facts: no
> remote_user: svc_anslibe
> 
> tasks:
> - name: get users
> community.routeros.command:
> commands:
> - /user print
> register: output
> 
> - name: Print output
> ansible.builtin.debug:
> var: output.stdout_lines
> 
> ```

I have tried re-installing the packages:

> **ansible-pylibssh**
>
> ```auto
> [svc_ansible@srv-ansible01 playbooks]$ pip install ansible-pylibssh
> Defaulting to user installation because normal site-packages is not writeable
> Requirement already satisfied: ansible-pylibssh in /home/svc_ansible/.local/lib/python3.9/site-packages (1.1.0)
> WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
> distutils: /home/svc_ansible/.local/lib/python3.9/site-packages
> sysconfig: /home/svc_ansible/.local/lib64/python3.9/site-packages
> WARNING: Additional context:
> user = True
> home = None
> root = None
> prefix = None
> 
> ```

> **paramiko**
>
> ```auto
> [svc_ansible@srv-ansible01 playbooks]$ pip install paramiko
> Defaulting to user installation because normal site-packages is not writeable
> Requirement already satisfied: paramiko in /usr/local/lib/python3.9/site-packages (3.2.0)
> Requirement already satisfied: pynacl>=1.5 in /usr/local/lib64/python3.9/site-packages (from paramiko) (1.5.0)
> Requirement already satisfied: cryptography>=3.3 in /usr/local/lib64/python3.9/site-packages (from paramiko) (41.0.2)
> Requirement already satisfied: bcrypt>=3.2 in /usr/local/lib64/python3.9/site-packages (from paramiko) (4.0.1)
> Requirement already satisfied: cffi>=1.12 in /usr/local/lib64/python3.9/site-packages (from cryptography>=3.3->paramiko) (1.15.1)
> Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=3.3->paramiko) (2.21)
> WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
> distutils: /home/svc_ansible/.local/lib/python3.9/site-packages
> sysconfig: /home/svc_ansible/.local/lib64/python3.9/site-packages
> WARNING: Additional context:
> user = True
> home = None
> root = None
> prefix = None
> 
> ```

but that doesn’t fix the problem.  
Please advice on how to fix this problem!

---

<div class="post-metadata">

**Author:** ![lumarel](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/lumarel/32/909_2.png) [@lumarel](https://forums.rockylinux.org/u/lumarel)\
**Post date:** [July 23, 2023, 1:26pm UTC](https://forums.rockylinux.org/t/rocky9-ansible-community-collections/10779/2 "2023-07-23T13:26:24Z")

</div>

Hey!  
Since the last minor releases of 8 and 9 ansible uses python3.11, so you have to run `python3.11 -m pip install paramiko` to get paramiko

Btw, as pip says, you should always use `python3 -m pip` instead of `pip`

---

<div class="post-metadata">

**Author:** ![Mikle](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Mikle](https://forums.rockylinux.org/u/Mikle)\
**Post date:** [July 23, 2023, 2:17pm UTC](https://forums.rockylinux.org/t/rocky9-ansible-community-collections/10779/3 "2023-07-23T14:17:41Z")

</div>

> [@lumarel](#):
>
> `python3.11 -m pip install paramiko`

I did the [update](https://techviewleo.com/how-to-install-python-3-on-rocky-almalinux/) python ftom 3.9 → 3.11.4, then install

```auto
python3.11 -m pip install ansible-pylibssh
python3.11 -m pip install paramiko

```

and this resolve my problem.  
thx! 😀

---

<div class="post-metadata">

**Author:** ![lumarel](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/lumarel/32/909_2.png) [@lumarel](https://forums.rockylinux.org/u/lumarel)\
**Post date:** [July 23, 2023, 9:45pm UTC](https://forums.rockylinux.org/t/rocky9-ansible-community-collections/10779/4 "2023-07-23T21:45:52Z")

</div>

> [@Mikle](#):
>
> I did the [update](https://techviewleo.com/how-to-install-python-3-on-rocky-almalinux/) python ftom 3.9 → 3.11.4, then install

I hope you didn’t break your system reading this link 🙂  
There is literally nothing to do, ansible-core depends on the `python3.11` which is in the [AppStream repo](https://rockylinux.pkgs.org/9/rockylinux-appstream-x86_64/python3.11-3.11.2-2.el9_2.1.x86_64.rpm.html), all you maybe have to do is install `python3.11-pip` and then use `python3.11 -m pip` (it is also possible to set the alternatives link for `python3` to 3.11 but might break other installed applications) (make sure you never change the platform-python link that will definitely break stuff)

If you manually build python, you will have to update it manually (beside SELinux might be mad at you if the executables are not put in the correct directories).
