0
我使用ansible來解決某些部署問題。某些任務不能執行
我要做到以下幾點:
- 安裝的virtualenv
- 激活安裝的虛擬環境
- 檢查,如果我在虛擬環境中
就是爲了這個目的,我有以下劇本:
---
- 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 == ""
的問題是,有時有些任務沒有被執行,但他們必須...例如在我的情況的任務:
tasks:
- name: create virtualenv
command: virtualenv venv
不執行。
但是,如果我會評論最後2項任務:
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 == ""
以前的作品之一......
不能讓我在做什麼錯。有人可以暗示我嗎?
您正在重複「任務:」鍵 - 但您只需要一次。 –
@Ramon de la Fuente謝謝) –