Merge "Update .travis.yml and .kitchen.yml files for parallel testing"
diff --git a/ceph/init.sls b/ceph/init.sls
index 0fa4edd..524ff26 100644
--- a/ceph/init.sls
+++ b/ceph/init.sls
@@ -1,10 +1,10 @@
 include:
-{% if pillar.ceph.osd is defined %}
-- ceph.osd
-{% endif %}
 {% if pillar.ceph.mon is defined %}
 - ceph.mon
 {% endif %}
+{% if pillar.ceph.osd is defined %}
+- ceph.osd
+{% endif %}
 {% if pillar.ceph.setup is defined %}
 - ceph.setup
 {% endif %}
diff --git a/ceph/setup/init.sls b/ceph/setup/init.sls
index e9c3e9a..07d3bcf 100644
--- a/ceph/setup/init.sls
+++ b/ceph/setup/init.sls
@@ -3,7 +3,7 @@
 
 include:
 - ceph.common
-{%- if setup.get('crush').enabled %}
+{%- if setup.get('crush') %}
 - ceph.setup.crush
 {%- endif %}
 {%- if setup.get('pool') %}
@@ -12,3 +12,5 @@
 {%- if common.get('keyring') %}
 - ceph.setup.keyring
 {%- endif %}
+
+{%- endif %}
diff --git a/ceph/setup/keyring.sls b/ceph/setup/keyring.sls
index 0a5b4c0..702200c 100644
--- a/ceph/setup/keyring.sls
+++ b/ceph/setup/keyring.sls
@@ -8,5 +8,3 @@
   - unless: ceph auth list | grep {{ keyring_name }}
 
 {%- endfor %}
-
-{%- endif %}
diff --git a/ceph/setup/pool.sls b/ceph/setup/pool.sls
index 1f7a40a..be2ace1 100644
--- a/ceph/setup/pool.sls
+++ b/ceph/setup/pool.sls
@@ -7,9 +7,17 @@
   - name: ceph osd pool create {{ pool_name }} {{ pool.pg_num }}{% if pool.pgp_num is defined %} {{ pool.pgp_num }}{% endif %} {{ pool.type }}{% if pool.erasure_code_profile is defined %} {{ pool.erasure_code_profile }}{% endif %}{% if pool.crush_ruleset_name is defined %} {{ pool.crush_ruleset_name }}{% endif %}{% if pool.expected_num_objects is defined %} {{ pool.expected_num_objects }}{% endif %}
   - unless: "ceph osd pool ls | grep ^{{ pool_name }}"
 
+{# We need to ensure pg_num is applied first #}
+{%- if pool.get('pg_num') %}
+ceph_pool_option_{{ pool_name }}_pg_num_first:
+  cmd.run:
+  - name: ceph osd pool set {{ pool_name }} pg_num {{ pool.get('pg_num') }}
+  - unless: "ceph osd pool get {{ pool_name }} pg_num | grep 'pg_num: {{ pool.get('pg_num') }}'"
+{%- endif %}
+
 {%- for option_name, option_value in pool.iteritems() %}
 
-{%- if option_name != 'type' %}
+{%- if option_name not in ['type', 'pg_num'] %}
 
 ceph_pool_option_{{ pool_name }}_{{ option_name }}:
   cmd.run:
@@ -22,4 +30,3 @@
 
 {%- endfor %}
 
-