From eb52bb61440285bd03112fe6da6a8ab1c51c5ee4 Mon Sep 17 00:00:00 2001 From: Elijah Lazkani Date: Sat, 18 Mar 2017 22:21:08 -0400 Subject: [PATCH] Adding a new salt state Fixing the neovim install Tying things together in top --- salty/base/neovim/init.sls | 2 +- salty/base/python_env/init.sls | 30 ++++++++++++++++++++++++++++++ salty/base/python_env/map.jinja | 24 ++++++++++++++++++++++++ salty/base/top.sls | 3 ++- 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 salty/base/python_env/init.sls create mode 100644 salty/base/python_env/map.jinja diff --git a/salty/base/neovim/init.sls b/salty/base/neovim/init.sls index 19ac055..f7ea9c7 100644 --- a/salty/base/neovim/init.sls +++ b/salty/base/neovim/init.sls @@ -12,7 +12,7 @@ neovim-install: {% endif %} # TODO: fix the python for MacOS -{% if grains['os_family'] != 'MacOS' %} +{% if grains['os_family'] == 'Arch' %} python-neovim: pkg.installed: - pkgs: diff --git a/salty/base/python_env/init.sls b/salty/base/python_env/init.sls new file mode 100644 index 0000000..4532916 --- /dev/null +++ b/salty/base/python_env/init.sls @@ -0,0 +1,30 @@ +pip-install: + pkg.installed: + - name: {{ python_env.pip }} + +virtualenv-install: + pip.installed: + - name: {{ python_env.virtualenv }} + - user: {{ grains.user }} + - bin_env: {{ python_env.pip_bin_env }} + - require: + - pkg: pip-install + +virtualenvwrapper-install: + pip.installed: + - name: {{ python_env.virtualenvwrapper }} + - user: {{ grains.user }} + - bin_env: {{ python_env.pip_bin_env }} + - require: + - pip: virtualenv-install + +zsh-virtualenvwrapper: + file.append: + - name: {{ grains.homedir }}/.zshrc + - text: + - "" + - "# Adding virtualenvwrapper python binary path" + - "export VIRTUALENVWRAPPER_PYTHON={{ python_env.python_path }}" + - "" + - "# Sourcing virtualenv" + - "source {{ grains.homedir }}/.local/bin/virtualenvwrapper.sh" diff --git a/salty/base/python_env/map.jinja b/salty/base/python_env/map.jinja new file mode 100644 index 0000000..18e0e11 --- /dev/null +++ b/salty/base/python_env/map.jinja @@ -0,0 +1,24 @@ +{% set python_env = salt['grains.filter_by']({ + 'Debian': { + 'pip': 'python3-pip', + 'pip_bin_env: '/usr/bin/pip3', + 'virtualenv': 'virtualenv', + 'virtualenvwrapper': 'virtualenvwrapper', + 'python_path': '/usr/bin/python3', + }, + 'Arch': { + 'pip': 'python-pip', + 'pip_bin_env: '/usr/bin/pip', + 'virtualenv': 'virtualenv', + 'virtualenvwrapper': 'virtualenvwrapper', + 'python_path': '/usr/bin/python', + }, + 'MacOS': { + 'pip': 'python3', + 'pip_bin_env: '/usr/local/bin/pip3', + 'virtualenv': 'virtualenv', + 'virtualenvwrapper': 'virtualenvwrapper', + 'python_path': '/usr/local/bin/python3', + }, +}, default='Debian' ) %} + diff --git a/salty/base/top.sls b/salty/base/top.sls index b48188a..cc02a04 100644 --- a/salty/base/top.sls +++ b/salty/base/top.sls @@ -1,5 +1,6 @@ base: '*': - git - - neovim - zsh + - python_env + - neovim