ten quick tips to improve your chef workflow - chefconf 2015

20
Ten Quick Tips to Improve Your Chef Workflow Sean Carolan, May 3, 2015

Upload: chef

Post on 15-Aug-2015

15 views

Category:

Technology


0 download

TRANSCRIPT

Te n Q u i c k T i p s t o I m p r o v e Yo u r C h e f Wo r k f l o w

S e a n C a r o l a n , M a y 3 , 2 0 1 5

C o n t r i b u t o r : C h e f S o f t w a r e

T h e C h e f D e v e l o p m e n t K i t i n c l u d e s t h e k n i f e c o m m a n d l i n e t o o l , t h e n e w c h e f c o m m a n d , g e n e r a t o r s f o r c o o k b o o k s a n d o t h e r i t e m s , a n d t e s t i n g t o o l s l i k e R u b o c o p , F o o d c r i t i c , C h e f s p e c , a n d Te s t K i t c h e n .

#1 Use the Che fDK

C o n t r i b u t o r : C h e f S o f t w a r e

T h e C h e f D e v e l o p m e n t K i t i n c l u d e s t h e k n i f e c o m m a n d l i n e t o o l , t h e n e w c h e f c o m m a n d , g e n e r a t o r s f o r c o o k b o o k s a n d o t h e r i t e m s , a n d t e s t i n g t o o l s l i k e R u b o c o p , F o o d c r i t i c , C h e f s p e c , a n d Te s t K i t c h e n .

#1 Use the Che fDK

C o n t r i b u t o r : A d a m E d w a r d s

I n s t a l l C h o c o l a t e y, C o n E M U a n d P S R e a d L i n e a n d a g o o d t e x t e d i t o r.

G e t a g o o d t e x t e d i t o r ! F r i e n d s d o n ’ t l e t f r i e n d s u s e N o t e p a d .

I n s t a l l t h e C h e f D K a n d a l w a y s u s e P o w e r s h e l l , n o t C M D . e x e

#2 Windows Chef Works ta t ion

C o n t r i b u t o r : A d a m E d w a r d s

I n s t a l l C h o c o l a t e y, C o n E M U a n d P S R e a d L i n e a n d a g o o d t e x t e d i t o r.

G e t a g o o d t e x t e d i t o r ! F r i e n d s d o n ’ t l e t f r i e n d s u s e N o t e p a d .

I n s t a l l t h e C h e f D K a n d a l w a y s u s e P o w e r s h e l l , n o t C M D . e x e

#2 Windows Chef Works ta t ion

C o n t r i b u t o r : J o s h u a T i m b e r m a n

W h e n w r i t i n g S e r v e r S p e c t e s t s y o u c a n h a v e a s i n g l e s h a r e d c o n f i g f i l e f o r a l l y o u r t e s t s .

• C r e a t e a s p e c _ h e l p e r. r b f i l e t o c o n t a i n a l l y o u r s h a r e d s e t t i n g s .

• U p d a t e t h e d a t a _ p a t h s e t t i n g i n y o u r . k i t c h e n . y m l f i l e t o r e a d f r o m t h e d i r e c t o r y w h e r e i t i s s t o r e d .

#3 ServerSpec He lper F i l es

C o n t r i b u t o r : J o s h u a T i m b e r m a n

W h e n w r i t i n g S e r v e r S p e c t e s t s y o u c a n h a v e a s i n g l e s h a r e d c o n f i g f i l e f o r a l l y o u r t e s t s .

• C r e a t e a s p e c _ h e l p e r. r b f i l e t o c o n t a i n a l l y o u r s h a r e d s e t t i n g s .

• U p d a t e t h e d a t a _ p a t h s e t t i n g i n y o u r . k i t c h e n . y m l f i l e t o r e a d f r o m t h e d i r e c t o r y w h e r e i t i s s t o r e d .

#3 ServerSpec He lper F i l es

C o n t r i b u t o r : J u l i a n D u n n

