apigee / devportal-kickstart-drupal-ansible-installer

Ansible playbook for installing Apigee Kickstart developer portal for Drupal.
Apache License 2.0
5 stars 6 forks source link

Fix issues wrt installation as a non-root user #13

Closed mhitza closed 1 year ago

mhitza commented 3 years ago

Because the playbook has been tested within a docker container where a root is used as the main account. There have been various locations that required elevation to a privileged user in order to avoid permission denied issues. See #9

Since the time when the playbook has been originally written and now, composer v2 has become the stable version. However, the version of Drupal used seems to be incompatible with this version of composer at this point. Relevant snippet of the error:

TASK [geerlingguy.drupal : Generate Drupal project with composer package in /tmp/composer-project (this may take a while).] ***
...
- drupal/core-project-message 8.8.x-dev requires composer-plugin-api ^1.1 -> found composer-plugin-api[2.0.0] but it does not match the constraint.\n\nYou are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
...

Because of this incompatibility, a separate step has been included to downgrade the installed version of composer to v1.

The container test also has missed a necessary SELinux boolean that would restrict the nginx server from connecting to the PHP-FPM service and MySQL/MariaDB.

geerlingguy.drupal role does not properly set the become_user value when running the composer installation. See related issue https://github.com/geerlingguy/ansible-role-drupal/issues/82 In order to work around this issue, a fork has been made, which implements the fix referenced.

In order to upstream the fix on the geerlingguy.drupal role, the project should be updated to work with Drupal 9.x (if necessary). This switch to Drupal 9.x has not been made as part of the changes, because that would require a switch to PHP 7.3 (CentOS 8 VM currently comes with PHP 7.2 and geerlingguy.php-versions would need to be included).


In order to replicate the issue and test the changes I have spun up a VirtualBox VM via Vagrant with the following Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "centos/8"
  config.vm.network "private_network", ip: "192.168.50.4"
  config.vm.provider "virtualbox" do |v| 
    v.memory = 2048
    v.cpus = 2 
  end 

  config.vm.network "forwarded_port", guest: 80, host: 8080
end

The following hosts.yml file

all:
  children:
    webservers:
      hosts:
        localhost:
          ansible_host: 127.0.0.1
          ansible_port: 2222
          ansible_user: vagrant
    dbservers:
      hosts:
        localhost:
          ansible_host: 127.0.0.1
          ansible_port: 2222
          ansible_user: vagrant

And the following ansible invocation once the VM has been started

$ ansible-playbook -i hosts.yml --private-key .vagrant/machines/default/virtualbox/private_key playbook.yml