geerlingguy / ansible-role-php

Ansible Role - PHP
https://galaxy.ansible.com/geerlingguy/php/
MIT License
495 stars 441 forks source link

Check install PHP version fails #71

Closed chasingmaxwell closed 8 years ago

chasingmaxwell commented 8 years ago

I'm using drupal-vm and running into this error when running vagrant up.

TASK: [geerlingguy.php | Check the installed version of PHP.] ***************** 
failed: [REDACTED] => {"changed": false, "cmd": "php -r \"echo php_installed_version;\"", "delta": "0:00:00.001369", "end": "2016-01-13 17:45:09.385431", "rc": 127, "start": "2016-01-13 17:45:09.384062", "stdout_lines": [], "warnings": []}
stderr: /bin/sh: 1: php: not found

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/REDACTED/playbook.retry

REDACTED                    : ok=57   changed=25   unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

It looks like the problem may be that the step to install PHP packages is skipped.

TASK: [geerlingguy.php | Ensure PHP packages are installed.] ****************** 
skipping: [REDACTED]

Is there additional information can I provide to help track down this issue?

chasingmaxwell commented 8 years ago

I tried specifying php_install_from_source and then I got a bit farther, but it failed here:

TASK: [geerlingguy.php | Ensure php-fpm is started and enabled at boot (if configured).] *** 
failed: [REDACTED] => {"failed": true}
msg: no service or tool found for: php5-fpm

FATAL: all hosts have already failed -- aborting
geerlingguy commented 8 years ago

Can you post your config.yml (or at least all the php configuration options from it) here?

Also, which OS/box are you using?

chasingmaxwell commented 8 years ago

Absolutely. Here it is:

---
# `vagrant_box` can also be set to geerlingguy/centos6, geerlingguy/centos7,
# geerlingguy/ubuntu1204, parallels/ubuntu-14.04, etc.
vagrant_box: geerlingguy/ubuntu1404
vagrant_user: vagrant
vagrant_synced_folder_default_type: virtualbox

# If you need to run multiple instances of Drupal VM, set a unique hostname,
# machine name, and IP address for each instance.
vagrant_hostname: REDACTED.vm
vagrant_machine_name: REDACTED
vagrant_ip: 0.0.0.0

# Allow Drupal VM to be accessed via a public network interface on your host.
# Vagrant boxes are insecure by default, so be careful. You've been warned!
# See: https://docs.vagrantup.com/v2/networking/public_network.html
vagrant_public_ip: ""

# A list of synced folders, with the keys 'local_path', 'destination', and
# a 'type' of [nfs|rsync|smb] (leave empty for slow native shares). See
# http://docs.drupalvm.com/en/latest/extras/syncing-folders/ for more info.
vagrant_synced_folders:
  # The first synced folder will be used for the default Drupal installation, if
  # build_makefile: is 'true'.
  - local_path: ~/workspace/REDACTED/REDACTED/REDACTED-vm
    destination: /var/www/REDACTED
    type: virtualbox
    create: true

# Memory and CPU to use for this VM.
vagrant_memory: 2048
vagrant_cpus: 2

# The web server software to use. Can be either 'apache' or 'nginx'.
drupalvm_webserver: nginx

# Set this to false if you are using a different site deployment strategy and
# would like to configure 'vagrant_synced_folders' and 'apache_vhosts' manually.
build_makefile: false
drush_makefile_path: /vagrant/drupal.make.yml

# Set this to false if you don't need to install drupal (using the drupal_*
# settings below), but instead copy down a database (e.g. using drush sql-sync).
install_site: false

# Settings for building a Drupal site from a makefile (if 'build_makefile:'
# is 'true').
drupal_major_version: 7
drupal_core_path: "/var/www/REDACTED/build"
drupal_domain: "REDACTED.vm"
drupal_site_name: "Drupal"
drupal_install_profile: standard
drupal_enable_modules: [ 'devel' ]
drupal_account_name: admin
drupal_account_pass: admin
drupal_mysql_user: REDACTED
drupal_mysql_password: REDACTED
drupal_mysql_database: REDACTED

# Additional arguments or options to pass to `drush site-install`.
drupal_site_install_extra_args: []

# Cron jobs are added to the root user's crontab. Keys include name (required),
# minute, hour, day, weekday, month, job (required), and state.
drupalvm_cron_jobs: []
  # - {
  #   name: "Drupal Cron",
  #   minute: "*/30",
  #   job: "drush -r {{ drupal_core_path }} core-cron"
  # }

