ami_creator_post.sls
author Paul Tonelli <paul.tonelli@logilab.fr>
Fri, 15 Mar 2013 14:58:22 +0100
changeset 78 f964fb1a386a
parent 69 03a191bfee6f
permissions -rw-r--r--
cut ami_creator_pre into different sls files in folder, made necessary modification: - transformed variables into salt grains when necessary - moved requirements

### Salt state to check after modifying chroot ###

{% set chroot = '/mnt/variation' %}
### deletes ###

#01proxy:
#    file.absent:
#        - name: {{ chroot }}/etc/apt/apt.conf.d/01proxy

02confold:
    file.absent:
        - name: {{ chroot }}/etc/apt/apt.conf.d/02confold

resolv.conf:
    file.absent:
        - name: {{ chroot }}/etc/resolv.conf

{% set keyfiles = ['ssh_host_dsa_key', 'ssh_host_dsa_key.pub', 'ssh_host_rsa_key', 'ssh_host_rsa_key.pub'] %}
{% for file in keyfiles %}
ssh_host_keys_{{ file }}:
    file.absent:
        - name: {{ chroot }}/etc/ssh/{{ file }}
{% endfor %}

### remove apt caches ###
{% set bin_caches = salt['file.find'](chroot + '/var/cache/apt/', iname='*bin') %}
{% for file in bin_caches %}
apt_cache_{{ file }}:
    file.absent:
        - name: {{ file }}
{% endfor %}

apt_lists:
    file.absent:
        - name: {{ chroot }}/var/lib/apt/lists

apt_policy:
    file.absent:
        - name: {{ chroot }}/usr/sbin/policy-rc.d

### extract necessary files ###

{% for file in salt['file.find'](chroot + '/boot/', iname='vmlinuz*') %}
kernel:
    tmp_state.local_managed:
        - name: /mnt/kernel_variation
        - source: {{ file }}
{% endfor %}

{% for file in salt['file.find'](chroot + '/boot/', iname='initrd*') %}
initrd:
    tmp_state.local_managed:
        - name: /mnt/ramdisk_variation
        - source: {{ file }}
{% endfor %}

### umounts ###
umount_chroot_proc:
    tmp_state.umounted:
        - name: {{ chroot }}/proc

umount_chroot_devpts:
    tmp_state.umounted:
        - name: {{ chroot }}/dev/pts

umount_chroot_slash:
    tmp_state.umounted:
        - name: {{ chroot }}
        - require:
            - tmp_state.umounted: umount_chroot_devpts
            - tmp_state.umounted: umount_chroot_proc
            - tmp_state.local_managed: kernel
            - tmp_state.local_managed: initrd
#            - file.absent: 01proxy_removed
            - file.absent: 02confold
            - file.absent: resolv.conf
{% for file in keyfiles %}
            - file.absent: ssh_host_keys_{{ file }}
{% endfor %}
{% for file in bin_caches %}
            - file.absent: apt_cache_{{ file }}
{% endfor %}
            - file.absent: apt_lists
            - file.absent: apt_policy

### Resize the partition to min ###
resize_variation:
    tmp_state.resized:
        - name: {{ chroot }}.img
        - require:
            - tmp_state.unmounted: umount_chroot_slash