• N o w t h a t s h e l l _ o u t a n d s h e l l _ o u t ! a r e p a r t o f t h e r e c i p e D S L i n C h e f 1 2 , t h e r e ’ s n o e x c u s e t o a b u s e ` b a c k t i c k s ` .

• s h e l l _ o u t ! w i l l e x e c u t e a c o m m a n d o n t h e s y s t e m a n d r a i s e a n e r r o r i f t h e c o m m a n d f a i l s .

• Yo u c a n c a p t u r e s t d o u t a n d s t d e r r w i t h s h e l l _ o u t

• h t t p s : / / d o c s . c h e f . i o / d s l _ r e c i p e . h t m l # s h e l l - o u t

#4 Use M ixL ib : :She l lOut

C o n t r i b u t o r : J u l i a n D u n n

• N o w t h a t s h e l l _ o u t a n d s h e l l _ o u t ! a r e p a r t o f t h e r e c i p e D S L i n C h e f 1 2 , t h e r e ’ s n o e x c u s e t o a b u s e ` b a c k t i c k s ` .

• s h e l l _ o u t ! w i l l e x e c u t e a c o m m a n d o n t h e s y s t e m a n d r a i s e a n e r r o r i f t h e c o m m a n d f a i l s .

• Yo u c a n c a p t u r e s t d o u t a n d s t d e r r w i t h s h e l l _ o u t

• h t t p s : / / d o c s . c h e f . i o / d s l _ r e c i p e . h t m l # s h e l l - o u t

#4 Use M ixL ib : :She l lOut

C o n t r i b u t o r : N e l l S h a m r e l l - H a r r i n g t o n

L o o k i n g o v e r s o m e o n e ' s s h o u l d e r w h i l e t h e y t e a c h y o u t h e i r C h e f w o r k f l o w ?

A s k t h e m t o c a p t u r e t h e i r s e s s i o n u s i n g s c r e e n r e c o r d i n g s o f t w a r e . T h i s w a y y o u c a n r e v i e w e v e r y t h i n g t h e y d i d l a t e r, c o m m a n d b y c o m m a n d .

#5 Record Whi le You Learn

C o n t r i b u t o r : N e l l S h a m r e l l - H a r r i n g t o n

L o o k i n g o v e r s o m e o n e ' s s h o u l d e r w h i l e t h e y t e a c h y o u t h e i r C h e f w o r k f l o w ?

A s k t h e m t o c a p t u r e t h e i r s e s s i o n u s i n g s c r e e n r e c o r d i n g s o f t w a r e . T h i s w a y y o u c a n r e v i e w e v e r y t h i n g t h e y d i d l a t e r, c o m m a n d b y c o m m a n d .

#5 Record Whi le You Learn

C o n t r i b u t o r : A n n M a r i e F r e d

S p i n n i n g u p a v i r t u a l m a c h i n e o r c o n t a i n e r a n d c o n f i g u r i n g i t f r o m s c r a t c h i s e x p e n s i v e .

P r e - i n s t a l l l a r g e p a c k a g e s a n d f i l e s i n y o u r i m a g e s s o t h a t y o u r C I / C D p i p e l i n e c a n q u i c k l y s p i n u p V M s f o r t e s t i n g .

L e a v e s m a l l e r c o n f i g u r a t i o n d e t a i l s f o r C h e f t o t a k e c a r e o f .

# 6 P r e - b a k e d V M s o r C o n t a i n e r s

C o n t r i b u t o r : A n n M a r i e F r e d

S p i n n i n g u p a v i r t u a l m a c h i n e o r c o n t a i n e r a n d c o n f i g u r i n g i t f r o m s c r a t c h i s e x p e n s i v e .

P r e - i n s t a l l l a r g e p a c k a g e s a n d f i l e s i n y o u r i m a g e s s o t h a t y o u r C I / C D p i p e l i n e c a n q u i c k l y s p i n u p V M s f o r t e s t i n g .

L e a v e s m a l l e r c o n f i g u r a t i o n d e t a i l s f o r C h e f t o t a k e c a r e o f .

