2019-01-24 13:20:24 +01:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
# Handle plugins
|
|
|
|
# If Jenkins is installed or updated, wait for pulling the Jenkins CLI, assuming 10s should be sufficiant
|
2019-01-24 18:29:09 +01:00
|
|
|
- name: Wait for jenkins
|
2019-05-01 16:35:13 +02:00
|
|
|
wait_for: port={{ jenkins_http_port }} delay={{ jenkins_restart_delay }} state=started timeout={{ jenkins_restart_wait_timeout }}
|
2019-01-24 18:29:09 +01:00
|
|
|
when: jenkins_has_been_restarted is changed or jenkins_has_been_started is changed
|
2019-01-24 13:20:24 +01:00
|
|
|
|
|
|
|
# Create Jenkins CLI destination directory
|
|
|
|
- name: "Create Jenkins CLI destination directory"
|
|
|
|
file: path={{ jenkins_dest }} state=directory
|
|
|
|
|
|
|
|
- name: Get Jenkins CLI
|
2019-01-24 18:29:09 +01:00
|
|
|
get_url: url={{ jenkins_local_url}}/jnlpJars/jenkins-cli.jar dest={{ jenkins_cli_dest }} mode=0440
|
2019-01-24 13:20:24 +01:00
|
|
|
|
2019-05-01 16:35:13 +02:00
|
|
|
# - name: Check if Jenkins has been initialized already
|
|
|
|
# stat: path={{ jenkins_admin_user_pwd_file }}
|
|
|
|
# register: jenkins_pwd_path
|
|
|
|
|
|
|
|
# - name: Get the initial admin password, if we have to initialize the service
|
|
|
|
# shell: cat '{{ jenkins_dest }}/secrets/initialAdminPassword'
|
|
|
|
# register: jenkins_admin_pwd
|
|
|
|
# when: not jenkins_pwd_path.stat.exists
|
|
|
|
|
|
|
|
# # Create the Jenkins administrative user password file
|
|
|
|
# - name: Create the Jenkins administrative user password file
|
|
|
|
# copy: content={{ jenkins_admin_pwd.stdout }} dest={{ jenkins_admin_user_pwd_file }} mode=600
|
|
|
|
|
2019-01-24 13:20:24 +01:00
|
|
|
# Create the Jenkins administrative user password file
|
|
|
|
- name: Create the Jenkins administrative user password file
|
|
|
|
copy: content={{ jenkins_admin_pwd }} dest={{ jenkins_admin_user_pwd_file }} mode=600
|
|
|
|
|
|
|
|
- name: Install plugins without a specific version
|
2019-01-24 18:29:09 +01:00
|
|
|
jenkins_plugin: name="{{ item.name }}" state={{ item.state | default('latest') }} with_dependencies={{ item.dependencies | default(True) }} url={{ jenkins_local_url }} url_username={{ jenkins_access_params.url_username }} url_password={{ jenkins_access_params.url_password }}
|
|
|
|
when: item.version is not defined
|
|
|
|
with_items: '{{ jenkins_plugins }}'
|
|
|
|
notify: Restart jenkins
|
2019-01-24 13:20:24 +01:00
|
|
|
|
|
|
|
- name: Install plugins with a specific version
|
2019-01-24 18:29:09 +01:00
|
|
|
jenkins_plugin: name="{{ item.name }}" state={{ item.state | default('latest') }} version='{{ item.version }}' url={{ jenkins_local_url }} url_username={{ jenkins_access_params.url_username }} url_password={{ jenkins_access_params.url_password }}
|
|
|
|
when: item.version is defined
|
|
|
|
with_items: '{{ jenkins_plugins }}'
|
|
|
|
notify: Restart jenkins
|
2019-01-24 13:20:24 +01:00
|
|
|
|
|
|
|
become: True
|
|
|
|
become_user: '{{ jenkins_username }}'
|
|
|
|
when: jenkins_install
|
|
|
|
tags: [ 'jenkins', 'jenkins_plugins', 'jenkins_master' ]
|
|
|
|
|