This is a fork of https://github.com/kevva/states, though this one probably has been more recently maintained.
I, mohae, do not currently use this repo. I have come to prefer including example pillars. As such the following are currently maintained by me:
Saltbase: A basic server deployment using a masterless minion.
Salted: A multi-environment, multi-role, master-minion salt deployment that can be used as a basis for actual server deployment or for quick usage via Vagrant (includes VagrantFile).
salt-iptables: A salt formula like modular iptables state with pillars. This is not called a formula because I don't follow all of SaltStack's salt formula conventions since I wanted to include all of the pillar examples for this state.
redis-formula-mohae: A formula for redis that is consistent with the Redis quickstart guide.
Odds are, if I'm using a state and I am making a base version of it publicly available, I have either created a separate repo for it, and added its link to the list above, it exists within the Salted repo, or it is a newer repo that can be found on my GitHub as I'm no longer updating this README.
A basic set of Salt Stack states for setting up a server with nginx, PageSpeed, Varnish and much more.
- Make sure you have Salt Stack installed.
- Download or clone the
git repo —
git clone https://github.com/kevva/states.git— into yourstates/folder. - Configure the Pillar data and run:
salt \* state.highstate
All states are controlled with Pillar which makes them very easy to customize.
Sets up a cron job.
user— The name of the user who's crontab needs to be modified. Default isroot.minute— The information to be set into the minute section. Default is*.hour— The information to be set in the hour section. Default is*.daymonth— The information to be set in the day of month section. Default is*.month— The information to be set in the month section. Default is*.dayweek— The information to be set in the day of week section. Default is*.
Example usage:
cron:
date > /tmp/date:
user: root
minute: random
hour: 2A list of ports to open for connections. Example usage:
port_allow:
- 22
- 443
- 80A list of ports to open from specific sources. Example usage:
port_allow_from:
8080:
- 10.0.0.1
- 10.0.0.2
3306:
- 10.0.0.3A list of ports to rate-limit (max 3 hits within 30 seconds). Example usage:
port_limit:
- 22A list of salt minions and their configured states. Example usage:
minions:
foo:
- salt.master
- web
- dev
bar:
- dbConfigures nginx.
worker_processes— How many worker threads to run. Default isauto.worker_rlimit_nofile— Maximum open file descriptors per process. Default is768.worker_connections— Maximum connections per process. Default is640.keepalive— How long to allow each connection to stay idle. Default is20.gzip— Enable or disable gzip compression. Default is'on'.gzip_comp_level— Gzip compression level. Default is5.ssl_certificate— Path to SSL certificate.ssl_certificate_key— Path to SSL certificate key.mail— Enable or disable mail configuration. Default isFalse.
Example usage:
nginx:
worker_processes: auto
worker_rlimit_nofile: 8192
worker_connections: 8000
keepalive: 15
gzip_comp_level: 6
mail: TrueA list of npm packages to install. Example usage:
npm:
- bower
- grunt-cli
- yoA list of filters to enable in PageSpeed. Example usage:
pagespeed:
- combine_javascript
- inline_preview_images
- lazyload_images
- prioritize_critical_css
- sprite_imagesConfigures php.
max_execution_time— The maximum time in seconds a script is allowed to run before it is terminated by the parser. Default is25.max_file_uploads— The maximum number of files allowed to be uploaded simultaneously. Default is20.memory_limit— The maximum amount of memory in bytes that a script is allowed to allocate. Default is256M.post_max_size— The maximum size of post data allowed. Default is50M.upload_max_filesize— The maximum size of an uploaded file. Default is50M.
Example usage:
php:
max_execution_time: 15
max_file_uploads: 50
memory_limit: 512MConfigures php-fpm.
max_children— The maximum number of child processes to be created. Default is50.start_servers— The number of child processes created on startup. Default is10.min_spare_servers— The desired minimum number of idle server processes. Default is5.max_spare_servers— The desired maximum number of idle server processes. Default is20.max_requests— The number of requests each child process should execute before respawning. Default is500.
Example usage:
php-fpm:
max_children: 75
start_servers: 25
min_spare_servers: 10
max_spare_servers: 30
max_requests: 750Configures the redis server.
unix— Whether or not to use Unix sockets. Default isFalse.timeout— How long to allow each connection to stay idle. Default is30.keepalive— Default is20.databases— The amount of databases per server. Default is1.maxclients— Maximum clients allowed. Default is10000.maxmemory— Maximum memory to be used per instance. Default is2mb.maxmemory-policy— Default isvolatile-lru.maxmemory-samples— Default is3.servers— A list of redis instances to create.
Example usage:
redis:
unix: True
timeout: 60
keepalive: 30
servers:
- 6380
- 6381
- 6382
- 6383Configure salt.
master— The address to the salt master server. Default issalt.interface— The address of the interface to bind to. Default is0.0.0.0.state_verbose— Default isFalse.fileserver_backend— Which backend to use. Default isroots.gitfs_remotes— Which git remotes to pull states from.file_roots— Default is/srv/salt/states.pillar_roots— Default is/srv/salt/pillars.
Example usage:
salt:
master: foobar.com
state_verbose: True
fileserver_backend:
- roots
- git
gitfs_remotes:
- https://github.com/kevva/states.gitA list of sites to enable.
default— Make a site the default one. Default isFalse.enable— Whether to enable a site or not. Default isFalse.aliases— A list of site aliases.php— Whether to enable php or not. Default isFalse.magento— Whether to include settings for Magento or not. Default isFalse.wordpress— Whether to include settings for Wordpress or not. Default isFalse.
Example usage:
sites:
foo.com:
default: True
enable: True
aliases:
- www.foo.com
- dev.foo.com
php: True
wordpress: True
bar.com
enable: True
aliases:
- www.bar.com
- foo.bar.comConfigures the system.
timezone— Sets the timezone. Default isEurope/Stockholm.locale— Sets the locale. Default issv_SE.UTF-8.
Example usage:
system:
timezone: Europe/Oslo
locale: en_US.UTF-8Configures twemproxy, also known as nutcracker. It will automatically add the redis servers for you.
listen— Which adress to listen to. Could also be a Unix socket. Default is127.0.0.1.port— Which port to listen to. Default is22121.hash— Default isfnv1a_64.hash_tag— Default is{}.distribution— Default isketama.redis— Whether to listen to redis or memcached. Default is'false'.timeout— The timeout value in msec that we wait for to establish a connection to the server or receive a response from a server. Default is20000.auto_eject_hosts— A boolean value that controls if server should be ejected temporarily when it fails consecutively server_failure_limit times. Default is'false'.server_retry_timeout— Default is30000.server_failure_limit— Default is2.
Example usage:
twemproxy:
listen: /tmp/twemproxy.sock
redis: 'true'
timeout: 100
server_failure_limit: 1Adds and configures users.
home— The path to the home directory. Default is/home/[username].shell— The configured shell. Default is/bin/bash.fullname— Sets the users full name.groups— A list of groups assigned to the user.ssh_auth— A list of SSH keys assigned to the user.
Example usage:
users:
johndoe:
fullname: John Doe
shell: /bin/zsh
groups:
- admin
ssh_auth:
- ssh-rsa 123KJom945+Configures Varnish.
config— The path to the config file. Default is/etc/varnish/default.vcl.listen— Which address Varnish listens to.port— Which port Varnish listens to. Default is80.min_threads— The minimum number of worker threads to start. Default is1.max_threads— The maximum number of worker threads to start. Default is1000.thread_timeout— Idle timeout for worker threads. Default is120.storage_size— Cache file size. Default is1G.
Example usage:
varnish:
config: /etc/varnish/foo.vcl
max_threads: 500
storage_size: 500mb