37
Getting to the Latest Puppet 1 Elizabeth Wittig Plumb Senior Technical Account Manager Nate McCurdy Senior Professional Services Engineer

PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

  • Upload
    puppet

  • View
    81

  • Download
    1

Embed Size (px)

Citation preview

Page 1: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Getting to the Latest Puppet

1

Elizabeth Wittig PlumbSenior Technical Account Manager

Nate McCurdySenior Professional Services Engineer

Page 2: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

2

The Breakdown

Why should I upgrade?

What do I need?

Anything else I should know?Walk me through this

– what do I do?

Page 3: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

3

Why Should I upgrade?

Page 4: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

4

Language● Iteration!

● Type system○ Class parameter validation○ Future proof for additional

awesomeness

● Cleaner Puppet code○ No more reliance on stdlib

functions

Other

● All-in-one agent packaging

● New features in Puppet Enterprise

● Stability and scalability

… because Puppet 4 is AWESOME

Page 5: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Puppet Enterprise 3.8 is end-of-life

December 31

5

Page 6: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

6

Ch-Ch-Ch-Ch-Changes

Code Changes

We’ve got a new compiler & new

language features

Directory Changes

The all-in-one agent means we’ve moved some things around

Classification Changes

Do you use theimport( ) function?

Console Changes

Whoa! Look at all those node groups!

https://docs.puppet.com/puppet/latest/reference/lang_updating_manifests.html

Page 7: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

7

in place upgrade < migration

Page 8: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

8

What do I need?

Page 9: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Preview Box, where you’ll make sure the code is ready for the future

Puppet Enterprise latest, your agents will aspire to be here

9

So here’s what you’ve gotta do:

Preview Box:• Puppet Enterprise 3.8 Master• Catalog Preview module installed• r10k (or a copy of your code)• parser = future

Puppet Enterprise2016.4 Master

Puppet Agents

Page 10: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Fast Feedback Loop Doesn’t impact work the agent is doing

Compare your catalogs in Puppet 3 vs 4

Why guess?

A 3.8 master with the catalog preview modulehttps://forge.puppet.com/puppetlabs/catalog_preview

10

What’s a preview box?

Page 11: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

11

Catalog Preview identifies 2 types of issues

~$ puppet preview \

--baseline-environment production \

--preview-environment future_production \

--migrate 3.8/4.0 \

--nodes nodes.txt \

--view overview

Migration Issues

Differences(conflicts)

Page 12: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

12

[root@pe-386-master ~]# /opt/puppet/bin/puppet preview --baseline-environment production --preview-environment future_production --migrate 3.8/4.0 --nodes /vagrant/nodes.txt --view overview Stats Total number of nodes: 10, 100.0% Conflicting..........: 7, 70.0% Compliant............: 0, 0.0% Equal................: 0, 0.0%

Baseline Errors (by manifest) Nodes..: agiledbtest2.example.com, monprod1.example.com Issues.:'Duplicate declaration: File[u01] is already declared in file /etc/puppetlabs/puppet/environments/production/site/example/manifests/oracle.pp:351; cannot redeclare (…snip…)Preview Errors (by manifest)

/etc/puppetlabs/puppet/environments/future_production/site/example/manifests/service-account.pp Nodes..: pocdbtest1.example.com Issues.: ILLEGAL_DEFINTION_NAME: 'Unacceptable name. The name 'example::service-account' is unacceptable as the name of a Host Class Definition' at line 1, column 1Preview Errors (by issue) ILLEGAL_DEFINTION_NAME (1)

/etc/puppetlabs/puppet/environments/future_production/site/example/manifests/service-account.pp:1:1Preview Warnings (by issue) MIGRATE4_AMBIGUOUS_INTEGER (77) /etc/puppetlabs/puppet/environments/future_production/manifests/compliance.pp:90:15 MIGRATE4_EMPTY_STRING_TRUE (21) /etc/puppetlabs/puppet/environments/future_production/site/example/manifests/init.pp:[16:6,21:6,26:6]

Top ten nodes with most issues node name errors warnings diffs --------------------------- -------- -------- -------- agiledbtest2.example.com 1 0 0 monprod1.example.com 1 0 0 pocdbtest1.example.com 1 0 0 obiaappstage2.example.com 0 1 71 obiaapptest1.example.com 0 1 71

Summary

Diff

Overview

Page 13: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

https://github.com/puppetlabs/prosvc-preview_report 13

Page 14: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Common Migration Warnings

14

MIGRATE4_UC_BAREWORD_IS_TYPE

