diff --git a/.github/workflows/devshop.yml b/.github/workflows/devshop.yml index b3673bb3c5..68ae305e4b 100644 --- a/.github/workflows/devshop.yml +++ b/.github/workflows/devshop.yml @@ -114,11 +114,15 @@ jobs: - name: "Launch devshop/server:latest container" working-directory: docker run: | - docker-compose up --detach devshop.server + docker-compose up --detach sleep 3 docker-compose logs docker-compose exec -T devshop.server /usr/share/devshop/scripts/devshop-logo "GitHub Actions Container populated with code. Running SHA ${GITHUB_PR_SHA}" + - name: "Git Status" + working-directory: docker + run: git status + - name: "Review Container Environment" working-directory: docker run: | @@ -135,6 +139,7 @@ jobs: # Since the container is launched with a new DEVSHOP_DOCKER_COMMAND_RUN, run the default. run: | docker-compose exec -T devshop.server bash -c '${DEFAULT_DEVSHOP_DOCKER_COMMAND_RUN}' + docker-compose exec -T devshop.remote bash -c '${DEFAULT_DEVSHOP_DOCKER_COMMAND_RUN}' - name: "Test DevShop" working-directory: docker diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0dabb8f4d5..b27f99c1d9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -8,9 +8,10 @@ on: branches: # This workflow will only run on pull requests for branch test/docker/actions. - test/docker/actions - push: - branches: - - 1.x +# @TODO: All builds are failing. Uncomment once this is fixed. +# push: +# branches: +# - 1.x schedule: - cron: "10 1 * * 0" diff --git a/.gitignore b/.gitignore index 3d98844350..6c63d62f48 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ src/DevShop/Control/web .vagrant devmaster_id_rsa.pub +vars.local.yml + # Ignore bin dir, except for devshop CLI. # @TODO: Move CLI to a component, so we can ignore the entire folder. bin/* diff --git a/RoboFile.php b/RoboFile.php index 8b72576eb7..e4df23678d 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -577,7 +577,7 @@ public function up($docker_command = '', $opts = [ $test_command = "/usr/share/devshop/tests/devshop-tests-upgrade.sh"; } else { - $cmd[] = "docker compose up --detach devshop.server"; + $cmd[] = "docker compose up --detach"; if (!$opts['no-follow']) { $cmd[] = "docker-compose logs -f"; } @@ -622,8 +622,14 @@ public function up($docker_command = '', $opts = [ // Process $extra vars into JSON for ENV var. $env_run['ANSIBLE_EXTRA_VARS'] = json_encode($extra_vars); + // Include an extra local vars file. + // Load Public SSH key from user to pass to devshop.remote authorized keys. + $vars_file_local = "aegir_user_authorized_keys: " . file_get_contents(getenv('HOME') . "/.ssh/id_rsa.pub"); + + file_put_contents('vars.local.yml', $vars_file_local); + // Add vars.development.yml as final command line option. - $env_run['ANSIBLE_PLAYBOOK_COMMAND_OPTIONS'] = '--extra-vars=@/usr/share/devshop/vars.development.yml'; + $env_run['ANSIBLE_PLAYBOOK_COMMAND_OPTIONS'] = '--extra-vars=@/usr/share/devshop/vars.development.yml --extra-vars=@/usr/share/devshop/vars.local.yml'; // Override the DEVSHOP_DOCKER_COMMAND_RUN if specified. if (!empty($docker_command)) { @@ -786,13 +792,13 @@ public function restart() { /** * Enter a bash shell in the devmaster container. */ - public function shell($user = 'aegir') { + public function shell($user = 'aegir', $service = 'devshop.server') { if ($user) { - $process = new \Symfony\Component\Process\Process("docker-compose exec --user $user devshop.server bash"); + $process = new \Symfony\Component\Process\Process("docker-compose exec --user $user $service bash"); } else { - $process = new \Symfony\Component\Process\Process("docker-compose exec devshop.server bash"); + $process = new \Symfony\Component\Process\Process("docker-compose exec $service bash"); } $process->setTty(TRUE); $process->setTimeout(NULL); diff --git a/docker/Dockerfile.remote b/docker/Dockerfile.remote new file mode 100644 index 0000000000..d5a87b1208 --- /dev/null +++ b/docker/Dockerfile.remote @@ -0,0 +1,18 @@ +# +# DevShop Remote Server container +# +FROM devshop/server:latest + +LABEL maintainer="Jon Pugh" + +RUN echo "Building container from Dockerfile.remote, from $DEVSHOP_CONTAINER_FROM ..." +RUN apt-get install openssh-server -y +RUN service mysql start && mysql -e "GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" +RUN rm -rf ${DEVSHOP_ANSIBLE_PATH}/hosts && ln -s ${DEVSHOP_PATH}/roles/devshop.server/inventory.remote ${DEVSHOP_ANSIBLE_PATH}/hosts + +#ENV DEVSHOP_DOCKER_COMMAND_RUN "" + +ENTRYPOINT /usr/share/devshop/docker/bin/docker-systemd-entrypoint +#CMD "" + +RUN devshop-logo 'DevShop Remote Server container build finished.' diff --git a/docker/docker-compose.override.yml b/docker/docker-compose.override.yml index 0a6b3c7da8..4bb64fbb38 100644 --- a/docker/docker-compose.override.yml +++ b/docker/docker-compose.override.yml @@ -10,5 +10,11 @@ services: - ../:/usr/share/devshop - ../aegir-home:/var/aegir - $HOME/.ssh:/var/aegir/.ssh + environment: + - XDEBUG_CONFIG="remote_host=172.17.0.1 idekey=PHPSTORM" + + devshop.remote: + volumes: + - ../:/usr/share/devshop environment: - XDEBUG_CONFIG="remote_host=172.17.0.1 idekey=PHPSTORM" \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 15d579fbab..120f5153d2 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -4,21 +4,22 @@ version: '3' services: devshop.server: image: ${DEVSHOP_DOCKER_IMAGE:-devshop/server:php8.1} - build: - context: ".." - dockerfile: "docker/Dockerfile.${OS:-ubuntu2004}" - args: - # see .env files for defaults. - - DEVSHOP_CONTAINER_FROM - - DEVSHOP_DOCKER_COMMAND_BUILD_ARG - - ANSIBLE_EXTRA_VARS_ARG - - ANSIBLE_TAGS_ARG - - ANSIBLE_PLAYBOOK_COMMAND_OPTIONS_ARG +# Builds Break. We must upgrade to ubuntu 20 +# build: +# context: ".." +# dockerfile: "docker/Dockerfile.${OS:-ubuntu2004}" +# args: +# # see .env files for defaults. +# - DEVSHOP_CONTAINER_FROM +# - DEVSHOP_DOCKER_COMMAND_BUILD_ARG +# - ANSIBLE_EXTRA_VARS_ARG +# - ANSIBLE_TAGS_ARG +# - ANSIBLE_PLAYBOOK_COMMAND_OPTIONS_ARG hostname: devshop.local.computer ports: - "80:80" - "443:443" - - "2222:22" +# - "2222:22" - "33066:3306" privileged: true entrypoint: /usr/share/devshop/docker/bin/docker-systemd-entrypoint @@ -43,3 +44,28 @@ services: - DEVSHOP_TESTS_ARTIFACTS_PATH # Setting this ensures the docker containers have this value, regardless if the container is an older image. - DEVSHOP_ANSIBLE_GROUP_NAME=devshop_server + + devshop.remote: + image: devshop/remote:latest + build: + context: ".." + dockerfile: "docker/Dockerfile.remote" + hostname: remote.local.computer + ports: + - "8080:80" + - "4433:443" + - "2222:22" +# - "33066:3306" + privileged: true + volumes: + - /var/lib/mysql + - ../:/usr/share/devshop + command: + - "devshop-ansible-playbook" + entrypoint: /usr/share/devshop/docker/bin/docker-systemd-entrypoint + environment: + DEVSHOP_DOCKER_COMMAND_RUN: "echo 'Welcome to devshop.remote container.'" + DEVSHOP_ANSIBLE_GROUP_NAME: devshop_remote + ANSIBLE_EXTRA_VARS: + ANSIBLE_PLAYBOOK_COMMAND_OPTIONS: + diff --git a/roles/devshop.server/inventory.remote b/roles/devshop.server/inventory.remote new file mode 100644 index 0000000000..fd7464fe4c --- /dev/null +++ b/roles/devshop.server/inventory.remote @@ -0,0 +1,10 @@ +--- +# DevShop Ansible Static Inventory File +# ------------------------------------- + +devshop_remote: + hosts: + devshop.remote: + + vars: + ansible_connection: local \ No newline at end of file diff --git a/roles/devshop.server/play.yml b/roles/devshop.server/play.yml index f7f9e4e8ad..c33c21d0cb 100644 --- a/roles/devshop.server/play.yml +++ b/roles/devshop.server/play.yml @@ -129,3 +129,60 @@ # Always run everything. Tags inside the roles will limit tasks run. - role: opendevshop.devmaster tags: [always] + +- hosts: devshop_remote + become: true + + # These vars override everything except command line variables. Set variables per host in the inventory or vars files in /etc/ansible. + # See https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable + vars: + devshop_server_role: 'devshop.server' + aegir_user_name: aegir + + # Set these in local inventory. + aegir_remote_database_user: remote_root + aegir_remote_database_password: password + aegir_user_authorized_keys: "" + + vars_files: + - ../../vars.yml + + tasks: + - name: "devshop.remote" + debug: + msg: + - "DevShop Remote Server Playbook begin..." + tags: [ always ] + + - name: Install OpenSSH Server + apt: + pkg: + - "openssh-server" + state: present + update_cache: true + tags: [ always ] + when: ansible_os_family == "Debian" + + - name: Ensure MySQL is started and enabled on boot. + service: "name=mysql state=started enabled=true" + tags: [ runtime ] + + - name: Grant mysql user access from any server. + mysql_user: + name: "{{ aegir_remote_database_user }}" + host: "%" + password: "{{ aegir_remote_database_password }}" + priv: "*.*:ALL,GRANT" + tags: [ runtime ] + + # @TODO Add authorized_keys + - name: Ensure authorized_keys for DevShop Server user account is present. + authorized_key: + user: "{{ aegir_user_name }}" + key: "{{ aegir_user_authorized_keys }}" + manage_dir: yes + tags: [ runtime ] + when: + - aegir_user_authorized_keys | length > 0 + + # @TODO Add authorized_keys diff --git a/roles/opendevshop.devmaster/tasks/config-devmaster.yml b/roles/opendevshop.devmaster/tasks/config-devmaster.yml index 37da662774..a043e06074 100644 --- a/roles/opendevshop.devmaster/tasks/config-devmaster.yml +++ b/roles/opendevshop.devmaster/tasks/config-devmaster.yml @@ -1,9 +1,12 @@ --- -- name: Clear drush caches - command: "{{ drush_executable_path }} cc drush" - become: true - become_user: "{{ aegir_user_name }}" - become_method: "{{ ansible_become_method_aegir }}" +# Trying to solve https://github.com/opendevshop/devshop/actions/runs/5546470029/jobs/10126861378?pr=752#step:12:2470 +# Error: localhost failed | msg: non-zero return code | stderr: Command hosting-tasks needs the following extension(s) enabled to [error] +#run: hosting. +#- name: Clear drush caches +# command: "{{ drush_executable_path }} cc drush" +# become: true +# become_user: "{{ aegir_user_name }}" +# become_method: "{{ ansible_become_method_aegir }}" - name: DevShop Control | Save GitHub Token become: true @@ -93,8 +96,16 @@ # become_user: "{{ aegir_user_name }}" # become_method: "{{ ansible_become_method_aegir }}" # -#- name: Clear drush caches -# command: "{{ drush_executable_path }} cc drush" -# become: true -# become_user: "{{ aegir_user_name }}" -# become_method: "{{ ansible_become_method_aegir }}" +# Trying to solve https://github.com/opendevshop/devshop/actions/runs/5546571307/jobs/10127031820?pr=752#step:13:165 +# + #Error: nable to load https_apache driver for the http service: Expecting [error] + # class Provision_Service_http_https_apache + #Warning: efined array key "http" server.php:125 [warning] + #Error: rush command terminated abnormally due to an unrecoverable error. [error] + # Error: Uncaught Error: Call to a member function setContext() on null + # in +- name: Clear drush caches + command: "{{ drush_executable_path }} cc drush" + become: true + become_user: "{{ aegir_user_name }}" + become_method: "{{ ansible_become_method_aegir }}" diff --git a/roles/opendevshop.users/defaults/main.yml b/roles/opendevshop.users/defaults/main.yml index ea3c490f90..1873ab9707 100644 --- a/roles/opendevshop.users/defaults/main.yml +++ b/roles/opendevshop.users/defaults/main.yml @@ -8,7 +8,7 @@ aegir_user_force_set_uid: false aegir_user_name: aegir aegir_user_home: /var/aegir -aegir_user_authorized_keys: ReplaceAtRuntime +aegir_user_authorized_keys: "" aegir_logs_path: /var/log/aegir # Populated in prepare-user.yml diff --git a/scripts/devshop-ansible-playbook b/scripts/devshop-ansible-playbook index 0920aa672b..83e9f260cf 100755 --- a/scripts/devshop-ansible-playbook +++ b/scripts/devshop-ansible-playbook @@ -22,7 +22,7 @@ if [ -f "${DEVSHOP_PATH}/${ANSIBLE_PLAYBOOK}" ]; then ANSIBLE_PLAYBOOK="${DEVSHOP_PATH}/${ANSIBLE_PLAYBOOK}" fi -ANSIBLE_PLAYBOOK=${ANSIBLE_PLAYBOOK:-"/etc/ansible/play.yml"} +ANSIBLE_PLAYBOOK=${ANSIBLE_PLAYBOOK:-"$DEVSHOP_PATH/roles/devshop.server/play.yml"} ANSIBLE_CONFIG=${ANSIBLE_CONFIG:-""} ANSIBLE_TAGS=${ANSIBLE_TAGS:-""} ANSIBLE_SKIP_TAGS=${ANSIBLE_SKIP_TAGS:-""} @@ -46,6 +46,7 @@ fi ON_FAIL=${ON_FAIL:-"systemctl status --no-pager"} +cd $DEVSHOP_PATH devshop-logo "Checking Ansible Inventory for group '$DEVSHOP_ANSIBLE_GROUP_NAME' ..." echo "> Contents of /etc/ansible/hosts:" cat /etc/ansible/hosts diff --git a/src/DevShop/Console/Application.php b/src/DevShop/Console/Application.php index 41f213317a..19881a12a2 100644 --- a/src/DevShop/Console/Application.php +++ b/src/DevShop/Console/Application.php @@ -150,7 +150,6 @@ public function __construct($version, $release_date) $this->devmaster_version = '0.5 or earlier'; } - $this->devmaster_platform = $aliases['hostmaster']['platform']; $this->devmaster_root = $aliases['hostmaster']['root']; $this->devmaster_uri = $aliases['hostmaster']['uri']; } diff --git a/src/DevShop/Control/composer.lock b/src/DevShop/Control/composer.lock index b4b0eaff5b..3cfca18315 100644 --- a/src/DevShop/Control/composer.lock +++ b/src/DevShop/Control/composer.lock @@ -2669,7 +2669,7 @@ "source": { "type": "git", "url": "https://git.drupalcode.org/project/hosting.git", - "reference": "891e53f1ca1357aea7e9c4f44c534539192c528b" + "reference": "895a34492476e11c05c2e1992a481f1fed3c143b" }, "require": { "drupal/drupal": "~7.0", @@ -2700,8 +2700,8 @@ "dev-4.x": "4.x-dev" }, "drupal": { - "version": "7.x-4.0-beta5+6-dev", - "datestamp": "1689116853", + "version": "7.x-4.0-beta5+7-dev", + "datestamp": "1689348569", "security-coverage": { "status": "not-covered", "message": "Dev releases are not covered by Drupal security advisories." @@ -3515,7 +3515,7 @@ "source": { "type": "git", "url": "https://git.drupalcode.org/project/provision.git", - "reference": "12a46246284d73a5a93a1b19d0cfbf34bca2d430" + "reference": "88f14b9394b4ddcbc3191aeb33776d96b2a92e8e" }, "require": { "devshop/git-traits": "1.x-dev", @@ -3534,8 +3534,8 @@ "dev-4.x": "4.x-dev" }, "drupal": { - "version": "7.x-4.0-beta7+6-dev", - "datestamp": "1687989630", + "version": "7.x-4.0-beta7+13-dev", + "datestamp": "1689287209", "security-coverage": { "status": "not-covered", "message": "Dev releases are not covered by Drupal security advisories." diff --git a/src/DevShop/Control/scripts/composer/ScriptHandler.php b/src/DevShop/Control/scripts/composer/ScriptHandler.php index 9bbba45e32..9f010f626c 100644 --- a/src/DevShop/Control/scripts/composer/ScriptHandler.php +++ b/src/DevShop/Control/scripts/composer/ScriptHandler.php @@ -87,10 +87,10 @@ public static function createRequiredFiles(Event $event) { } } - // @TODO: Detect non-provision composer installs and continue through the "standard" settings.php file setup. - // This will probably have to be done to allow alternative hosts for "devshop control" sites. - $event->getIO()->warning("Skipping settings.php setup. Provision will configure the files."); - return; +// // @TODO: Detect non-provision composer installs and continue through the "standard" settings.php file setup. +// // This will probably have to be done to allow alternative hosts for "devshop control" sites. +// $event->getIO()->warning("Skipping settings.php setup. Provision will configure the files."); +// return; // Prepare the settings file for installation if (!$fs->exists($drupalRoot . '/sites/default/settings.php') && $fs->exists($drupalRoot . '/sites/default/default.settings.php')) { diff --git a/src/DevShop/Control/tests/features/letsencrypt.feature b/src/DevShop/Control/tests/features/letsencrypt.feature index f6003029ba..944cb3b8e4 100644 --- a/src/DevShop/Control/tests/features/letsencrypt.feature +++ b/src/DevShop/Control/tests/features/letsencrypt.feature @@ -13,6 +13,7 @@ Feature: DevShop Servers have LetsEncrypt enabled out of the box. Then I select the radio button "LetsEncrypt" Then I select the radio button "Staging" And I press "Save" + When I run drush "cache-clear drush" When I run drush "hosting-tasks --force --fork=0 --strict=0" Then I click "Edit" diff --git a/tests/devshop-tests.sh b/tests/devshop-tests.sh index 149779cb4b..c3ef4009cf 100755 --- a/tests/devshop-tests.sh +++ b/tests/devshop-tests.sh @@ -5,6 +5,10 @@ PATH="$DEVSHOP_PATH:$PATH" devshop-logo "Running DevShop Tests" devshop-log echo "Path: $PATH" + +cd /usr/share/devshop +git status +git show devshop status # Print the lines and exit if a failure happens. @@ -12,6 +16,9 @@ devshop-log "Checking versions of devshop, drush, node, npm..." devshop-log "DevShop Version: $(devshop --version)" devshop-log "Drush Version: $(drush --version)" +echo "Drush RC: " +cat ~/.drush/drushrc.php + #echo "Node Version: " && node --version #echo "NPM Version: " && npm --version @@ -30,10 +37,10 @@ drush @hostmaster vset hosting_queue_tasks_enabled 0 #PLATFORM_ALIAS=`drush @hm php-eval "print d()->platform->name"` #drush @hostmaster hosting-task $PLATFORM_ALIAS verify --fork=0 --strict=0 --force -devshop-log "Running remaining tasks: drush @hostmaster hosting-tasks --fork=0 --strict=0 --force || true" -drush @hostmaster hosting-tasks --fork=0 --strict=0 --force || true +# devshop-log "Running remaining tasks: drush @hostmaster hosting-tasks --fork=0 --strict=0 --force || true" +# drush @hostmaster hosting-tasks --fork=0 --strict=0 --force || true -devshop-log "Running remaining tasks: Complete!" +# devshop-log "Running remaining tasks: Complete!" # Enable watchdog drush @hostmaster en dblog -y @@ -46,6 +53,9 @@ else devshop-log "WARNING: GITHUB_TOKEN environment variable not found." fi +echo "Drush RC Right before devmaster:test" +cat ~/.drush/drushrc.php + # Run the test suite. devshop devmaster:test #drush @hostmaster provision-test --behat-folder-path=profiles/devmaster/tests --test-type=behat