Ansible Playbook error in Jenkins

I've written a simple playbook to install httpd. Here is my playbook:

    - name: install httpd
      hosts: localhost
      become: root
       inputvariable: "{{lookup('file','/home/ec2-user/inputfile.json')}}"
       - yum:
          name:  "{{item.packagename}}"
          state: "{{item.state}}"
        with_items: '{{ inputvariable.resources}}'

Here is my input file:

      "packagename": "httpd",
      "state": "present"

The problem is when I execute the playbook with the following command from the console it executes successfully.

     ansible-playbook -vvv -C -e "ansible_python_interpreter=/usr/bin/python" apacheplaybook.yml

But when executed in Jenkins It shows the following error:

"msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed for this module"}

This is how I run the jenkins project: enter image description here

I'm running Jenkins as ec2-user and I have changed the owner ship of /var/lib/jenkins & /var/log/jenkins & /var/cache/jenkins to ec2-user and wheel group. Problem is with Jenkins as from console it executes successfully with this command.