[AETHER-852] - Mask the service to enusre Jenkins will load the latest config.
- Only generate the init groovy script for first-time installation
- Remove init groovy script after first-time instllation.
- Moved the variable location
Change-Id: I0c0fb01f21353c817e2de986c86903df0387b9e4
diff --git a/tasks/main.yml b/tasks/main.yml
index 32b6c1b..1860396 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -7,18 +7,35 @@
- 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: generate groovy for initializing local admin account
- template:
- src: init_admin.groovy.j2
- dest: "{{ jenkins_home }}/init.groovy.d/basic-security.groovy"
- owner: "{{ jenkins_process_user }}"
- group: "{{ jenkins_process_group }}"
- mode: 0775
- notify:
- - start-jenkins
+- 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