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

Advance salt/api.sls, install rest_cherrypy or rest_tornado from pip. #150

Merged
merged 2 commits 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
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Configure pillar data under salt:ssh_roster to feed the template.

Install salt api
Requisite: Configure salt-master with rest_cherrypy or rest_tornado.
Requires: pip.extensions as it installs the latest version from pip.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a huge fan of having an external dependency. What does this buy us? Why can't we just do a pip.installed instead of pulling in an outside state from another formula?

Copy link
Member Author

Choose a reason for hiding this comment

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

salt/api.sls installs the latest version of cherrpy/tornado from pip. As the ones in trusty are outdated.


``salt.standalone``
-------------------
Expand Down
43 changes: 37 additions & 6 deletions salt/api.sls
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
#!jinja|yaml

{% from "salt/map.jinja" import salt_settings with context %}

include:
- salt.master
- pip.extensions

{%- set cfg_salt = pillar.get('salt', {}) %}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct and it matches the style of the rest of the formula.

{%- set cfg_master = cfg_salt.get('master', {}) %}

salt-api:
{% if salt_settings.install_packages %}
salt_api_install:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct. salt_settings.api_service can never be unset (it's in defaults.yaml).

pkg.installed:
- name: {{ salt_settings.salt_api }}
{% endif %}
- name: {{ salt_settings['salt_api'] }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure this line is correct.

service.running:
- name: {{ salt_settings.api_service }}
- name: {{ salt_settings.get('api_service', 'salt-api') }}
- require:
- service: {{ salt_settings.master_service }}
{%- if 'rest_cherrypy' in cfg_master %}
- pip: salt_api_cherrypy
{% elif 'rest_tornado' in cfg_master %}
- pip: salt_api_tornado
{% endif %}
- watch:
- pkg: salt-master
- file: salt-master

{%- if 'rest_cherrypy' in cfg_master %}
salt_api_cherrypy:
pkg.purged:
- name: {{ salt_settings['python-cherrypy'] }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Installing from pip vs from package should be completely optional. Some people have perfectly valid versions of cherrypy in their package manager.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add that feature and make pip.extensions optional (use_pip = True add pip.extensions).

pip.installed:
- name: cherrypy
- require:
- pkg: salt_api_cherrypy
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a circular dependency.

Copy link
Member Author

Choose a reason for hiding this comment

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

No its not, as it requires the pkg salt_api_cherrypy to be purged.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's unnecessary then (Salt operates top-down by default).

- pkg: pip_extensions
{% endif %}

{%- if 'rest_tornado' in cfg_master %}
salt_api_tornado:
pkg.purged:
- name: {{ salt_settings['python-tornado'] }}
pip.installed:
- name: tornado
- require:
- pkg: salt_api_tornado
- pkg: pip_extensions
{% endif %}
3 changes: 3 additions & 0 deletions salt/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ salt:
salt_api: salt-api
salt_ssh: salt-ssh

python-cherrypy: python-cherrypy
python-tornado: python-tornado

master:
gitfs_provider: gitpython

Expand Down