# Drupal VM automatically creates a drush alias file in your ~/.drush folder if
# this variable is 'true'.
configure_local_drush_aliases: true

# Apache VirtualHosts. Add one for each site you are running inside the VM. For
# multisite deployments, you can point multiple servernames at one documentroot.
# View the geerlingguy.apache Ansible Role README for more options.
apache_vhosts:
  - servername: "{{ drupal_domain }}"
    documentroot: "{{ drupal_core_path }}"

  - servername: "adminer.drupalvm.dev"
    documentroot: "/opt/adminer"

  - servername: "xhprof.drupalvm.dev"
    documentroot: "/usr/share/php/xhprof_html"

  - servername: "pimpmylog.drupalvm.dev"
    documentroot: "/usr/share/php/pimpmylog"

apache_remove_default_vhost: true
apache_mods_enabled:
  - expires.load
  - ssl.load
  - rewrite.load

# Nginx hosts. Each site will get a server entry using the configuration defined
# here. Set the 'is_php' property for document roots that contain PHP apps like
# Drupal.
nginx_hosts:
  - server_name: "{{ drupal_domain }}"
    root: "{{ drupal_core_path }}"
    is_php: true

  - server_name: "adminer.drupalvm.dev"
    root: "/opt/adminer"
    is_php: true

  - server_name: "xhprof.drupalvm.dev"
    root: "/usr/share/php/xhprof_html"
    is_php: true

  - server_name: "pimpmylog.drupalvm.dev"
    root: "/usr/share/php/pimpmylog"
    is_php: true

nginx_remove_default_vhost: true

# MySQL Databases and users. If build_makefile: is true, first database will
# be used for the makefile-built site.
mysql_databases:
  - name: "{{ drupal_mysql_database }}"
    encoding: utf8
    collation: utf8_general_ci

mysql_users:
  - name: "{{ drupal_mysql_user }}"
    host: "%"
    password: "{{ drupal_mysql_password }}"
    priv: "{{ drupal_mysql_database }}.*:ALL"

# Comment out any extra utilities you don't want to install. If you don't want
# to install *any* extras, make set this value to an empty set, e.g. `[]`.
installed_extras:
  # - adminer
  # - drupalconsole
  - mailhog
  - memcached
  # - nodejs
  #- pimpmylog
  - redis
  # - ruby
  - selenium
  - solr
  - varnish
  # - xdebug
  # - xhprof

# Add any extra apt or yum packages you would like installed.
extra_packages:
  - unzip

# `nodejs` must be in installed_extras for this to work.
nodejs_version: "0.12"
nodejs_npm_global_packages: []

# `ruby` must be in installed_extras for this to work.
ruby_install_gems_user: "{{ vagrant_user }}"
ruby_install_gems: []

# You can configure almost anything else on the server in the rest of this file.
extra_security_enabled: false

drush_version: master
drush_keep_updated: true
drush_composer_cli_options: "--prefer-dist --no-interaction"

firewall_allowed_tcp_ports:
  - "22"
  - "25"
  - "80"
  - "81"
  - "443"
  - "4444"
  - "8025"
  - "8080"
  - "8443"
  - "8983"
firewall_log_dropped_packets: false

# PHP Configuration. Currently-supported versions: 5.5, 5.6, 7.0.
php_version: "5.6"
php_memory_limit: "192M"
php_display_errors: "On"
php_display_startup_errors: "On"
php_enable_php_fpm: true
php_realpath_cache_size: "1024K"
php_sendmail_path: "/usr/sbin/ssmtp -t"
php_opcache_enabled_in_ini: true
php_opcache_memory_consumption: "192"
php_opcache_max_accelerated_files: 4096
php_max_input_vars: "4000"
php_install_from_source: true
php_packages:
  - php5-redis

composer_path: /usr/bin/composer
composer_home_path: '/home/vagrant/.composer'
# composer_global_packages:
#   - { name: phpunit/phpunit, release: '@stable' }

# Run specified scripts after VM is provisioned. Path is relative to the
# `provisioning/playbook.yml` file.
post_provision_scripts: []
  # - "../examples/scripts/configure-solr.sh"

# MySQL Configuration.
mysql_root_password: root
mysql_slow_query_log_enabled: true
mysql_slow_query_time: 2
mysql_wait_timeout: 300
adminer_install_filename: index.php

