ami_creator_pre.sls
author Paul Tonelli <paul.tonelli@logilab.fr>
Tue, 12 Mar 2013 17:31:13 +0100
changeset 69 03a191bfee6f
parent 68 601c145e6326
permissions -rw-r--r--
bug corrections and renamed initrd to ramdisk and vmlinuz to kernel when possible

### unarchived files ###

{% if  salt['grains.item']('ami.type') %}
{% set ami_origin = salt['grains.item']('ami.type') %}
{% else %}
{% set ami_origin = 'debian' %}
{% endif %}

variation_extracted:
    archive.extracted:
        - name: /mnt/
        - source: salt://variation_{{ ami_origin }}.tar.gz
        - archive_format: tar
        - tar_options: z
        - if_missing: variation.img

### Resize the partition ###
resize_variation:
    tmp_state.resized:
        - name: /mnt/variation.img
        - size: 3G
        - require:
            - archive.extracted: variation_extracted

###  Directories ###
/mnt/variation:
    file.directory:
        - user: root
        - group: root
        - mode: 755
        - makedirs: True

### Mounts ###
mounted_variation:
    mount.mounted:
        - device: /mnt/variation.img
        - name: /mnt/variation
        - fstype: ext4
        - mkmnt: False
        - opts:
            - loop
        - require:
            - file.directory: /mnt/variation
            - tmp_state.resized: resize_variation

chroot_proc:
    mount.mounted:
        - device: none
        - name: /mnt/variation/proc
        - fstype: proc
        - mkmnt: false
        - require:
            - mount.mounted: mounted_variation

chroot_devpts:
    mount.mounted:
        - device: none
        - name: /mnt/variation/dev/pts
        - fstype: devpts
        - mkmnt: False
        - require:
            - mount.mounted: mounted_variation

### Temporary Files ###
01proxy:
    file.managed:
        - name: /mnt/variation/etc/apt/apt.conf.d/01proxy
        - source: salt://others/01proxy
        - mode: 644
        - require:
            - mount.mounted: mounted_variation

02confold:
    file.managed:
        - name: /mnt/variation/etc/apt/apt.conf.d/02confold
        - source: salt://others/02confold
        - mode: 644
        - require:
            - mount.mounted: mounted_variation

policy-rc.d:
    file.managed:
        - name: /mnt/variation/usr/sbin/policy-rc.d
        - source: salt://others/policy-rc.d
        - mode: 755
        - require:
            - mount.mounted: mounted_variation

{% if ami_origin == 'debian' %}
unstable.list:
    file.managed:
        - name: /mnt/variation/etc/apt/sources.list.d/unstable.list
        - source: salt://others/unstable.list
        - mode: 644
        - require:
            - mount.mounted: mounted_variation

pinning:
    file.managed:
        - name: /mnt/variation/etc/apt/preferences.d/pinning
        - source: salt://others/pinning
        - mode: 644
        - require:
            - mount.mounted: mounted_variation
{% endif %}

minion:
    file.managed:
        - name: /mnt/variation/etc/salt/minion
        - source: salt://variation.minion
        - mode: 644
        - require:
            - mount.mounted: mounted_variation

variation.sls:
    file.managed:
        - name: /mnt/variation/etc/salt/srv/variation.sls
        - source: salt://variation.sls
        - mode: 644
        - require:
            - mount.mounted: mounted_variation

variation.top.sls:
    file.managed:
        - name: /mnt/variation/etc/salt/srv/top.sls
        - source: salt://variation.top.sls
        - mode: 644
        - require:
            - mount.mounted: mounted_variation

resolv.conf:
    tmp_state.local_managed:
        - name: /mnt/variation/etc/resolv.conf
        - source: /etc/resolv.conf
        - require:
            - mount.mounted: mounted_variation