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

Create new module anaconda #57908

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
3 participants
@lukepafford
Copy link

commented Jun 16, 2019

SUMMARY

When deploying a python application that installs from anaconda you essentially have to roll your own scripts to create the anaconda environment, and install the necessary packages. It is even more tedious since the conda utility likely won't be in your environment path. This module ensures that the anaconda environment will be created, and the declared packages will be installed. Simple use cases are covered, but It should be easy to add more features if needed.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

lib/ansible/modules/packaging/language/anaconda.py

ADDITIONAL INFORMATION

Example usage for declaring an environment

# Create environment and install dependencies
- name: Create flask project
  anaconda:
    name: flask_project
    packages:
      - flask
      - sqlalchemy
      - gunicorn
      - celery
    channels:
      - conda-forge
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 16, 2019

@Lujeni @dmtrs @fcuny @jle64 @johanwiren @matburt @mattupstate @mwarkentin @shane-walker @thoiberg @tumbl3w33d @turb @verkaufer @xcambar

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@lukepafford lukepafford force-pushed the lukepafford:anaconda branch from 5acd294 to 4388bd5 Jun 17, 2019

Create new module anaconda
The Anaconda module will create an Anaconda environment, and
install the specified packages. This module satisfies the most
common use case that I've come across when trying to idempotently
ensure that a system has a specific environment, with specific
packages installed.

If new features are requested to wrap certain arguments of the conda
utility, then it should be easy to add in.

@lukepafford lukepafford force-pushed the lukepafford:anaconda branch from 4388bd5 to 9c555cf Jun 17, 2019

@ansibot ansibot added the stale_ci label Jun 25, 2019

@beenje

This comment has been minimized.

Copy link

commented Jul 9, 2019

Anaconda is the name of a distribution. I think it would make more sense to name this module "conda" (the name of the tool).

There is already a WIP PR for a conda module: #40455
It's not complete and hasn't been updated since june 2018.

I know of 2 alternate solutions:

I'd really like to see a conda module in Ansible, but it would be nice to agree on an initial version and start from there...

@lukepafford

This comment has been minimized.

Copy link
Author

commented Jul 9, 2019

Unfortunately I didn't know there were other implementations. My module can definitely be ignored and one of the listed modules can be used. As long as something that works gets integrated into Ansible I'm happy.

In the meantime, before I wrote the module I wasn't aware that conda had idempotent functionality built in. I've been using the following shell script pattern to declare that I want an environment to exist

#!/bin/bash
conda=/path/to/conda/exe
"${conda}" env update --verbose ---prefix /path/to/environment --file /path/to/environment_file.yml 2>&1 | grep 'LINKING PACKAGE' --quiet

packageUpdate="$?"
if [[ "${packageUpdated}" -eq 0 ]]; then
    echo "Perform some action on package update"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.