# Varnish Configuration.
varnish_listen_port: "81"
varnish_default_vcl_template_path: templates/drupalvm.vcl.j2
varnish_default_backend_host: "127.0.0.1"
varnish_default_backend_port: "80"

# Pimp my Log settings.
pimpmylog_install_dir: /usr/share/php/pimpmylog
pimpmylog_grant_all_privs: true

# XDebug configuration. XDebug is disabled by default for better performance.
php_xdebug_default_enable: 0
php_xdebug_coverage_enable: 0
php_xdebug_cli_enable: 1
php_xdebug_remote_enable: 1
php_xdebug_remote_connect_back: 1
# Use PHPSTORM for PHPStorm, sublime.xdebug for Sublime Text.
php_xdebug_idekey: PHPSTORM
php_xdebug_max_nesting_level: 256

# Solr Configuration (if enabled above).
solr_version: "4.10.4"
solr_xms: "64M"
solr_xmx: "128M"

# Selenium configuration.
selenium_version: 2.46.0

# Other configuration.
known_hosts_path: ~/.ssh/known_hosts
chasingmaxwell commented 8 years ago

So as far as I can tell, it looks like the second problem I ran into is caused by the fact that --enable-fpm is not included here:

https://github.com/geerlingguy/ansible-role-php/blob/master/defaults/main.yml#L63

So a workaround would be to provide my own php_source_configure_command in config.yml, but I would expect php_enable_php_fpm to cause that flag to be included.

chasingmaxwell commented 8 years ago

It looks like the first issue was my use of php_packages. I didn't realize that was overriding a variable which contained ALL php packages that needed to be installed. I thought it was specifying additional packages to install. Also I probably don't need that line at all now that drupal-vm includes the php-redis role.

geerlingguy commented 8 years ago

Ah yes, that could definitely be the cause; can you see if not overriding php_packages (or including all the other defaults in there) allows everything to work fine?

Also, for installing from source, this role is a little less than optimized, and in the few cases where I'm using the role in that way (mostly for testbeds and general PHP dev work), I have overridden many more of the variables as necessary. The role's laid out to support installing from packages much more easily than source.

chasingmaxwell commented 8 years ago

@geerlingguy yes, my original issue was solved by just removing the php_packages config. php5-redis is installed by default with drupal-vm now anyway.

Also, looking at the readme, the need to change php_source_configure_command is well documented, so that was my oversight.

Thanks for your help!

geerlingguy commented 8 years ago

No problem!

tpitre commented 8 years ago

Hi @geerlingguy, I think I'm experiencing a similar issue with php packages after a vagrant up.

This is where it's failing:

TASK [geerlingguy.php : Ensure PHP packages are installed.] ********************
failed: [drupalvm] => (item=[u'php7.0-common', u'php7.0-cli', u'php7.0-dev', u'php7.0-fpm', u'libpcre3-dev', u'php7.0-gd', u'php7.0-curl', u'php7.0-imap', u'php7.0-json', u'php7.0-opcache', u'php7.0-xml', u'php7.0-mbstring', u'php-sqlite3', u'php-apcu']) => {"failed": true, "item": ["php7.0-common", "php7.0-cli", "php7.0-dev", "php7.0-fpm", "libpcre3-dev", "php7.0-gd", "php7.0-curl", "php7.0-imap", "php7.0-json", "php7.0-opcache", "php7.0-xml", "php7.0-mbstring", "php-sqlite3", "php-apcu"], "msg": "No package matching 'php7.0-common' is available"}

RUNNING HANDLER [geerlingguy.firewall : restart firewall] **********************

RUNNING HANDLER [geerlingguy.apache : restart apache] **************************

RUNNING HANDLER [geerlingguy.mysql : restart mysql] ****************************
    to retry, use: --limit @/Users/tpitre/Sites/outsideonline/vagrant/provisioning/playbook.retry

PLAY RECAP *********************************************************************
drupalvm                   : ok=87   changed=28   unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

And this is my config.yml:

---
# `vagrant_box` can also be set to geerlingguy/centos6, geerlingguy/centos7,
# geerlingguy/ubuntu1204, parallels/ubuntu-14.04, etc.
vagrant_box: geerlingguy/ubuntu1404
vagrant_user: vagrant
vagrant_synced_folder_default_type: nfs

