Skip to content
Snippets Groups Projects
Commit b19c3acc authored by Tim O'Guin's avatar Tim O'Guin
Browse files

merged with upstream

parents be972d90 e8e01e34
No related branches found
No related tags found
No related merge requests found
Showing
with 804 additions and 344 deletions
......@@ -41,6 +41,59 @@ Install salt cloud.
Install salt-ssh with roster file.
Configure pillar data under salt:ssh_roster to feed the template.
``salt.standalone``
-------------------
Install a minion and configure it in `standalone mode
<http://docs.saltstack.com/en/latest/topics/tutorials/standalone_minion.html>`_.
``salt.pkgrepo``
----------------
Enable the official saltstack package repository in order to always
benefit from the latest version. This state currently only works on Debian
and Ubuntu, and aims to implement the `installation recommendations of the
official documentation
<http://docs.saltstack.com/en/latest/topics/installation/index.html#platform-specific-installation-instructions>`_.
``salt.pkgrepo.absent``
-----------------------
Undo the effects of ``salt.pkgrepo``.
``salt.formulas``
-----------------
Clone selected `Salt formulas
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_
Git repositories under ``/srv/formulas`` and makes them available in the
relevant ``file_roots`` settings. Pillar data can be used to customize all
paths, URLs, etc.
Here's a minimal pillar sample installing two formulas in the base
environment.
::
salt_formulas:
list:
base:
- salt-formula
- openssh-formula
See pillar.example for an exhaustive list of settings available via pillar. Note
that by default this state:
- downloads the latest formulas from the `saltstack-formulas project
<https://github.com/saltstack-formulas>`_ on GitHub.
- does not update the local repositories after the initial clone.
This is a safety measure since you do not control how the official
repositories evolve.
If you configure the state to download the formulas from repositories that
you control, then you can safely enable the
``salt_formulas:git_opts:default:update`` pillar setting to ``True``.
``Configuration``
=================
Every option available in the templates can be set in pillar. Settings under 'salt' will be overridden by more specific settings under ``salt['master']``, ``salt['minion']`` or ``salt['cloud']``
......
......@@ -4,13 +4,22 @@ salt:
- git
- roots
gitfs_remotes:
- git://github.com/saltstack-formulas/salt-formula.git
- git://github.com/saltstack-formulas/salt-formula.git:
- base: develop
file_roots:
base:
- /srv/salt
minion:
master: salt
fileserver_backend:
- git
- roots
gitfs_remotes:
- git://github.com/saltstack-formulas/salt-formula.git:
- base: develop
file_roots:
base:
- /srv/salt
module_config:
test: True
test.foo: foo
......@@ -64,3 +73,41 @@ salt_cloud_certs:
-----BEGIN RSA PRIVATE KEY-----
...........
-----END RSA PRIVATE KEY-----
salt_formulas:
git_opts:
# The Git options can be customized differently for each
# environment, if an option is missing in a given environment, the
# value from "default" is used instead.
default:
# URL where the formulas git repositories are downloaded from
# it will be suffixed with <formula-name>.git
baseurl: https://github.com/saltstack-formulas
# Directory where Git repositories are downloaded
basedir: /srv/formulas
# Update the git repository to the latest version (False by default)
update: False
# Options passed directly to the git.latest state
options:
rev: master
dev:
basedir: /srv/formulas/dev
update: True
options:
rev: develop
# Options of the file.directory state that creates the directory where
# the git repositories of the formulas are stored
basedir_opts:
makedirs: True
user: root
group: root
mode: 755
# List of formulas to enable in each environment
list:
base:
- salt-formula
- postfix-formula
dev:
- salt-formula
- postfix-formula
- openssh-formula
......@@ -10,7 +10,7 @@ pycrypto:
- require:
- pkg: python-pip
{% if grains['os_family'] != 'Debian' %}
{% if grains['os_family'] not in ['Debian', 'RedHat'] %}
crypto:
pip.installed:
- require:
......@@ -28,7 +28,7 @@ salt-cloud:
- require:
- pip: apache-libcloud
- pip: pycrypto
{% if grains['os_family'] != 'Debian' %}
{% if grains['os_family'] not in ['Debian', 'RedHat'] %}
- pip: crypto
{% endif %}
......
# This file is managed by Salt via {{ source }}
make_salty:
- someinstance:
ssh_host: somehost.somedomain
ssh_username: user
password: password
sudo: True
# This file is managed by Salt via {{ source }}
make_salty:
provider: saltify
# This file managed by Salt, do not edit by hand!!
{% set salt = pillar.get('salt', {}) -%}
{% set cloud = salt.get('cloud', {}) -%}
{% set cloud = salt['pillar.get']('salt:cloud', {}) -%}
ec2_ubuntu_public:
minion:
master: {{ cloud['master'] }}
......
# This file managed by Salt, do not edit by hand!!
{% set salt = pillar.get('salt', {}) -%}
{% set cloud = salt.get('cloud', {}) -%}
{% set cloud = salt['pillar.get']('salt:cloud', {}) -%}
gce:
project: "{{ cloud['gce_project'] }}"
service_account_email_address: "{{ cloud['gce_service_account_email_address'] }}"
......
# This file managed by Salt, do not edit by hand!!
# Providers for openstack-based Rackspace cloud servers.
{% set salt = pillar.get('salt', {}) -%}
{% set cloud = salt.get('cloud', {}) -%}
{% set cloud = salt['pillar.get']('salt:cloud', {}) -%}
{% for region in cloud.get('rsos_regions', []) %}
rsos_{{ region|lower }}:
......
# This file is managed by Salt via {{ source }}
saltify:
provider: saltify
This diff is collapsed.
This diff is collapsed.
{% set defaults = {
'baseurl': 'https://github.com/saltstack-formulas',
'basedir': '/srv/formulas',
'update': False,
'options': {},
}
%}
{% set formulas = salt['pillar.get']('salt_formulas:list', {}) %}
{%- macro formulas_git_opt(env, opt) -%}
{%- set value = salt['pillar.get']('salt_formulas:git_opts:{}:{}'.format(env, opt),
salt['pillar.get']('salt_formulas:git_opts:default:{}'.format(opt),
defaults[opt])) -%}
{%- if value is mapping -%}
{{ value|yaml }}
{%- else -%}
{{ value }}
{%- endif -%}
{%- endmacro -%}
{%- macro formulas_roots(env) -%}
{%- set value = [] -%}
{%- for dir in formulas.get(env, []) -%}
{%- do value.append('{}/{}'.format(formulas_git_opt(env, 'basedir'), dir)) -%}
{%- endfor -%}
{{ value|yaml }}
{%- endmacro -%}
{# Generate file_roots config merging standard salt config and list of
enabled formulas #}
{%- macro file_roots(input) -%}
{%- set processed_envs = [] -%}
file_roots:
{%- for name, roots in input|dictsort -%}
{%- do processed_envs.append(name) %}
{{ name }}:
{%- for dir in roots %}
- {{ dir }}
{%- endfor -%}
{%- for dir in formulas_roots(name)|load_yaml %}
- {{ dir }}
{%- endfor -%}
{%- endfor -%}
{%- for name in formulas -%}
{%- if name not in processed_envs %}
{{ name }}:
{%- for dir in formulas_roots(name)|load_yaml %}
- {{ dir }}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{% set processed_gitdirs = [] %}
{% set processed_basedirs = [] %}
{% from "salt/formulas.jinja" import formulas_git_opt with context %}
# Loop over all formulas listed in pillar data
{% for env, entries in salt['pillar.get']('salt_formulas:list').iteritems() %}
{% for entry in entries %}
{% set basedir = formulas_git_opt(env, 'basedir') %}
{% set gitdir = '{}/{}'.format(basedir, entry) %}
{% set update = formulas_git_opt(env, 'update')|load_yaml %}
# Setup the directory hosting the Git repository
{% if basedir not in processed_basedirs %}
{% do processed_basedirs.append(basedir) %}
{{ basedir }}:
file.directory:
{%- for key, value in salt['pillar.get']('salt_formulas:basedir_opts',
{'makedirs': True}).iteritems() %}
- {{ key }}: {{ value }}
{%- endfor %}
{% endif %}
# Setup the formula Git repository
{% if gitdir not in processed_gitdirs %}
{% do processed_gitdirs.append(gitdir) %}
{% set options = formulas_git_opt(env, 'options')|load_yaml %}
{{ gitdir }}:
git.latest:
- name: {{ formulas_git_opt(env, 'baseurl') }}/{{ entry }}.git
- target: {{ gitdir }}
{%- for key, value in options.iteritems() %}
- {{ key }}: {{ value }}
{%- endfor %}
- require:
- file: {{ basedir }}
{%- if not update %}
- unless: test -e {{ gitdir }}
{%- endif %}
{% endif %}
{% endfor %}
{% endfor %}
......@@ -8,6 +8,8 @@ salt-minion:
- template: jinja
- source: salt://salt/files/minion.d
- clean: True
- context:
standalone: False
service.running:
- enable: True
- name: {{ pkgs.get('minion-service', 'salt-minion') }}
......
......@@ -37,6 +37,10 @@
'salt-minion': 'salt',
'salt-syndic': 'salt',
'salt-cloud': 'salt'},
'openSUSE':{'salt-master': 'salt-master',
'salt-minion': 'salt-minion',
'salt-syndic': 'salt-syndic',
'salt-cloud': 'salt-cloud'},
'FreeBSD': {'salt-master': 'py27-salt',
'salt-minion': 'py27-salt',
'salt-syndic': 'py27-salt',
......
include:
- .{{ grains['os']|lower }}.absent
drop-saltstack-pkgrepo:
file.absent:
- name: /etc/apt/sources.list.d/saltstack.list
drop-saltstack-apt-key:
file.absent:
- name: /etc/apt/trusted.gpg.d/saltstack.gpg
saltstack-apt-key:
file.managed:
- name: /etc/apt/trusted.gpg.d/saltstack.gpg
- source: salt://salt/pkgrepo/debian/saltstack.gpg
- user: root
- group: root
- mode: 644
saltstack-pkgrepo:
file.managed:
- name: /etc/apt/sources.list.d/saltstack.list
- source: salt://salt/pkgrepo/debian/sources.list
- user: root
- group: root
- mode: 644
- template: jinja
- require:
- file: saltstack-apt-key
# Order: 1 because we can't put a require_in on "pkg: salt-{master,minion}"
# because we don't know if they are used.
- order: 1
File added
# saltstack
deb http://debian.saltstack.com/debian {{ grains['oscodename'] }}-saltstack main
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment