Merge "Fixed labels in master node config enforcing"
diff --git a/jenkins/client/_job.sls b/jenkins/client/_job.sls
index 003a11a..1a8e6df 100644
--- a/jenkins/client/_job.sls
+++ b/jenkins/client/_job.sls
@@ -20,7 +20,6 @@
   - config: {{ client.dir.jenkins_jobs_root }}/{{ job_name }}.xml
   - watch:
     - file: jenkins_job_{{ job_name }}_definition
-    - file: /etc/salt/minion.d/_jenkins.conf
 
 {%- else %}
 
@@ -33,7 +32,5 @@
 jenkins_job_{{ job_name }}_absent:
   jenkins_job.absent:
   - name: {{ job_name }}
-  - watch:
-    - file: /etc/salt/minion.d/_jenkins.conf
 
 {%- endif %}
diff --git a/jenkins/client/init.sls b/jenkins/client/init.sls
index 8578af9..d93963f 100644
--- a/jenkins/client/init.sls
+++ b/jenkins/client/init.sls
@@ -53,11 +53,6 @@
   pkg.installed:
   - names: {{ client.pkgs }}
 
-/etc/salt/minion.d/_jenkins.conf:
-  file.managed:
-  - source: salt://jenkins/files/_jenkins.conf
-  - template: jinja
-
 jenkins_client_dirs:
   file.directory:
   - names:
diff --git a/jenkins/client/node.sls b/jenkins/client/node.sls
index a9bc209..35e43a3 100644
--- a/jenkins/client/node.sls
+++ b/jenkins/client/node.sls
@@ -1,6 +1,6 @@
 {% from "jenkins/map.jinja" import client with context %}
 {% for name, node in client.get("node",{}).iteritems() %}
-{% if node.get('name', name) == "master"}
+{% if node.get('name', name) == "master" %}
 master_configuration:
   jenkins_node.setup_master:
     - num_executors: {{ node.get('num_executors','1') }}
@@ -17,7 +17,7 @@
     - node_mode: {{ node.get('node_mode','Normal') }}
     - ret_strategy: {{ node.get('ret_strategy','Always') }}
     - labels: {{ node.get('labels',[]) }}
-{% endfor %}
+{% endif %}
 
 {% for node_name, label in client.get("label",{}).iteritems() %}
 label_for_{{ node_name }}:
@@ -25,4 +25,5 @@
     - name: {{ node_name }}
     - lbl_text: {{ label.lbl_text }}
     - append: {{ label.get('append', False) }}
-{% endfor %}
\ No newline at end of file
+{% endfor %}
+{%- endfor %}
diff --git a/jenkins/files/_jenkins.conf b/jenkins/files/_jenkins.conf
deleted file mode 100644
index 0079d74..0000000
--- a/jenkins/files/_jenkins.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-{%- from "jenkins/map.jinja" import client with context %}
-jenkins:
-  url: "{{ client.master.get('proto', 'http') }}://{{ client.master.host }}:{{ client.master.port }}"
-  {%- if client.master.api_key is defined %}
-  api_key: {{ client.master.api_key }}
-  {%- else %}
-  user: {{ client.master.get('username', 'admin') }}
-  password: {{ client.master.get('password', 'dummy') }}
-  {%- endif %}
diff --git a/jenkins/files/hudson.model.UpdateCenter.xml b/jenkins/files/hudson.model.UpdateCenter.xml
index 571853e..7c9de8b 100644
--- a/jenkins/files/hudson.model.UpdateCenter.xml
+++ b/jenkins/files/hudson.model.UpdateCenter.xml
@@ -5,4 +5,4 @@
     <id>default</id>
     <url>{{ master.update_site_url }}</url>
   </site>
-</sites>
+</sites>
\ No newline at end of file
diff --git a/jenkins/files/jobs/_common.xml b/jenkins/files/jobs/_common.xml
index c723b65..7baaf40 100644
--- a/jenkins/files/jobs/_common.xml
+++ b/jenkins/files/jobs/_common.xml
@@ -118,7 +118,7 @@
           <triggerConfigURL></triggerConfigURL>
           <triggerInformationAction/>
         </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
-        {%- elif type == 'timer' %}
+        {%- elif type == 'timer' and trigger.spec != '' %}
         <hudson.triggers.TimerTrigger>
           <spec>{{ trigger.spec }}</spec>
         </hudson.triggers.TimerTrigger>
diff --git a/jenkins/master/service.sls b/jenkins/master/service.sls
index 8dcd8d7..b5a1215 100644
--- a/jenkins/master/service.sls
+++ b/jenkins/master/service.sls
@@ -89,8 +89,8 @@
 
 jenkins_service_running:
   cmd.wait:
-    - name: "i=0; while true; do curl -s -f http://localhost:{{ master.http.port }} >/dev/null && exit 0; [ $i -gt 60 ] && exit 1; sleep 5; done"
+    - name: "i=0; while true; do curl -s -f http://localhost:{{ master.http.port }}/login >/dev/null && exit 0; [ $i -gt 60 ] && exit 1; sleep 5; done"
     - watch:
       - service: jenkins_master_service
 
-{%- endif %}
\ No newline at end of file
+{%- endif %}
diff --git a/jenkins/meta/salt.yml b/jenkins/meta/salt.yml
new file mode 100644
index 0000000..b46fdb5
--- /dev/null
+++ b/jenkins/meta/salt.yml
@@ -0,0 +1,13 @@
+minion:
+  {%- if pillar.get('jenkins', {}).get('client') %}
+  jenkins:
+    {%- from "jenkins/map.jinja" import client with context %}
+    jenkins:
+      url: "{{ client.master.get('proto', 'http') }}://{{ client.master.host }}:{{ client.master.port }}"
+      {%- if client.master.api_key is defined %}
+      api_key: {{ client.master.api_key }}
+      {%- else %}
+      user: {{ client.master.get('username', 'admin') }}
+      password: {{ client.master.get('password', 'dummy') }}
+      {%- endif %}
+  {%- endif %}