# activating a conda environment in ansible playbook

**URL:** <https://forum.ansible.com/t/activating-a-conda-environment-in-ansible-playbook/23367>\
**Category:** Ansible Developer\
**Created:** [January 3, 2017, 4:41pm UTC](https://forum.ansible.com/t/activating-a-conda-environment-in-ansible-playbook/23367 "2017-01-03T16:41:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff3](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@Jeff3](https://forum.ansible.com/u/Jeff3)\
**Post date:** [January 3, 2017, 4:41pm UTC](https://forum.ansible.com/t/activating-a-conda-environment-in-ansible-playbook/23367/1 "2017-01-03T16:41:11Z")

</div>

Hello

I am trying to run a list of tasks (here running airflow but it could be anything really) that require to be executed in a existing conda environment. I would like to do sth like this:

tasks:

- name: activate conda environment

# does not work, just for the sake of understanding

command: source activate my\_conda\_env

- name: initialize the database  
command: airflow initdb

- name: start the web server  
command: ‘airflow webserver -p {{ airflow\_webserver\_port }}’

- name: start the scheduler  
command: airflow scheduler

Of course, this does not work as each task is independent and the conda environment activation in the first task is ignored by the following tasks. I guess the issue would be the same if using a python virtualenv instead of conda. How can I achieve each task being runned in the conda environment?

many thanks
