corrections to pre and post state
authorPaul Tonelli <paul.tonelli@logilab.fr>
Thu, 07 Mar 2013 10:30:14 +0100
changeset 35 0792b2bd0795
parent 34 434bfcf7aa95
child 36 b416322fdd6b
corrections to pre and post state
ami_creator_post.sls
ami_creator_pre.sls
--- a/ami_creator_post.sls	Wed Mar 06 18:02:01 2013 +0100
+++ b/ami_creator_post.sls	Thu Mar 07 10:30:14 2013 +0100
@@ -10,6 +10,27 @@
     file.absent:
         - name: /mnt/variation/etc/resolv.conf
 
+01proxy_removed:
+    file.absent:
+        - name: /mnt/variation/etc/apt/apt.conf.d/01proxy
+
+### Extract necessary files ###
+
+{% for file in salt['file.find']('/mnt/variation/boot/', iname='vmlinuz*') %}
+kernel:
+    tmp_func.local_managed:
+        - name: /mnt/vmlinuz_variation
+        - source: {{ file }}
+{% endfor %}
+
+{% for file in salt['file.find']('/mnt/variation/boot/', iname='initrd*') %}
+initrd:
+    tmp_func.local_managed:
+        - name: /mnt/vmlinuz_variation
+        - source: {{ file }}
+{% endfor %}
+
+
 ### umounts ###
 umount_chroot_proc:
     tmp_func.umounted:
@@ -25,6 +46,9 @@
         - require:
             - tmp_func.umounted: umount_chroot_devpts
             - tmp_func.umounted: umount_chroot_proc
+            - tmp_func.local_managed: kernel
+            - tmp_func.local_managed: initrd
             - file.absent: policy_removed
             - file.absent: resolvconf_removed
+            - file.absent: 01proxy_removed
 
--- a/ami_creator_pre.sls	Wed Mar 06 18:02:01 2013 +0100
+++ b/ami_creator_pre.sls	Thu Mar 07 10:30:14 2013 +0100
@@ -1,30 +1,32 @@
-### Salt state to check before modifying chroot ###
+### unarchived files ###
+variation_extracted:
+    archive.extracted:
+        - name: /mnt/
+        - source: salt://variation_debian.tar.gz
+        - archive_format: tar
+        - tar_options: z
+        - if_missing: variation_debian.img
 
-base_pkgs:
-    pkg.installed:
-        - pkgs:
-            - salt-minion
-            - python
-            - mercurial
-            - tar
-            - glance
-#          - eca2ools
-
-hg_ami_creation:
-    hg.latest:
-        - name: http://hg.logilab.fr/users/ptonelli/srv_salt
-        - target: /etc/salt/srv
-
+###  Directories ###
+/mnt/variation:
+    file.directory:
+        - user: root
+        - group: root
+        - mode: 755
+        - makedirs: True
 
 ### Mounts ###
 mounted_variation:
     mount.mounted:
-        - device: /mnt/variation.img
+        - device: /mnt/variation_debian.img
         - name: /mnt/variation
         - fstype: ext4
         - mkmnt: False
         - opts:
             - loop
+        - require:
+            - file.directory: /mnt/variation
+            - archive.extracted: variation_extracted
 
 chroot_proc:
     mount.mounted:
@@ -53,7 +55,6 @@
         - require:
             - mount.mounted: mounted_variation
 
-
 policy-rc.d:
     file.managed:
         - name: /mnt/variation/usr/sbin/policy-rc.d
@@ -62,13 +63,6 @@
         - require:
             - mount.mounted: mounted_variation
 
-resolv.conf:
-    tmp_func.local_managed:
-        - name: /mnt/variation/etc/resolv.conf
-        - source: /etc/resolv.conf
-        - require:
-            - mount.mounted: mounted_variation
-
 variation.sls:
     file.managed:
         - name: /mnt/variation/etc/salt/variation.sls
@@ -84,3 +78,10 @@
         - mode: 644
         - require:
             - mount.mounted: mounted_variation
+
+resolv.conf:
+    tmp_func.local_managed:
+        - name: /mnt/variation/etc/resolv.conf
+        - source: /etc/resolv.conf
+        - require:
+            - mount.mounted: mounted_variation