我已将脚本更新为以下内容: setup_server.yml
- name: Install python packages
hosts: webservers
user: ubuntu
sudo: yes
tasks:
- name: add nginx ppa
apt_repository:
repo: "ppa:nginx/stable"
- name: install common packages needed for python application development
apt:
name: "{{ item }}"
with_items:
- libpq-dev
- libmysqlclient-dev
- libxml2-dev
- libjpeg62
- libjpeg62-dev
- libfreetype6
- libfreetype6-dev
- zlib1g-dev
- mysql-client
- python-dev
- python-setuptools
- python-imaging
- python-mysqldb
- python-psycopg2
- git-core
- nginx
- name: install pip
easy_install:
name: pip
- name: install various libraries with pip
pip:
name: "{{ item }}"
with_items:
- virtualenv
- supervisor
- uwsgi
- name: symlink imaging library files
file: src=/usr/lib/x86_64-linux-gnu/libfreetype.so dest=/usr/lib/libfreetype.so state=link
- name: symlink imaging library files
file: src=/usr/lib/x86_64-linux-gnu/libz.so dest=/usr/lib/libz.so state=link
- name: symlink imaging library files
file: src=/usr/lib/x86_64-linux-gnu/libjpeg.so.62 dest=/usr/lib/x86_64-linux-gnu/libjpeg.so state=link
- name: symlink imaging library files
file: src=/usr/lib/x86_64-linux-gnu/libjpeg.so dest=/usr/lib/libjpeg.so state=link
- name: remove default nginx site
file: path=/etc/nginx/sites-enabled/default state=absent
- name: write nginx.conf
template: src=templates/nginx.conf dest=/etc/nginx/nginx.conf
- name: create supervisord config folder
file: dest=/etc/supervisor state=directory owner=root
- name: create supervisord config
template: src=templates/supervisord.conf dest=/etc/supervisor/supervisord.conf
- name: create supervisord init script
template: src=templates/supervisord.sh dest=/etc/init.d/supervisord mode=0755
- name: start supervisord service and have it run during system startup
service: name=supervisord state=started enabled=yes
- name: create webapps directory
file: dest=/srv/webapps state=directory
和: deploy.yml
- name: Setup webser
hosts: webservers
user: ubuntu
sudo: True
vars:
app_name: hello_flask
repo_url: https://github.com/mattupstate/ansible-tutorial.git
repo_remote: origin
repo_version: master
webapps_dir: /srv/webapps
wsgi_file: wsgi.py
wsgi_callable: app
tasks:
- name: ensure log directory
file: path={{ webapps_dir }}/{{ app_name }}/log state=directory mode=0755
- name: deploy code from repository
synchronize: src=/Users/ankitjain/dev/virel/ansible-tutorial/ dest={{ webapps_dir }}/{{ app_name }}/src archive=yes delete=yes rsync_opts="--exclude='tags' --exclude='.git' --exclude='*.swp'" rsync_path='sudo rsync'
- name: install dependencies into virtualenv
pip: requirements={{ webapps_dir }}/{{ app_name }}/src/requirements.txt virtualenv={{ webapps_dir }}/{{ app_name }}/venv state=present
- name: create supervisor program config
template: src=templates/supervisor.ini dest=/etc/supervisor/{{ app_name }}.ini
notify:
- restart app
- name: create nginx site config
template: src=templates/nginx_site.conf dest=/etc/nginx/sites-available/{{ app_name }}.conf
notify:
- restart nginx
- name: link nginx config
file: src=/etc/nginx/sites-available/{{ app_name }}.conf dest=/etc/nginx/sites-enabled/{{ app_name }}.conf state=link
- name: start app
supervisorctl: name={{ app_name }} state=started
handlers:
- name: restart app
supervisorctl: name={{ app_name }} state=restarted
- name: restart nginx
service: name=nginx state=restarted
如果我在本地运行它,我已经验证了源工作正常。它与所有变量一起正确复制。主管正常运行。所以nginx配置设置正确,我可以直接启动它的网络服务器。
但是主管无法启动网络服务器。我收到以下错误: hello_flask:ERROR(异常终止)
我不确定如何调试
答案 0 :(得分:1)
通过SSH登录服务器
手动使用管理员启动该过程。主管文件:http://supervisord.org/
如果需要,可以通过管理主管配置文件使主管输出stdout和stderr文件,您可以准备好看看应用程序在通过主管启动时打印出的错误消息