Automate shutdown command via Ansible playbook

I’m using ansible 2.9. There is no shutdown module available.

I need to automate shutdown command via Ansible playbook. The target hosts are different distributions of CentOS servers - 7 or 6. When I ran the playbook to shutdown them, the execution will hang forever for one of CentOS 7 servers. I had to hit Ctrl-C. The execution stopped when example8 is down. It is CentOS 7. The example7 is CentOS 6 and does not hang forever.

inventory file:
[shutdown_300]
example1

[shutdown_301]
example2

[shutdown_302]
example3

[shutdown_303]
example4

[shutdown_304]
example5

[shutdown_305]
example6

[shutdown_306]
example7
example8

[shutdown_30:children]
shutdown_306
shutdown_305
shutdown_304
shutdown_303
shutdown_302
shutdown_301
shutdown_300

Here is the playbook:

Don’t waste time on working around problems in unsupported software.

Instead use the energy to upgrade to something supported.

A more recent version is not published as an RPM for RHEL systems. If
you want one, I publish tools to build RPMs for it at
https://github.com/nkadel/ansiblerepo/

You probably have no use for the current ansible package. It is a very
bulky agglomeration of roughly 100 ansible collection modules, and
*all* the necessary scripts and python modules for basic ansible
operation are in the ansible-core package. I suspect that if you rip
out ansible, install ansible-core, and install the ansible collection
modules on if and when needed, you will have a much more stable
ansible setup.