# 6 P r e - b a k e d V M s o r C o n t a i n e r s

C o n t r i b u t o r : C l a i r e M c Q u i n

E v e r w i s h y o u c o u l d p a u s e a C h e f r u n a n d e x a m i n e w h a t i t ’ s d o i n g m o r e c l o s e l y ? T h e R u b y ‘ p r y ’ g e m a l l o w s y o u t o d o e x a c t l y t h i s .

• A d d t h i s t o t h e t o p o f y o u r r e c i p e : r e q u i r e ‘ p r y ’

• A d d t h i s w h e r e y o u w a n t y o u r b r e a k p o i n t : b i n d i n g . p r y

• A d v a n c e t o t h e n e x t r e s o u r c e w i t h C T R L - D

#7 Troub leshoot w i th P ry

C o n t r i b u t o r : C l a i r e M c Q u i n

E v e r w i s h y o u c o u l d p a u s e a C h e f r u n a n d e x a m i n e w h a t i t ’ s d o i n g m o r e c l o s e l y ? T h e R u b y ‘ p r y ’ g e m a l l o w s y o u t o d o e x a c t l y t h i s .

• A d d t h i s t o t h e t o p o f y o u r r e c i p e : r e q u i r e ‘ p r y ’

• A d d t h i s w h e r e y o u w a n t y o u r b r e a k p o i n t : b i n d i n g . p r y

• A d v a n c e t o t h e n e x t r e s o u r c e w i t h C T R L - D

#7 Troub leshoot w i th P ry

C o n t r i b u t o r : M i c h a e l G o e t z

S o m e t i m e s w e n e e d t o t e m p o r a r i l y s t o r e d a t a d u r i n g a C h e f r u n , b u t d o n o t w i s h t o s t o r e i t i n t h e n o d e o b j e c t .

T h e r u n _ s t a t e i s a p e r f e c t p l a c e t o s t o r e t e m p o r a r y d a t a a n d m a k e i t a v a i l a b l e t o o t h e r r e s o u r c e s i n y o u r C h e f r u n .

h t t p s : / / d o c s . c h e f . i o / r e c i p e s . h t m l # n o d e - r u n - s t a t e

#8 Use run_s ta te to s to re da ta

C o n t r i b u t o r : M i c h a e l G o e t z

S o m e t i m e s w e n e e d t o t e m p o r a r i l y s t o r e d a t a d u r i n g a C h e f r u n , b u t d o n o t w i s h t o s t o r e i t i n t h e n o d e o b j e c t .

T h e r u n _ s t a t e i s a p e r f e c t p l a c e t o s t o r e t e m p o r a r y d a t a a n d m a k e i t a v a i l a b l e t o o t h e r r e s o u r c e s i n y o u r C h e f r u n .

h t t p s : / / d o c s . c h e f . i o / r e c i p e s . h t m l # n o d e - r u n - s t a t e

#8 Use run_s ta te to s to re da ta

C o n t r i b u t o r : F r a n k l i n We b b e r

C o e r c e e v e r y t h i n g i n s t e a d o f c h e c k i n g f o r n i l

i f p a r a m . n i l ? n e x te l s e . . .e n d

p a r a m . t o _ s . c h o m p

#9 Coerce every th ing ins tead o f check ing fo r n i l

C o n t r i b u t o r : M a t t S t r a t t o n

W h e n w r i t i n g C h e f c o d e , u s e a g o o d t e x t e d i t o r w i t h a p r o j e c t d r a w e r o r f i l e b r o w s e r.

M a n y t e x t e d i t o r s h a v e p l u g i n s a v a i l a b l e f o r s y n t a x h i g h l i g h t i n g , a u t o - c o m p l e t i o n , a n d i m p r o v i n g y o u r R u b y s t y l e .

Yo u c a n e v e n r u n l i n t a n d s y n t a x c h e c k e r s f r o m w i t h i n t h e e d i t o r.

#10 P imp My Tex t Ed i to r