# If you need to run multiple instances of Drupal VM, set a unique hostname,
# machine name, and IP address for each instance.
vagrant_hostname: outside.dev
vagrant_machine_name: drupalvm
vagrant_ip: 192.168.88.88

# Allow Drupal VM to be accessed via a public network interface on your host.
# Vagrant boxes are insecure by default, so be careful. You've been warned!
# See: https://docs.vagrantup.com/v2/networking/public_network.html
vagrant_public_ip: ""

# A list of synced folders, with the keys 'local_path', 'destination', and
# a 'type' of [nfs|rsync|smb] (leave empty for slow native shares). See
# http://docs.drupalvm.com/en/latest/extras/syncing-folders/ for more info.
vagrant_synced_folders:
  # The first synced folder will be used for the default Drupal installation, if
  # build_makefile: is 'true'.
  # The local_path parameter needs to be path to your local's Outside docroot.
  - local_path: ~/Sites/outsideonline/docroot
    destination: /var/www/drupalvm
    type: nfs
    create: true

# Memory and CPU to use for this VM.
vagrant_memory: 1024
vagrant_cpus: 2

# The web server software to use. Can be either 'apache' or 'nginx'.
drupalvm_webserver: apache

# Set this to false if you are using a different site deployment strategy and
# would like to configure 'vagrant_synced_folders' and 'apache_vhosts' manually.
build_makefile: false
drush_makefile_path: /vagrant/drupal.make.yml

# Set this to false if you don't need to install drupal (using the drupal_*
# settings below), but instead copy down a database (e.g. using drush sql-sync).
install_site: false

# Settings for building a Drupal site from a makefile (if 'build_makefile:'
# is 'true').
drupal_major_version: 7
drupal_core_path: "/var/www/drupalvm"
drupal_domain: "{{ vagrant_hostname }}"
drupal_site_name: "Drupal"
drupal_install_profile: standard
drupal_enable_modules: [ 'devel', 'diff', 'stage_file_proxy', 'update', 'views_ui' ]
drupal_account_name: admin
drupal_account_pass: admin
drupal_mysql_user: outsidelocal
drupal_mysql_password: outsidelocal
drupal_mysql_database: outsidelocal

# Additional arguments or options to pass to `drush site-install`.
drupal_site_install_extra_args: []

# Cron jobs are added to the root user's crontab. Keys include name (required),
# minute, hour, day, weekday, month, job (required), and state.
drupalvm_cron_jobs: []
  # - {
  #   name: "Drupal Cron",
  #   minute: "*/30",
  #   job: "drush -r {{ drupal_core_path }} core-cron"
  # }

# Drupal VM automatically creates a drush alias file in your ~/.drush folder if
# this variable is 'true'.
configure_local_drush_aliases: true

# Apache VirtualHosts. Add one for each site you are running inside the VM. For
# multisite deployments, you can point multiple servernames at one documentroot.
# View the geerlingguy.apache Ansible Role README for more options.
apache_vhosts:
  - servername: "{{ vagrant_hostname }}"
    documentroot: "/var/www/drupalvm"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000/var/www/drupalvm"

  - servername: "adminer.{{ vagrant_hostname }}"
    documentroot: "{{ adminer_install_dir }}"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ adminer_install_dir }}"

  - servername: "xhprof.{{ vagrant_hostname }}"
    documentroot: "{{ php_xhprof_html_dir }}"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ php_xhprof_html_dir }}"

  - servername: "pimpmylog.{{ vagrant_hostname }}"
    documentroot: "{{ pimpmylog_install_dir }}"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ pimpmylog_install_dir }}"

apache_remove_default_vhost: true
apache_mods_enabled:
  - expires.load
  - ssl.load
  - rewrite.load
  - proxy.load
  - proxy_fcgi.load

# Nginx hosts. Each site will get a server entry using the configuration defined
# here. Set the 'is_php' property for document roots that contain PHP apps like
# Drupal.
nginx_hosts:
  - server_name: "{{ drupal_domain }}"
    root: "{{ drupal_core_path }}"
    is_php: true

  - server_name: "adminer.{{ vagrant_hostname }}"
    root: "{{ adminer_install_dir }}"
    is_php: true

  - server_name: "xhprof.{{ vagrant_hostname }}"
    root: "{{ php_xhprof_html_dir }}"
    is_php: true

  - server_name: "pimpmylog.{{ vagrant_hostname }}"
    root: "{{ pimpmylog_install_dir }}"
    is_php: true

