Shellcode to install the python on target machine

I need to understand to write ansible module in shellcode to install python on controller machine. we know without python on controller machine we can’t run ansible modules.
some of operating system (RHEL8) does not come up with python and we can’t run ansible modules. Need to write shellcode moudle to install python to run sudo yum install python.

can you help me how to write shellcode module and integrated with ansible and make sure to install by running playbook.

You can do this with Ansible. Use a raw task:

- name: Bootstrap a host without python3 installed
  raw: dnf install -y python3

If you want to be idempotent then you should be able to do something like this:

- name: Bootstrap a host without python
  raw: bash -c "test -e /bin/python3 || (dnf install -y python3)"
  register: output
  changed_when: output.stdout

If /bin/python3 exists, then output.stdout will be blank and Ansible will report the task as “ok”.

You can double check where python should be installed:

$ which python3
/bin/python3

raw is an ansible module right. How this is going to be work without python.

Also, i need to test this one in RHEL system. Do we have any playground to test it.

No it does not use python to execute, that is the whole point of it:

ansible.builtin.raw module – Ansible Community Documentation

There is a Centos Stream 8 playground:
CentOS Stream Playground | KodeKloud