Top Banner
#FrOSCon14 SaltStack meets Foreman 10.08.2019 Bernhard Suttner
34

SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

Jun 29, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

SaltStack meets Foreman

10.08.2019

Bernhard Suttner

Page 2: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#atix #cfgmgmtcamp

SIMPLIFY YOUR DATACENTER

Page 3: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Open Source Automation Days

Page 4: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Foreman

● Open Source project initiated by

Ohad Levy committed on 13 Jul 2009

● Ruby on Rails (and React / JS)

● Puppet ENC / Show reports & facts

➢ ~ 300 contributors➢ ~ 8000 commits➢ ~ 50 plugins

Page 5: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Foreman: features overview

Page 6: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Foreman

Page 7: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

SaltStack

● Open Source project initiated by

Thomas Hatch commited on 13 Feb 2011● Driven by SaltStack Inc, founded Aug 2012● Written in python● Infrastructure as code: yaml + jinja templates● Event driven, full infrastructure management tool

➢ ~ 2250 contributors➢ ~ 106.000 commits➢ ~ 320 formulas

Page 8: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Grains & States → Terminology

Ansible Salt puppet

Facts Grains Facts

Modules Modules Resources

Tasks States Manifests

Roles Formulas Modules

Playbook top.sls Roles/Profiles

Inventory Pillar Hiera

Page 9: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

SaltStack: Flexibility

● Architecture: – Client (= minion) / Server

– Client-less (= salt ssh)

● Modes: – Push: ‘salt’ on Salt Master

– Pull: ‘salt-call’ on Salt Minion

● Event bus: Reactor and Beacons● Scheduled jobs

schedule: highstate: function: state.highstate minutes: 20

Page 10: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

SaltStack: Modular System

Execution modules

State

Grains

Pillar

Returner

Cloud

Beacon

Runner

…. and many more

Page 11: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Foreman & Salt: Scenario

Smart Proxy

Managed Host

foreman_salt

Salt Master

smart_proxy_salt

Salt Minion

REST APIv2 (SSL)

RE

ST

CLI

ZeroMQ (AES)

Page 12: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

foreman_salt: Supported features

Hoststates

Global / Host Group /

HostParameters

Assign Configure

Report

Use pillars

Grains

Runstate.highstate

Salt Key

Accept

Upload

Page 13: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Salt Keys

Page 14: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Import Salt states

Page 15: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Assign Salt states

Page 16: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Salt ENC: pillars

Page 17: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Ready to run salt state.highstate?

Hoststates

Global / Host Group /

HostParameters

Assign Configure

Report

Use pillars

Grains

Runstate.highstate

Salt Key

Accept

Upload

Page 18: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Run Salt by ‘push’

Smart Proxy

Salt Master

smart_proxy_saltManaged Host

Salt Minion

Push state.highstate

OLD: Salt Run via foreman-task (no output)

salt managed.host state.highstate

Page 19: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Run Salt by ‘pull’

Smart Proxy

Salt Master

smart_proxy_saltManaged Host

Salt Minion

NEW: Salt via Remote Execution

salt-call state.highstate

Pull state.highstate

Page 20: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

state.highstate

Page 21: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Salt grains

Page 22: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Salt reports

Page 23: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Page 24: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

WTF, I’m maintainer!

● PR handling● A lot of more tests in foreman_salt● Tests for smart_proxy_salt● Fixes + rubocop

Unit tests

Integration tests

UI tests

Page 25: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Challenge accepted!

Configuring pillar data for Salt states

No Salt Remote Execution Provider

Report upload only every 10 minutes

Be more Salt-like

Page 26: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Need more pillars!

Salt Master Salt Minionstate.highstate

Host params

Host Group params

Global paramsxyz

params

Page 27: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

New: Salt Variables

● Similar to puppet smart class variables / ansible variables● PR: https://github.com/theforeman/foreman_salt/pull/103

Page 28: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Remote Execution

Salt Master

Managed Host

Salt MinionSSH (+ Ansible)

Managed Host

Salt MinionZeroMQREX

NEW!!!

Page 29: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

New: Salt Remote Execution Provider

● Thanks to Adam Růžička● Use salt to execute (every) Remote Execution Job● Run state.highstate on one/multiple Salt Minions

Page 30: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Report, please!

Salt Minion

cronjob

Salt Master state.highstate

upload

collect jobs

Salt Minionstate.highstate

upload

NEW!!!

Reactor

Event

event bus

Salt Master

Smart Proxy

Page 31: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

New: Salt Reactor for uploading reports

● PR: https://github.com/theforeman/smart_proxy_salt/pull/39● Reactor + salt runner module to upload the report to foreman

salt/master cfg snippet

reactor: - 'salt/job/*/ret/*': - /srv/salt/foreman_report_upload.sls

/srv/salt/foreman_report_upload.sls

{% if 'cmd' in data and data['cmd'] == '_return' and 'fun' in data and data['fun'] == 'state.highstate' %}

foreman_report_upload: runner.foreman_report_upload.now: - args: - highstate: '{{data|json}}'

{% endif %}

Page 32: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Be (even) more salt-like

Use the Salt remote execution ecosystem

gitorize everything

Be a (*) salt module

Page 33: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

Links

● https://www.theforeman.org

● https://community.theforeman.org

● https://github.com/ATIX-AG/

● https://github.com/theforeman/foreman/

● https://github.com/theforeman/foreman_salt/

● https://github.com/saltstack/salt/

● https://www.saltstack.com

Page 34: SaltStack meets Foreman · #FrOSCon14 SaltStack Open Source project initiated by Thomas Hatch commited on 13 Feb 2011 Driven by SaltStack Inc, founded Aug 2012 Written in python Infrastructure

#FrOSCon14

sbernhard @ #theforeman-dev

https://github.com/sbernhard

@_sBernhard

[email protected]

Thank you!