nginx_remove_default_vhost: true

# MySQL Databases and users. If build_makefile: is true, first database will
# be used for the makefile-built site.
mysql_databases:
  - name: "{{ drupal_mysql_database }}"
    encoding: utf8
    collation: utf8_general_ci

mysql_users:
  - name: "{{ drupal_mysql_user }}"
    host: "%"
    password: "{{ drupal_mysql_password }}"
    priv: "{{ drupal_mysql_database }}.*:ALL"

# Comment out any extra utilities you don't want to install. If you don't want
# to install *any* extras, make set this value to an empty set, e.g. `[]`.
installed_extras:
  - adminer
  - drupalconsole
  - mailhog
  - memcached
  - nodejs
  - pimpmylog
  # - redis
  - ruby
  # - selenium
  # - solr
  #- varnish
  - xdebug
  - xhprof

# Add any extra apt or yum packages you would like installed.
extra_packages:
  - unzip

# `nodejs` must be in installed_extras for this to work.
nodejs_version: "0.12"
nodejs_npm_global_packages: []

# `ruby` must be in installed_extras for this to work.
ruby_install_gems_user: "{{ vagrant_user }}"
ruby_install_gems: []

# You can configure almost anything else on the server in the rest of this file.
extra_security_enabled: false

drush_version: "master"
drush_keep_updated: true
drush_composer_cli_options: "--prefer-dist --no-interaction"

firewall_allowed_tcp_ports:
  - "22"
  - "25"
  - "80"
  - "81"
  - "443"
  - "4444"
  - "8025"
  - "8080"
  - "8443"
  - "8983"
firewall_log_dropped_packets: false

# PHP Configuration. Currently-supported versions: 5.5, 5.6, 7.0.
php_version: "5.6"
php_memory_limit: "192M"
php_display_errors: "On"
php_display_startup_errors: "On"
php_realpath_cache_size: "1024K"
php_sendmail_path: "/usr/sbin/ssmtp -t"
php_opcache_enabled_in_ini: true
php_opcache_memory_consumption: "192"
php_opcache_max_accelerated_files: 4096
php_max_input_vars: "4000"

# Drupal VM defaults to using PHP-FPM with either Apache or Nginx. If you wish
# to instead use Apache + mod_php with an Ubuntu base box, make sure you add
# libapache2-mod-php5 to `extra_packages` elsewhere in this config file.
php_enable_php_fpm: true
php_fpm_listen: "127.0.0.1:9000"

composer_path: /usr/bin/composer
composer_home_path: '/home/vagrant/.composer'
# composer_global_packages:
#   - { name: phpunit/phpunit, release: '@stable' }

# Run specified scripts after VM is provisioned. Path is relative to the
# `provisioning/playbook.yml` file.
post_provision_scripts: []
  # - "../examples/scripts/configure-solr.sh"

# MySQL Configuration.
mysql_root_password: root
mysql_slow_query_log_enabled: true
mysql_slow_query_time: 2
mysql_wait_timeout: 300
adminer_install_filename: index.php

# Varnish Configuration.
varnish_listen_port: "81"
varnish_default_vcl_template_path: templates/drupalvm.vcl.j2
varnish_default_backend_host: "127.0.0.1"
varnish_default_backend_port: "80"

# Pimp my Log settings.
pimpmylog_install_dir: /usr/share/php/pimpmylog
pimpmylog_grant_all_privs: true

# XDebug configuration. XDebug is disabled by default for better performance.
php_xdebug_default_enable: 0
php_xdebug_coverage_enable: 0
php_xdebug_cli_enable: 1
php_xdebug_remote_enable: 1
php_xdebug_remote_connect_back: 1
# Use PHPSTORM for PHPStorm, sublime.xdebug for Sublime Text.
php_xdebug_idekey: PHPSTORM
php_xdebug_max_nesting_level: 256

# Solr Configuration (if enabled above).
solr_version: "4.10.4"
solr_xms: "64M"
solr_xmx: "128M"

# Selenium configuration.
selenium_version: 2.46.0

# Other configuration.
known_hosts_path: ~/.ssh/known_hosts

Any insight here would be appreciated.

geerlingguy commented 8 years ago

@tpitre please see http://docs.drupalvm.com/en/latest/other/php-56/ — there are some other variables that need to be changed to support older PHP versions.