[cubciweb] activate cubicweb db-create instruction in pillar
authorKatia Saurfelt <katia.saurfelt@logilab.fr>
Fri, 05 Jun 2015 15:36:00 +0200
changeset 37 3a1147a825c5
parent 36 581a383990fa
child 38 939dee846ce3
[cubciweb] activate cubicweb db-create instruction in pillar (closes #5437946)
_states/cubicweb_instance.py
cubicweb/instances.sls
pillar.example
--- a/_states/cubicweb_instance.py	Fri Jun 05 11:30:41 2015 +0200
+++ b/_states/cubicweb_instance.py	Fri Jun 05 15:36:00 2015 +0200
@@ -47,6 +47,7 @@
 def present(name,
             cubes,
             install_type='all-in-one',
+            create_db=False,
             **kwargs):
 
     ret = {'name': name,
@@ -66,5 +67,9 @@
         ret['comment'] = 'Instance {0} is set to be created'.format(name)
         return ret
     __salt__['cubicweb.create'](name, cubes, install_type=install_type, **kwargs)
-    ret['comment'] = 'Instance {0} has been installed'.format(name)
+    if create_db:
+        __salt__['cubicweb.initialize'](name)
+        ret['comment'] = 'Instance {0} has been installed and database initialized'.format(name)
+    else:
+        ret['comment'] = 'Instance {0} has been installed'.format(name)
     return ret
--- a/cubicweb/instances.sls	Fri Jun 05 11:30:41 2015 +0200
+++ b/cubicweb/instances.sls	Fri Jun 05 15:36:00 2015 +0200
@@ -11,7 +11,7 @@
 {% endfor %}
 
 {% for extrasrc in salt['pillar.get']('extra_sources', ()) %}
-{{ extrasrc }}: 
+{{ extrasrc }}:
     pkgrepo.managed:
         - name : {{ extrasrc }}
         - file: /etc/apt/sources.list.d/extra_source_{{loop.index}}.list
@@ -34,6 +34,7 @@
     - db-name: {{config.database.name}}
     - db-user: {{config.database.user}}
     - db-password: {{config.database.password}}
+    - create_db: {{config.cwapp.create_db}}
     - require:
       - pkg: cw-{{vhostname}}-{{name}}
   pkg.installed:
--- a/pillar.example	Fri Jun 05 11:30:41 2015 +0200
+++ b/pillar.example	Fri Jun 05 15:36:00 2015 +0200
@@ -44,6 +44,7 @@
         port: 9090
         adminuser: admin
         adminpass: admin
+        create_db: True # will execute cubiweb db-create
         cubes:
           blog: cubicweb-blog
     demo2: