This session will expand your knowledge of cutting-edge techniques for creating Salt states and formulas. Users will obtain a thorough understanding of how states interact with pillars, as well as map.jinja files. We'll discuss how to make formulas OS agnostic and show how the usage of external pillars combined with a map file can result in formulas that are easy to explain, easy to learn, and easy to update.
7. State Directory Structure
/srv/salt/nginx/init.sls - Installs and starts
service
!
/srv/salt/mysql/client.sls - installs client
!
/srv/salt/mysql/server.sls - installs the server
and starts the service
8. Salt States Can Become Complex
apache:
pkg:
- installed
{% if grains[‘os_family’] == ‘RedHat’ %}
- name: httpd
{% elif grains[‘os_family’] == ‘Debian’ %}
- name: apache2
{% endif %}
26. Merging Maps With Pillars
Multiple pillars further reduce complexity
!
Easy to include several pillars in your top pillar
!
Pillar variables can overwrite map
28. Clear Location of Variables
Where did I miss that conf name change?
!
Did I make sure to update all my requires?
!
Hey, could you modify this value?
29. The Simpler the Better
Works great even if you only have a single OS
!
Easy to hand off
!
Fewer files to manage
33. Writing Formulas Effectively
Think about what is OS based
!
Consider what might need to be expanded
!
Look at how someone else would see your
formula
34. Premade Salt Formulas
Over 75 formulas publicly available
!
Not all formulas require the map
!
Fork it with GIT and modify as needed