How can I pass parameters from Jenkins to my Ansible playbook? Eg. I want to take IP address from users and pass it to the playbook so that it will execute only on those machines.
You can use -e switch for that purpose:
ansible-playbook -e 'foo=${FOO}'
where the FOO can be defined in the Jenkins envirionment variables. If it is defined within the parameters block of your Jenkinsfile, then you need to use ${params.foo}
. Then, the value can be accessed by the Ansible playbook with {{ foo }}
.