Skip to content

dkilcy/saltstack-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Salt tools for bare-metal provisioning

Contents:

  1. Introduction
  2. Lab Infrastructure
  3. Lab Setup
  4. Useful Commands
  5. References

Introduction

This is the reference setup I use in my home lab.

SaltStack (Salt) is used in conjunction with PXE server/kickstart to install and provision multiple bare-metal machines running CentOS. The machines designated as the Salt masters have the OS installed installed manually, and the Salt minions are installed via PXE/kickstart.

Tested against salt 2015.5.10 (Lithium)

Lab Infrastructure

Lab

The MintBox2 machines are Salt masters running CentOS 7 with the MATE desktop. They are also referred to as the workstation machines. They are also the PXE servers, yum mirror, and NTP servers.

The Supermicros are Salt minions running CentOS 7.

Network infrastructure

On the Supermicro 5018-series hardware all 4 interfaces are bonded as bond0 using 802.3ad and LACP mode 4

View the pillar configuration here: pillar/superlab.sls

If you plan to fork the repository, unless you use the exact same hardware and IP addressing scheme you need to change the pillar and other network infrastructure files appropriately. There should be no other hardcoded dependency changes to make.

Lab Setup

  1. Install CentOS 7 on MintBox2
  2. Setup Salt Master and Minion on MintBox2
  3. Setup Git and saltstack-base repository on MintBox2
  4. Run Initial Highstate
  5. Setup PXE Server on MintBox2
  6. Install Supermicros (or other MintBox2) via PXE Server
  7. Run States on Minions

Assigning Roles to Machines

salt '<id>' grains.setvals "{'saltstack-base':{'role':'master'}}"
salt '<id>' grains.setvals "{'saltstack-base':{'role':'minion'}}"

Useful Commands

Debug and output options:

  • Local Version: salt-run manage.versions
  • Output data using pprint: salt 'store1' grains.items --output=pprint
  • Output data using json: salt 'store1' grains.items --output=json
  • Debug level: salt 'store1' --log-level=debug --state-output=mixed state.highstate test=True
  • Verbose: salt -v --log-level=debug --state-output=mixed 'store1' state.highstate test=True

Common commands:

  • Run a command: salt '*' cmd.run 'date'
  • Service restart: salt '*' service.restart ntp
  • View a file: salt '*' cp.get_file_str /etc/hosts
  • Look for a package: salt 'store1' pkg.list_pkgs --output=json | grep ntp
  • Copy a file: salt-cp '*' /local/file /remote/file

State Execution:

  • Force a pillar refresh: salt '*' saltutil.refresh_pillar
  • Sync all: salt '*' saltutil.sync_all
  • Calling Highstate: salt '*' state.highstate

Jobs:

  • Lookup result of a job: salt-run jobs.lookup_jid 20150627120734094928

Help:

  • Show module docstrings: salt 'store1' sys.doc test.ping

Salt Grains

References

About

Bare-metal provisioning using SaltStack on CentOS 7

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages