Chef infra 使用Chef-Ubuntu12.04升级到php5.6

Chef infra 使用Chef-Ubuntu12.04升级到php5.6,chef-infra,ubuntu-12.04,chef-recipe,cookbook,php-5.6,Chef Infra,Ubuntu 12.04,Chef Recipe,Cookbook,Php 5.6,我正在尝试使用Chef升级到Ubuntu12.04中的php5.6 到目前为止,我已经能够通过一些手动步骤来完成,但是,由于我们使用CI,这并不理想 这是我正在运行的以下配方: #app.rb include_recipe 'project::php' include_recipe 'project::apache2' include_recipe 'project::mod_php5' #php.rb # configure sessions

我正在尝试使用Chef升级到Ubuntu12.04中的php5.6

到目前为止,我已经能够通过一些手动步骤来完成,但是,由于我们使用CI,这并不理想

这是我正在运行的以下配方:

    #app.rb
    include_recipe 'project::php'
    include_recipe 'project::apache2'
    include_recipe 'project::mod_php5'

    #php.rb
    # configure sessions
    # install php
    # include_recipe 'php'
    apt_repository "ondrej-php5_6-#{node[:lsb][:codename]}" do
      uri 'http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu'
      distribution node[:lsb][:codename]
      components [:main]
      keyserver 'keyserver.ubuntu.com'
      key 'E5267A6C'
    end

    #Remove previous packages once
    # You have to manually execute the following command
    # sudo apt-get -q -y remove libapache2-mod-php5
    # otherwise it gives you an error.
    =begin
    package 'libapache2-mod-php5' do
      action :remove
    end

    package 'php-apc' do
      action :remove
    end

    package 'php5-json' do
      action :remove
    end

    package 'php5-common' do
      action :remove
    end

    package 'php5-cli' do
     action :remove
    end

    package 'php5-cgi' do
     action :remove
    end
    =end

    package 'php5' do
      action :upgrade
    end

    package 'php5-json'
    package 'php5-common'
    package 'php5-cli'
    package 'php5-cgi'
    package 'php5-readline'
    package 'php5-apcu'
    package 'php5-curl' do
      action :upgrade
    end
    package 'php5-memcache'
    package 'php5-mysql'
    package 'php5-sqlite'
    package 'php5-intl'
    package 'php5-mcrypt'
    package 'php5-fpm'
    package 'php5-gmp'

    # remove the cron job
    file '/etc/cron.d/php5' do
      action :delete
    end

    #apache2.rb
    #remove apache2.2 to upgrade to 2.4
    service "apache2" do
      action :stop, :immediately
    end

    package 'apache2' do
      action :remove
    end

    package 'apache2-utils' do
      action :remove
    end

    package 'apache2.2-bin' do
      action :remove
    end

    package 'apache2-common' do
     action :remove
    end

    include_recipe 'apache2'

    # apache config
    directory '/etc/php5/apache2'
    template '/etc/php5/apache2/php.ini' do
      source 'php.ini.erb'
      cookbook 'php'
      variables :directives => node[:php][:directives]
      notifies :reload, 'service[apache2]'
    end

    #mod_php5.rb
    package 'libapache2-mod-php5'
这是我在运行chef客户端时遇到的错误

    # Output
    Recipe: project::php
     * apt_repository[ondrej-php5_6-precise] action add
     * execute[install-key E5267A6C] action run (skipped due to not_if)
     * ruby_block[validate-key E5267A6C] action run (skipped due to not_if)
     * file[/var/lib/apt/periodic/update-success-stamp] action nothing (skipped 
       due to action :nothing)
     * execute[apt-cache gencaches] action nothing (skipped due to action  
      :nothing)
     * execute[apt-get update] action nothing (skipped due to action :nothing)
     * file[/etc/apt/sources.list.d/ondrej-php5_6-precise.list] action create (up 
       to date)
     (up to date)
   * apt_package[libapache2-mod-php5] action remove


    ============================================================================
    Error executing action `remove` on resource 'apt_package[libapache2-mod-php5]'
    ============================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '100'
    ---- Begin output of apt-get -q -y remove libapache2-mod-php5 ----
    STDOUT: Reading package lists...
    Building dependency tree...
    Reading state information...
    The following packages will be REMOVED:
      libapache2-mod-php5
    0 upgraded, 0 newly installed, 1 to remove and 7 not upgraded.
    19 not fully installed or removed.
    After this operation, 9694 kB disk space will be freed.
    Setting up php5-common (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    STDERR: perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
        LANGUAGE = "C.UTF-8",
        LC_ALL = (unset),
        LC_CTYPE = "UTF-8",
        LANG = "C.UTF-8"
        are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Configuration file `/etc/cron.d/php5'
     ==> Deleted (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** php5 (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing php5-common (--
    configure):
     EOF on stdin at conffile prompt
    dpkg: dependency problems prevent configuration of php5-json:
     php5-json depends on phpapi-20131226; however:
      Package phpapi-20131226 is not installed.
      Package php5-common which provides phpapi-20131226 is not configured yet.
    dpkg: error processing php5-json (--configure):
     dependency problems - leaving unconfigured
    No apport report written because the error message indicates its a followup 
    error from a previous failure.
    dpkg: dependency problems prevent configuration of php5-cli:
     php5-cli depends on php5-common (= 5.6.18+dfsg-1+deb.sury.org~precise+1); 
     however:
      Package php5-common is not configured yet.
     php5-cli depends on php5-json; however:
      Package php5-json is not configured yet.
    dpkg: error processing php5-cli (--configure):
     dependency problems - leaving unconfigured
    No apport report written because the error message indicates its a followup  
    error from a previous failure.
    dpkg: dependency problems prevent configuration of php5-cgi:
     php5-cgi depends on php5-common (= 5.6.18+dfsg-1+deb.sury.org~precise+1); 
     however:
      Package php5-common is not configured yet.
     php5-cgi depends on php5-cli; however:
      Package php5-cli is not configured yet.
     php5-cgi depends on php5-json; however:
      Package php5-json is not configured yet.
    dpkg: error processing php5-cgi (--configure):
     dependency problems - leaving unconfigured
    No apport report written because MaxReports is reached already
    Errors were encountered while processing:
     php5-common
     php5-json
     php5-cli
     php5-cgi
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    ---- End output of apt-get -q -y remove libapache2-mod-php5 ----
    Ran apt-get -q -y remove libapache2-mod-php5 returned 100

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/project/recipes/php.rb

     23: package 'libapache2-mod-php5' do
     24:   action :remove
     25: end
     26:

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/project/recipes/php.rb:23:in   
    `from_file'

    apt_package("libapache2-mod-php5") do
      package_name "libapache2-mod-php5"
      action [:remove]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :package
      cookbook_name "project"
      recipe_name "php"
    end


    Running handlers:
    Running handlers complete
    Chef Client failed. 3 resources updated in 31 seconds
最后,当我手动运行此命令时:

    sudo apt-get -q -y remove libapache2-mod-php5
对于一些apacheconf文件,我必须用N来回复,在chef中,我没有看到这条消息

    Reading package lists...
    Building dependency tree...
    Reading state information...
    The following packages will be REMOVED:
      libapache2-mod-php5
    0 upgraded, 0 newly installed, 1 to remove and 7 not upgraded.
    19 not fully installed or removed.
    After this operation, 9694 kB disk space will be freed.
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
        LANGUAGE = "en_US:",
        LC_ALL = (unset),
        LC_CTYPE = "UTF-8",
        LANG = "en_US.UTF-8"
        are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory
    Setting up php5-common (5.6.18+dfsg-1+deb.sury.org~precise+1) ...

    Configuration file `/etc/cron.d/php5'
     ==> Deleted (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** php5 (Y/I/N/O/D/Z) [default=N] ? N
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/pdo.ini with new version
    php5_invoke: Enable module pdo for fpm SAPI
    php5_invoke: Enable module pdo for cli SAPI
    php5_invoke: Enable module pdo for cgi SAPI
    php5_invoke: Enable module pdo for apache2 SAPI
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/opcache.ini with new version
    php5_invoke: Enable module opcache for fpm SAPI
    php5_invoke: Enable module opcache for cli SAPI
    php5_invoke: Enable module opcache for cgi SAPI
    php5_invoke: Enable module opcache for apache2 SAPI
    Setting up php5-json (1.3.9-1+deb.sury.org~precise+4) ...
    php5_invoke: Enable module json for fpm SAPI
    php5_invoke: Enable module json for cli SAPI
    php5_invoke: Enable module json for cgi SAPI
    php5_invoke: Enable module json for apache2 SAPI
    Setting up php5-cli (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    update-alternatives: using /usr/bin/phar5 to provide /usr/bin/phar (phar) in 
    auto mode.
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory
    /usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or 
    directory
    /usr/bin/locale: Cannot set LC_ALL to default locale: No such file or 
    directory
    Setting up php5-cgi (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory
    Replacing config file /etc/php5/cgi/php.ini with new version
    Package apache2 is not configured yet. Will defer actions by package php5-cgi.
    (Reading database ... 60536 files and directories currently installed.)
    Removing libapache2-mod-php5 ...
    Setting up php5-fpm (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    Installing new version of config file /etc/php5/fpm/pool.d/www.conf ...
    Installing new version of config file /etc/php5/fpm/php-fpm.conf ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory
    Replacing config file /etc/php5/fpm/php.ini with new version
    php5-fpm start/running, process 28686
    Setting up php5 (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    Setting up apache2 (2.4.16-4+deb.sury.org~precise+4) ...

    Configuration file `/etc/apache2/mods-available/autoindex.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** autoindex.conf (Y/I/N/O/D/Z) [default=N] ? N
    Installing new version of config file /etc/apache2/mods-available/dav_fs.conf 
    ...
    Installing new version of config file /etc/apache2/mods-available/ssl.conf ...
    Installing new version of config file /etc/apache2/mods-
    available/auth_digest.load ...
    Installing new version of config file /etc/apache2/mods-
    available/mime_magic.conf ...
    Installing new version of config file /etc/apache2/mods-
    available/authz_user.load ...

    Configuration file `/etc/apache2/mods-available/alias.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** alias.conf (Y/I/N/O/D/Z) [default=N] ? N

    Configuration file `/etc/apache2/mods-available/deflate.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** deflate.conf (Y/I/N/O/D/Z) [default=N] ? N

    Configuration file `/etc/apache2/mods-available/negotiation.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** negotiation.conf (Y/I/N/O/D/Z) [default=N] ? N
    Installing new version of config file /etc/apache2/mods-available/asis.load 
    Installing new version of config file /etc/apache2/mods-available/ldap.conf 

    Configuration file `/etc/apache2/mods-available/dir.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** dir.conf (Y/I/N/O/D/Z) [default=N] ? N
    Installing new version of config file /etc/apache2/mods-
    available/proxy_balancer.conf ...
    Installing new version of config file /etc/apache2/mods-  
    available/proxy_ftp.conf ...
    Installing new version of config file /etc/apache2/mods-
    available/auth_basic.load ...
    Installing new version of config file /etc/apache2/mods-available/proxy.conf 
    Installing new version of config file /etc/apache2/mods
    available/authz_groupfile.load ...
    Installing new version of config file /etc/apache2/mods-
    available/proxy_balancer.load ...
    Installing new version of config file /etc/apache2/mods-available/userdir.conf 

    Configuration file `/etc/apache2/mods-available/mime.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** mime.conf (Y/I/N/O/D/Z) [default=N] ? N
    Installing new version of config file /etc/apache2/mods-available/cgid.conf 

    Configuration file `/etc/apache2/mods-available/setenvif.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** setenvif.conf (Y/I/N/O/D/Z) [default=N] ? N
    Installing new version of config file /etc/apache2/mods-available/ssl.load ...
    Installing new version of config file /etc/apache2/mods-
    available/reqtimeout.conf ...
    Installing new version of config file /etc/apache2/mods-available/deflate.load 

    Configuration file `/etc/apache2/mods-available/status.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** status.conf (Y/I/N/O/D/Z) [default=N] ? N
    Installing new version of config file /etc/apache2/mods-available/actions.conf 

    Configuration file `/etc/apache2/apache2.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** apache2.conf (Y/I/N/O/D/Z) [default=N] ? N

    Configuration file `/etc/apache2/ports.conf'
     ==> Modified (by you or by a script) since installation.
     ==> Package distributor has shipped an updated version.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
     The default action is to keep your current version.
    *** ports.conf (Y/I/N/O/D/Z) [default=N] ? N
    Installing new version of config file /etc/apache2/envvars ...
    Installing new version of config file /etc/init.d/apache2 ...
    Installing new version of config file /etc/default/apache2 ...
    Installing new version of config file /etc/cron.daily/apache2 ...
    info: Executing deferred 'a2enconf php5-cgi' for package php5-cgi
    Enabling conf php5-cgi.
     * Restarting web server apache2                                                                                                                                                   
    [fail]
     * There are processes named 'apache2' running which do not match your pid 
    file which are left untouched in the name of safety, Please review the 
    situation by hand.
    invoke-rc.d: initscript apache2, action "restart" failed.
    Setting up php5-apcu (4.0.10-1+deb.sury.org~precise+2) ...
    php5_invoke: Enable module apcu for fpm SAPI
    php5_invoke: Enable module apcu for cli SAPI
    php5_invoke: Enable module apcu for cgi SAPI
    Setting up php5-curl (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/curl.ini with new version
    php5_invoke: Enable module curl for fpm SAPI
    php5_invoke: Enable module curl for cli SAPI
    php5_invoke: Enable module curl for cgi SAPI
    Setting up php5-dev (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    Setting up php5-gmp (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/gmp.ini with new version
    php5_invoke: Enable module gmp for fpm SAPI
    php5_invoke: Enable module gmp for cli SAPI
    php5_invoke: Enable module gmp for cgi SAPI
    Setting up php5-intl (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/intl.ini with new version
    php5_invoke: Enable module intl for fpm SAPI
    php5_invoke: Enable module intl for cli SAPI
    php5_invoke: Enable module intl for cgi SAPI
    Setting up php5-mcrypt (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/mcrypt.ini with new version
    php5_invoke: Enable module mcrypt for fpm SAPI
    php5_invoke: Enable module mcrypt for cli SAPI
    php5_invoke: Enable module mcrypt for cgi SAPI
    Setting up php5-memcache (3.0.8-5+deb.sury.org~precise+1) ...
    Setting up php5-mysql (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/mysql.ini with new version
    php5_invoke: Enable module mysql for fpm SAPI
    php5_invoke: Enable module mysql for cli SAPI
    php5_invoke: Enable module mysql for cgi SAPI
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/mysqli.ini with new version
    php5_invoke: Enable module mysqli for fpm SAPI
    php5_invoke: Enable module mysqli for cli SAPI
    php5_invoke: Enable module mysqli for cgi SAPI
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/pdo_mysql.ini with new version
    php5_invoke: Enable module pdo_mysql for fpm SAPI
    php5_invoke: Enable module pdo_mysql for cli SAPI
    php5_invoke: Enable module pdo_mysql for cgi SAPI
    Setting up php5-sqlite (5.6.18+dfsg-1+deb.sury.org~precise+1) ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/sqlite3.ini with new version
    php5_invoke: Enable module sqlite3 for fpm SAPI
    php5_invoke: Enable module sqlite3 for cli SAPI
    php5_invoke: Enable module sqlite3 for cgi SAPI
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Creating config file /etc/php5/mods-available/pdo_sqlite.ini with new version
    php5_invoke: Enable module pdo_sqlite for fpm SAPI
    php5_invoke: Enable module pdo_sqlite for cli SAPI
    php5_invoke: Enable module pdo_sqlite for cgi SAPI
    Setting up php-apc (4.0.10-1+deb.sury.org~precise+2) ...
    Setting up pkg-php-tools (1.21+deb.sury.org~precise+1) ...
    Processing triggers for php5-fpm ...
    php5-fpm stop/waiting
    php5-fpm start/running, process 30932
我可以做些什么来避免和厨师一起手动操作吗。 在生产服务器中,如果包是较旧的版本,那么删除包的最佳方法是什么,因此它只执行一次,
这将适用于php5.3到php5.6和apache2.2到apache2.4

哪个版本的Chef?(显示在输出的顶部)Chef客户端,版本12.7.2哪个版本的Chef?(显示在输出的顶部)Chef客户端,版本12.7.2