Using Ansible to provision Jenkins

I’m using Ansible to provision a machine with Jenkins within a Docker container

As part of the provisioning process I wait until Jenkins is running and then download the CLI to continue the provisioning by executing CLI commands.
The jar file is being downloaded to the host machine.

I was wondering if this was necessarily the best approach ?
Could the CLI jar be downloaded to my workstation instead and the commands executed from there?
Could I use Groovy scripts to provision the machine ?
Other suggestions?

hi anthony,

you can check delegation and local_action to download the jenkins cli to your local workstation:
https://docs.ansible.com/playbooks_delegation.html

best,
naomi.

You could have a look at this.
https://github.com/adithyakhamithkar/ansible/blob/master/roles/jenkins-configure/tasks/main.yml