Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Write Puppet manifests and modules faster with VIM

Deimos Fr
September 11, 2013

Write Puppet manifests and modules faster with VIM

Those slides presents VIM modules to help on writing Puppet manifests and modules.

Deimos Fr

September 11, 2013
Tweet

More Decks by Deimos Fr

Other Decks in Technology

Transcript

  1. Write Puppet manifests and modules faster with VIM: Summary Summary

    1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 Setup and usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 2 / 23
  2. Write Puppet manifests and modules faster with VIM: Introduction Plan

    1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 3 / 23
  3. Write Puppet manifests and modules faster with VIM: Introduction Puppet

    Labs Puppet is IT automation software that gives system administrators the power to easily automate repetitive tasks, quickly deploy critical applications, and proactively manage infrastructure, on-premises or in the cloud. Puppet is a scalable and open source solution. A lot of modules exists on the official repository called Puppet forge : https://forge.puppetlabs.com/ If you search a specific module not available on Puppet forge and you will need to create your own. This task would take some time at first. To create Puppet manifests, it will be easier, but the required time to know the syntax is a problem for newbies. Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 4 / 23
  4. Write Puppet manifests and modules faster with VIM: Introduction eNovance

    eNovance, an innovative French company that delivers services in two key areas: Integrating and operating public and private open source clouds and 24/7 managed Services for the world’s largest public clouds (Cloudwatt, AWS, Google Compute Engine, etc.). With its extensive investment in R&D, in less than three years eNovance has become the world’s 7th largest contributor to the OpenStack initiative, and the only European company on the foundation’s board of directors alongside Rackspace, Redhat, Cisco and HP. Today, we’re using Puppet in production and need to often write Puppet manifests and modules. That’s why we needed to have an IDE or something similar to win time when writing them. Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 5 / 23
  5. Write Puppet manifests and modules faster with VIM: Introduction Plan

    1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 6 / 23
  6. Write Puppet manifests and modules faster with VIM: Introduction History

    Puppet announced in 2011 an IDE plugin for Eclipse called Geppetto. I used it for more than a year and it really helps me to write manifests. Unfortunately, the latests versions purposed by Cloudsmith (Geppetto editor) get stability problems, even with the "all in one" version. In addition, Eclipse consume a lot of resources just for writing Puppet manifests. Another solution exist, this is set of VIM plugins which provide a lightweight solution. It gives more advanced features and automatically checks Puppet syntax (Geppetto too). This is what we’re going to see here with the usage. http://puppetlabs.com/blog/geppetto-a-puppet-ide/ http://cloudsmith.github.io/geppetto/ Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 7 / 23
  7. Write Puppet manifests and modules faster with VIM: Setup and

    usage Plan 2 Setup and usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Vundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Ultisnips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 VIM Puppet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Tabular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Syntastic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 8 / 23
  8. Write Puppet manifests and modules faster with VIM: Setup and

    usage Vundle What is Vundle ? Vundle is short for Vim bundle and is a Vim plugin manager. It will helps on install the next VIM modules (download and install from github/vimscripts...). To install it : Grab it from GitHub and add it to your vim personal folder git clone https :// github.com/gmarik/vundle.git ~/. vim/bundle/vundle To finish, add this at the beginning of your /.vimrc file : /.vimrc set nocompatible " be iMproved filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " My Bundles here: Bundle ’gmarik/vundle’ " Additional bundles: filetype plugin indent on " required! Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 9 / 23
  9. Write Puppet manifests and modules faster with VIM: Setup and

    usage Vundle When you will add new lines to declare new bundles, you’ll install them by running that command : Install bundles with vundle vim + BundleInstall +qall Link : https://github.com/gmarik/vundle Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 10 / 23
  10. Write Puppet manifests and modules faster with VIM: Setup and

    usage Plan 2 Setup and usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Vundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Ultisnips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 VIM Puppet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Tabular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Syntastic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 11 / 23
  11. Write Puppet manifests and modules faster with VIM: Setup and

    usage Ultisnips Ultisnips helps on writing Puppet type refences (file, cron, user...). To install it add this line after ’Additional bundle’ part of your vimrc and install this new bundle : .vimrc " Additional bundles: Bundle ’SirVer/ultisnips’ To test it, edit a file with ’.pp’ extension and type as follow : class <tab> : you’ll see a class block user <tab> : a block with most used option will appear cron <tab> : a block ... ... <tab> Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 12 / 23
  12. Write Puppet manifests and modules faster with VIM: Setup and

    usage Ultisnips Here is the result : test.pp class name { # body } user { ’username’: ensure => present, uid => uid, gid => gid, comment => gecos, home => homedirectory, managehome => false, require => Group[’group’], } cron { ’name’: user => user, command => ’command’, minute => minute, hour => hour, } Link : https://github.com/SirVer/ultisnips Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 13 / 23
  13. Write Puppet manifests and modules faster with VIM: Setup and

    usage Plan 2 Setup and usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Vundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Ultisnips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 VIM Puppet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Tabular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Syntastic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 14 / 23
  14. Write Puppet manifests and modules faster with VIM: Setup and

    usage VIM Puppet VIM Puppet provides : Formatting based on the latest Puppetlabs Style Guide Syntax highlighting Automatic => alignment (when the tabular plugin is also installed) To install it add this line after ’Additional bundle’ part of your vimrc and install this new bundle : /.vimrc " Additional bundles: Bundle ’rodjek/vim-puppet’ Link : https://github.com/rodjek/vim-puppet Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 15 / 23
  15. Write Puppet manifests and modules faster with VIM: Setup and

    usage Plan 2 Setup and usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Vundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Ultisnips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 VIM Puppet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Tabular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Syntastic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 16 / 23
  16. Write Puppet manifests and modules faster with VIM: Setup and

    usage Tabular This plugins helps on having signs alignments on multiple lines. It’s usually better to read good formated code. For instance having ’=’ sign aligned or ’=>’ sign for Puppet. Coupled with VIM Puppet, it will automatically align the signs when you will write your manifests. To install it add this line after ’Additional bundle’ part of your vimrc and install this new bundle : .vimrc " Additional bundles: Bundle ’godlygeek/tabular’ To use it with Puppet manifests/modules, you don’t have nothing to do as it will automatically align from the previous lines. Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 17 / 23
  17. Write Puppet manifests and modules faster with VIM: Setup and

    usage Tabular Anyway, for any reasons you want to do it manually, this is easy. In VIM, place your cursor on the first line containing the symbol on which the alignment should be done, then type : This will align from the ’=’ symbol : Tabularize /= Example : toto = toto titi =titi toto = toto titi = titi Link : https://github.com/godlygeek/tabular Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 18 / 23
  18. Write Puppet manifests and modules faster with VIM: Setup and

    usage Plan 2 Setup and usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Vundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Ultisnips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 VIM Puppet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Tabular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Syntastic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 19 / 23
  19. Write Puppet manifests and modules faster with VIM: Setup and

    usage Syntastic Syntastic is a syntax checking plugin that runs files through external syntax checkers and displays any resulting errors to the user. This can be done on demand, or automatically as files are saved. If syntax errors are detected, the user is notified and is happy because they didn’t have to compile their code or execute their script to find them. To install it add this line after ’Additional bundle’ part of your vimrc and install this new bundle : .vimrc " Additional bundles: Bundle ’scrooloose/syntastic’ On the next slide, you’ll find a screenshot example. Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 20 / 23
  20. Write Puppet manifests and modules faster with VIM: Setup and

    usage Syntastic Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 21 / 23
  21. Write Puppet manifests and modules faster with VIM: Setup and

    usage Syntastic When you move your cursor on a line beginning with the ’»’ symbol, you’ll see the line error message on the bottom of the screen. If you want to see all errors, you need to type this in VIM : Install bundles with vundle :Errors And the bottom of the screen will look likes the screenshot above. Link : https://github.com/scrooloose/syntastic Pierre Mavro www.enovance.com Write Puppet manifests and modules faster with VIM 22 / 23