Puppet 无法启动可以手动启动的服务?

Puppet 无法启动可以手动启动的服务?

在 Debian 上,我使用 pserve 为 Pyramid 应用程序编写了一个简单的初始化脚本。我不能 100% 确定它是完整/正确的,但它目前有效:

DAEMON="/home/project/.virtualenvs/project/bin/pserve /home/project/production.ini"
PIDFILE=/home/project/project.pid
USER=project
GROUP=project
CWD=/home/project
LOGFILE=/home/project/project.appserver.log

case "$1" in
  start|stop|restart|status)
    echo "$1 project app server: "
    cd $CWD
    $DAEMON $1 --pid-file=$PIDFILE --user=$USER --group=$GROUP --log-file=$LOGFILE
    RETVAL=$?
    if [ "$RETVAL" -eq "0" ]; then
        echo "Success"
    fi
    ;;
  *)
    echo "Usage: /etc/init.d/project {start|stop|restart|status}"
    exit 1
    ;;
esac

exit 0

当我以 root 身份登录时,我可以毫无问题地运行以下命令:

~# service project start
start project app server: 
Changing user to project:project (200:1001)
Entering daemon mode
Success

我将以下内容放入机器的 Puppet 配置中:

  file { '/etc/init.d/project':
    ensure => present,
    group => 'root',
    mode => 'a=rx,u+w',
    owner => 'root',
    source => 'puppet:///modules/project/project.init',
  }

  service { 'project':
    enable => true,
    ensure => running,
    require => File['/etc/init.d/project'],
  }

但是,当我运行 时puppet agent --test,服务并没有处于运行状态。当我查看项目的日志文件时,我看到以下内容:

...
  File "/home/project/.virtualenvs/project/lib/python2.7/site-packages/project-0.0-py2.7.egg/project/model/__init__.py", line 1, in <module>
    from base import Base, DBSession, initialize_sql
  File "/home/project/.virtualenvs/project/lib/python2.7/site-packages/project-0.0-py2.7.egg/project/model/base.py", line 1, in <module>
    from sqlalchemy import Column, engine_from_config
  File "build/bdist.linux-x86_64/egg/sqlalchemy/__init__.py", line 52, in <module>

  File "build/bdist.linux-x86_64/egg/sqlalchemy/types.py", line 33, in <module>
    except NameError:
  File "build/bdist.linux-x86_64/egg/sqlalchemy/processors.py", line 98, in <module>
  File "build/bdist.linux-x86_64/egg/sqlalchemy/cprocessors.py", line 7, in <module>
  File "build/bdist.linux-x86_64/egg/sqlalchemy/cprocessors.py", line 4, in __bootstrap__
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 882, in resource_filename
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 1351, in get_resource_filename
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 1373, in _extract_resource
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 962, in get_cache_path
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 928, in extraction_error
pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

  [Errno 13] Permission denied: '/root/.python-eggs'

The Python egg cache directory is currently set to:

  /root/.python-eggs

正如我所指出的,以 root 身份登录并启动它似乎工作正常。我猜想 Puppet 也会做类似的事情。缺少什么部分?

答案1

问题在于您的 python egg 缓存,它试图写入根目录。将以下内容添加到您的脚本中。

export PYTHON_EGG_CACHE=/var/tmp

相关内容