Module "community.general.shutdown" was not found in configured module paths

Hello,
I am a beginer in Ansible and this is my first question,the action and outcome is described here,

  1. I configured a two-node ansible env with sucess two days ago, following the “Get started with Ansible” section in https://docs.ansible.com/.
    One control node(T460-node1) and 2 managed nodes(T460-node1 and T460-node2), both in ubuntun machine.

  2. Ansible-core was insatlled with pip under ubuntu user id :lvtao
    and then module “community.general.shutdow” was installed with the same id.
    Install path: /home/lvtao/.ansible/collections/ansible_collections

3.With ubuntu root id, I wanted to practise shutting down these two nodes with a ad hoc command, and failed with the “module NOT FOUND” issue.

Could someone give me any suggestion, is there any parameter can resolve or bypass this this issue?

(learning_env) root@t460-node1:~# ansible t460 -m community.general.shutdown
t460-node1 | FAILED! => {
    "msg": "The module community.general.shutdown was not found in configured module paths"
}
t460-node2 | FAILED! => {
    "msg": "The module community.general.shutdown was not found in configured module paths"
}

(learning_env) lvtao@t460-node1:~/.ansible/collections/ansible_collections$ pwd
/home/lvtao/.ansible/collections/ansible_collections
(learning_env) lvtao@t460-node1:~/.ansible/collections/ansible_collections$ ls
community  community.general-7.4.0.info

Hi,

Could someone give me any suggestion, is there any parameter can resolve or bypass this this issue?

Either run your command as the same user you installed ansible packages with (obviously, and note you can specify user to login with on remote machine with ansible_user var, though you’d also need to provide password or have a key configured for this specific connection -and ofc, ssh access would need to be authorized with this user, which is usually not the case for root. I’m not sure for Ubuntu, but I consider it to be bad practice anyways-), or you indicate your user where to find collections; this user being root on the same machine you installed ansible packages, permissions won’t be an issue.

If I understand this situation well, you’re trying to power off remote machines, which needs to run as root on remote nodes. In that case, I think using become with default settings (sudo as root) will be a better option. Just add --become --ask-become-pass (or -bK) to your command. Here is the relevant doc section.

Edit: I should have been more precise; regarding @IPvSean answer, you can indeed install this collection as root as well, but you’ll then have it installed at two places on your system (which is sometimes the desired course of action).
I suggested prior that you can use the already installed collections (I haven’t explained either, but modules are part of a collection, so you need to have it installed to use its content) by setting your collections path to point to it, though it might not be the most elegant way to proceed.
As I said, if you run your playbook as root so you can run tasks as root on remote systems, you certainly should use become instead.

Hope it helps !

1 Like

Did you install this collection? You can do a ansible-galaxy collection list to see what you have installed, and install a collection that you need with ansible-galaxy collection install community.general

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.