$pkg_name = $::osfamily ? { Redhat => ‘httpd’, Debian => ‘apache2’, }

MIGRATE4_EQUALITY_TYPE_MISMATCH

'1' == 1 # 4x. false, 3x. true'1' <= 1 # 4x. error, 3x. true

MIGRATE4_REVIEW_IN_EXPRESSION

$foo = undef if $foo in [ ‘one’, ‘two’, ‘blue’ ]

Page 15: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

MIGRATE4_EMPTY_STRING_TRUE

15

Page 16: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Differences: This could get messy

--excludes</path/to/excludes.json>

--[no-]diff-array-value

Here are some handy flags to filter out info you don’t care about

16

--[no-]diff-string-numeric

Page 17: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Alright, walk me through this...

17

Page 18: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Directory Environments

18

Page 19: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Workflow Steps: Step 1Get preview box and future infra stood up

19

Page 20: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Workflow Steps: Step 2● Create future_production branch● Enable the future parser

20

Manually

Control Repository

Page 21: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Workflow Steps: Step 3Run “r10k deploy” on preview box

21

[root@pe-386-master]# r10k deploy environment -pv

[INFO] Deploying environment “production”[INFO] Deploying environment “future_production”

Page 22: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Workflow Steps: Step 4Generate first report.

● Run Puppet Preview● Convert JSON to HTML

22

[root@pe-386-master]# puppet preview \

--baseline-environment production \

--preview-environment future_production \

--migrate 3.8/4.0 \

--nodes nodes.txt \

--view overview-json | tee ~/overview.json

[root@pe-386-master]# preview_report.rb \

-f ~/overview.json \

-w ~/preview_report.html

Page 23: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Workflow Steps: Step 5 Find an issue to fix.

Start with any catalog compilation errors, then move to migration warnings / differences

23

Baseline Errors (by manifest) Nodes..: agiledbtest2.example.com Issues.:'Duplicate declaration: File[u01] is already declared in file /etc/puppetlabs/puppet/environments/production/site/example/manifests/oracle.pp:351; cannot redeclare

Page 24: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Workflow Steps: Step 6 Fix the issue.

For simple changes, modify code in future_production

For more complex issues, create a branch off of future_production for that issue

24

Page 25: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Workflow Steps: Step 7 Deploy change to preview box, and run the preview tool again.

Ensure that your issue has been fixed.

25

[root@pe-386-master]# r10k deploy environment -pv

[INFO] Deploying environment “production”[INFO] Deploying environment “future_production”

[root@pe-386-master]# puppet preview \

--baseline-environment production \

--preview-environment future_production \

--migrate 3.8/4.0 \

--nodes nodes.txt \

--view overview-json | tee ~/fix_file_mode.json

[root@pe-386-master]# preview_report.rb \

-f ~/fix_file_mode.json \

-w ~/fix_file_mode.html

Page 26: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Workflow Steps: Step 8 Rinse and repeat

26

Page 27: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

27

NOISE

LEGIT

What?! I can’t hear you!

Page 28: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

But… catalog_preview only solves part of the problem

We’re only testing catalog compilation, not catalog application

28

Page 29: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

29

Page 30: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

30

Page 31: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

We need to test Catalog Application!

● On the new infrastructure!

● Migrate CA certs to new infrastructure

● puppet agent -t --noop--server=new_infra --environment=future_production

● Merge into production when everything’s

fixed31

Page 32: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Anything else I should know?

32

Page 33: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

All this is happening on your diff box, not on your prod systems

33

Don’t worry. Be happy.Catalogs are being compiled using only facts and your code

Page 34: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

There’s 2 ways to get facts on the preview box

Query PuppetDB directly Yaml facts cache

34

puppet master --configprint route_file

Page 35: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

YAML Facts

If you have thousands of nodes, start with a

representative cross section.

35

[root@pe-386-master ~]# puppet master --configprint yamldir/var/opt/lib/pe-puppet/yaml[root@pe-386-master ~]# tree -C /var/opt/lib/pe-puppet/yaml/var/opt/lib/pe-puppet/yaml├── facts│ ├── agileappprod1.example.com.yaml│ ├── agileappprod2.example.com.yaml│ ├── agileappstage1.example.com.yaml│ ├── agileappstage2.example.com.yaml(...)

puppet preview \ --nodes roles.txt

https://github.com/natemccurdy/puppet-upgrade-workplace

Page 36: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet

Upgrade your agents with the puppet_agent module and you’re done!

https://forge.puppet.com/puppetlabs/puppet_agent

36

Page 37: PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Wittig Plumb, Puppet