| --- |
| # jenkins tasks/main.yml |
| # |
| # SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| # SPDX-License-Identifier: Apache-2.0 |
| |
| - name: include OS-specific vars |
| include_vars: "{{ ansible_os_family }}.yml" |
| |
| - name: Gather the package facts |
| package_facts: |
| manager: auto |
| |
| - name: include OS-specific tasks |
| include_tasks: "{{ ansible_os_family }}.yml" |
| |
| - name: Initial the Jenkins |
| include_tasks: "settings.yml" |
| |
| - name: Trigger handlers immediately in case Jenkins was installed |
| meta: flush_handlers |
| |
| - name: Wait for Jenkins to start up before proceeding. |
| uri: |
| url: "http://{{ jenkins_localhost }}/cli/" |
| method: GET |
| return_content: "yes" |
| timeout: 5 |
| body_format: raw |
| follow_redirects: "no" |
| status_code: 200,403 |
| register: result |
| until: (result.status == 403 or result.status == 200) |
| and (result.content.find("Please wait while") == -1) |
| retries: 60 |
| delay: 5 |
| |
| - name: Remove Jenkins security init scripts after first startup. |
| file: |
| path: "{{ jenkins_home }}/init.groovy.d/basic-security.groovy" |
| state: absent |
| |
| - name: Install plugins |
| jenkins_plugin: |
| name: "{{ item.name }}" |
| version: "{{ item.version | default(omit) }}" |
| url_username: "{{ jenkins_admin_username }}" |
| url_password: "{{ jenkins_admin_password }}" |
| url: "http://{{ jenkins_localhost }}" |
| register: my_jenkins_plugin_versioned |
| with_items: "{{ jenkins_plugins }}" |
| notify: restart-jenkins |
| register: plugin_result |
| until: plugin_result is success |
| retries: 3 |
| delay: 2 |