How to create and execute jenkinsfile when Jenkins and ansible are in separate containers

  • I’m new to Jenkins…
  • My goal is to create a Jenkins file for activate group of ansible-playbook – which will create a long installation of my tested product.
  • I manage my Ansible files locally with VSCode and push them to Git repository.
  • I also have an empty directory for Jenkins files.
  • I build 2 containers in Docker desktop (Windows): Ansible and Jenkins.
  • Ansible and Jenkins are on the same Network Id.
  • Ping command is working from Ansible to Jenkins and vis versa.
  • Both containers have access to Internet.
  • My Ansible container has an access to my Ansible directory with its docker-compose file, like this:
      - ~/product/ansible:/ansible
  • My Jenkins container has no access to the Jenkins directory.
  • I installed Ansible plugin in Jenkins container through Jenkins site > Manage Jenkins > Manage Plugins.
  • I go to Create a Job > Freestyle project – under steps section, I filled name, paths for Ansible-playbook and inventories and that’s all.
  • Of course – this pipeline wasn’t worked at all. Not to mention that no file was created in my Jenkins folder.

So, what are the missing parts in my configuration – in order it to be work?