GithubHelp home page GithubHelp logo

dachung / saltstack-format-partition Goto Github PK

View Code? Open in Web Editor NEW

This project forked from opensource-expert/saltstack-format-partition

0.0 1.0 0.0 14 KB

salt state sample to format a partition under debian and add mountpoint

License: GNU General Public License v3.0

SaltStack 100.00%

saltstack-format-partition's Introduction

# saltstack-format-partition
A samble of salt state: to format a partition under debian Jessie and add mountpoint

## Usage

~~~
salt 'minion' state.apply format-partition.install-additional-storage
~~~


## About

This state find a new drive, create a new primary partition using the full space.
Then the partition is formated, and finally the partition is added to `fstab` but not mounted.

`DESTROY_partition.sls` is a tool to destroy what is done above, mainly for testing.

## Snippet

The last step needs to have the partition formated already, so it can't find the
`blkid` of the drive too early. Unfortunately it can't be done during the same
state definition. So I tested two approches, each delays the jinja evaluation of the blkid
when the state is executed, not when the yaml is built for salt.

### seconde state file
~~~yaml
add_fstab:
  module.run:
    - name: state.sls
    - mods: format-partition/.add_fstab
    - unless: grep /home /etc/fstab
~~~

loaded sls file `format-partition.add_fstab.sls`

~~~yaml
add_fstab:
  mount.mounted:
    - name: /home
    - mount: False
    - device: UUID={{ salt['disk.blkid']('/dev/vdb1')['/dev/vdb1']['UUID'] }}
    - fstype: ext4
    - opts: auto,defaults,errors=remount-ro
    - dump: 0
    - pass_num: 1
    - persist: True
~~~



### managed file with template
~~~yaml
add_fstab:
  file.append:
    - name: /etc/fstab
    - source: salt://format-partition/files/fstab
    - require:
      - module: mkfs_vdb1
~~~

template file `format-partition/files/fstab`

~~~jinja
{# vim: set ft=jinja: #}
# ceph remote storag, added by salt
UUID="{{ salt['disk.blkid']('/dev/vdb1')['/dev/vdb1']['UUID'] }}" /home ext4 defaults,errors=remount-ro 0 1
~~~

saltstack-format-partition's People

Contributors

sylvain303 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.