Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install cherrypy/tornado from pip only if use_pip is True for salt-api. #151

Merged
merged 1 commit into from
Jul 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ salt:
debug: False
disable_ssl: False

api:
# Installs the latest version of cherrpy/tornado from pip.
use_pip: True

# salt minion config:
minion:

Expand Down
55 changes: 44 additions & 11 deletions salt/api.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,47 @@

{% from "salt/map.jinja" import salt_settings with context %}
{%- set cfg_salt = pillar.get('salt', {}) %}
{%- set cfg_master = cfg_salt.get('master', {}) %}
{%- set use_pip = salt['pillar.get']('salt:api:use_pip', False) %}
include:
- salt.master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary code shuffling

{%- if use_pip %}
- pip.extensions
{%- set cfg_salt = pillar.get('salt', {}) %}
{%- set cfg_master = cfg_salt.get('master', {}) %}
{%- endif %}
salt_api_install:
pkg.installed:
- name: {{ salt_settings['salt_api'] }}
service.running:
- name: {{ salt_settings.get('api_service', 'salt-api') }}
- require:
{%- if use_pip %}
{%- if 'rest_cherrypy' in cfg_master %}
- pip: salt_api_cherrypy
{% elif 'rest_tornado' in cfg_master %}
{%- elif 'rest_tornado' in cfg_master %}
- pip: salt_api_tornado
{% endif %}
{%- endif %}
{%- else %} # if use_pip
{%- if 'rest_cherrypy' in cfg_master %}
- pkg: salt_api_cherrypy
{%- elif 'rest_tornado' in cfg_master %}
- pkg: salt_api_tornado
{%- endif %}
{%- endif %}
- watch:
- pkg: salt-master
- file: salt-master
{%- if use_pip %}
{%- if 'rest_cherrypy' in cfg_master %}
salt_api_cherrypy:
pkg.purged:
- name: {{ salt_settings['python-cherrypy'] }}
pip.installed:
pkg:
- purged
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formula standards say to use

module.function:

notation instead of

module:
  - function

- name: {{ salt_settings['python_cherrypy'] }}
pip:
- installed
- name: cherrypy
- require:
- pkg: salt_api_cherrypy
Expand All @@ -37,11 +51,30 @@ salt_api_cherrypy:
{%- if 'rest_tornado' in cfg_master %}
salt_api_tornado:
pkg.purged:
- name: {{ salt_settings['python-tornado'] }}
pip.installed:
pkg:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

- purged
- name: {{ salt_settings['python_tornado'] }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

salt_settings.python_tornado is standard in this formula (and most newer ones)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm brackets was in there before.

pip:
- installed
- name: tornado
- require:
- pkg: salt_api_tornado
- pkg: pip_extensions
{% endif %}
{%- else %} # if use_pip
{% if 'rest_cherrypy' in cfg_master %}
salt_api_cherrypy:
pkg:
- installed
- name: {{ salt_settings['python_cherrypy'] }}
{% endif %}
{% if 'rest_tornado' in cfg_master %}
salt_api_tornado:
pkg:
- installed
- name: {{ salt_settings['python_tornado'] }}
{% endif %}
{%- endif %}
4 changes: 2 additions & 2 deletions salt/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ salt:
salt_api: salt-api
salt_ssh: salt-ssh

python-cherrypy: python-cherrypy
python-tornado: python-tornado
python_cherrypy: python-cherrypy
python_tornado: python-tornado

master:
gitfs_provider: gitpython
Expand Down