I'm using ansible for some deployment issues.

I want to do the following:

1. Install virtualenv
2. Activate installed virtual environment
3. Check if I'm in virtual environment

For this purposes I have the following playbook:

    ---
    - hosts: servers
        
      tasks:
        - name: update repository
          apt: update_cache=yes
          sudo: true
    
      tasks:
        - name: install git
          apt: name=git state=latest
          sudo: true
    
      tasks:
        - name: install pip
          apt: name=python-pip state=latest
          sudo: true
    
      tasks:
        - name: installing postgres
          sudo: true
          apt: name=postgresql state=latest
    
      tasks:
        - name: installing libpd-dev
          sudo: true
          apt: name=libpq-dev state=latest
    
      tasks:
        - name: installing psycopg
          sudo: true
          apt: name=python-psycopg2 state=latest
    
      tasks:
        - name: configuration of virtual env
          sudo: true
          pip: name=virtualenvwrapper state=latest
    
      tasks:
        - name: create virtualenv
          command: virtualenv venv
    
      tasks:
        - name: virtualenv activate
          shell: . ~/venv/bin/activate
    
      tasks:
        - name: "Guard code, so we are more certain we are in a virtualenv"
          shell: echo $VIRTUAL_ENV
          register: command_result
          failed_when: command_result.stdout == ""

The problem is that sometimes some tasks are not executed, but they have 
to... For instance in my case the task:

      tasks:
        - name: create virtualenv
          command: virtualenv venv

Is not executed.

But if I will comment 2 last tasks:

      tasks:
        - name: virtualenv activate
          shell: . ~/venv/bin/activate
    
      tasks:
        - name: "Guard code, so we are more certain we are in a virtualenv"
          shell: echo $VIRTUAL_ENV
          register: command_result
          failed_when: command_result.stdout == ""

The previous one works...

Can't get what I'm doing wrong. Can somebody hint me?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e447bd97-72ce-425d-ac7f-512ded00c5d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to