diff --git a/.github/workflows/ce-provision-test-web.yml b/.github/workflows/ce-provision-test-web.yml index 275af558e..e78a140d0 100644 --- a/.github/workflows/ce-provision-test-web.yml +++ b/.github/workflows/ce-provision-test-web.yml @@ -10,7 +10,7 @@ jobs: # Name the Job name: Run tests against Ansible code base # Set the type of machine to run on - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: # Checks out a copy of your repository on the ubuntu-latest machine @@ -38,5 +38,5 @@ jobs: if: ${{ github.event.pull_request.head.ref != 'documentation' }} run: | git clone --branch ${{ github.event.pull_request.base.ref }} https://github.com/codeenigma/ce-dev-ce-provision-config.git config - /bin/bash ce-dev/ansible/test.sh --examples web --own-branch ${{ github.event.pull_request.base.ref }} --config-branch ${{ github.event.pull_request.base.ref }} + /bin/bash ce-dev/ansible/test.sh --examples web --own-branch ${{ github.event.pull_request.head.ref }} --config-branch ${{ github.event.pull_request.base.ref }} shell: bash diff --git a/ce-dev/ansible/plays/_common/setup.yml b/ce-dev/ansible/plays/_common/setup.yml new file mode 100644 index 000000000..59135624b --- /dev/null +++ b/ce-dev/ansible/plays/_common/setup.yml @@ -0,0 +1,20 @@ +--- +# Run the _init role to correctly install Ansible first. +- hosts: provision-target + become: true + + vars: + project_name: blank + is_local: true + _ce_provision_base_dir: /home/ce-dev/ce-provision + _init: + force_play: true + vars_dirs: + - "{{ _ce_provision_base_dir }}/ce-dev/ansible/vars/_common" + - "{{ _ce_provision_base_dir }}/ce-dev/ansible/vars/{{ project_name }}" + + tasks: + - ansible.builtin.import_role: + name: _init + - ansible.builtin.import_role: + name: _exit diff --git a/ce-dev/ansible/test.sh b/ce-dev/ansible/test.sh index 61124de0a..ebf637089 100755 --- a/ce-dev/ansible/test.sh +++ b/ce-dev/ansible/test.sh @@ -94,15 +94,19 @@ provision-target provision-privileged EOT PROVISION_CMD="/bin/sh /home/ce-dev/ce-provision/scripts/provision.sh" - echo "# Executing $1 project" - PROVISION_CMD="$PROVISION_CMD --repo dummy --branch dummy --workspace /home/ce-dev/ce-provision/ce-dev/ansible --playbook plays/$1/$1.yml --own-branch $2 --config-branch $3 --force" if [ $VERBOSE = true ]; then echo "# In verbose mode" PROVISION_CMD="$PROVISION_CMD --verbose" fi - echo "# Running command: $PROVISION_CMD" + echo "# Executing $1 project" + PROVISION_EXEC="$PROVISION_CMD --repo dummy --branch dummy --workspace /home/ce-dev/ce-provision/ce-dev/ansible --playbook plays/_common/setup.yml --own-branch $2 --config-branch $3 --force" + echo "# Installing Ansible in a venv: $PROVISION_EXEC" + # shellcheck disable=SC2086 + sudo docker exec -t --workdir /home/ce-dev/ce-provision --user ce-dev provision-controller $PROVISION_EXEC + PROVISION_EXEC="$PROVISION_CMD --python-interpreter /home/ce-dev/ce-python/bin/python3 --repo dummy --branch dummy --workspace /home/ce-dev/ce-provision/ce-dev/ansible --playbook plays/$1/$1.yml --own-branch $2 --config-branch $3 --force" + echo "# Running command: $PROVISION_EXEC" # shellcheck disable=SC2086 - sudo docker exec -t --workdir /home/ce-dev/ce-provision --user ce-dev provision-controller $PROVISION_CMD + sudo docker exec -t --workdir /home/ce-dev/ce-provision --user ce-dev provision-controller $PROVISION_EXEC echo "### $1 project completed ###" } diff --git a/ce-dev/ansible/vars/provision/ce_provision.yml b/ce-dev/ansible/vars/provision/ce_provision.yml index 4819f04c5..15dcb2705 100644 --- a/ce-dev/ansible/vars/provision/ce_provision.yml +++ b/ce-dev/ansible/vars/provision/ce_provision.yml @@ -6,7 +6,7 @@ ce_provision: own_repository_branch: "devel-2.x" own_repository_skip_checkout: true config_repository: "https://github.com/codeenigma/ce-dev-ce-provision-config.git" - config_repository_branch: "1.x" + config_repository_branch: "devel-2.x" config_repository_skip_checkout: true local_dir: "/home/ce-dev/ce-provision" galaxy_custom_requirements_file: "/home/ce-dev/ce-provision/ce-dev/ansible/vars/provision/galaxy-requirements.yml" diff --git a/ce-dev/ansible/vars/web/php.yml b/ce-dev/ansible/vars/web/php.yml index e77d64b22..e6f4aeeb2 100644 --- a/ce-dev/ansible/vars/web/php.yml +++ b/ce-dev/ansible/vars/web/php.yml @@ -1,3 +1,6 @@ php: version: - - 8.1 \ No newline at end of file + - 8.1 + # GitHub Actions doesn't make ansible_facts for CPU info available + fpm: + max_children: 5 diff --git a/ce-dev/ce-dev.compose.yml b/ce-dev/ce-dev.compose.yml index 78a4ac0f8..f512e6176 100644 --- a/ce-dev/ce-dev.compose.yml +++ b/ce-dev/ce-dev.compose.yml @@ -11,6 +11,8 @@ services: x-ce_dev: {} volumes: - ../:/home/ce-dev/ce-provision + platform: linux/amd64 + cgroup: host target: image: codeenigma/ce-dev-1.x:devel x-ce_dev: @@ -21,6 +23,8 @@ services: - 443 cap_add: - NET_ADMIN + platform: linux/amd64 + cgroup: host privileged: image: codeenigma/ce-dev-1.x:devel x-ce_dev: @@ -32,3 +36,5 @@ services: - 443 cap_add: - NET_ADMIN + platform: linux/amd64 + cgroup: host diff --git a/docs/roles/debian/php-fpm.md b/docs/roles/debian/php-fpm.md index 1c6484680..063e97276 100644 --- a/docs/roles/debian/php-fpm.md +++ b/docs/roles/debian/php-fpm.md @@ -23,7 +23,7 @@ php: # It is important to scale up processes on bigger servers, so that more # requests can be handled. Double the number of vCPUs is a good default. # Can be between 5 and 64. - max_children: "{{ [5, [ansible_facts.processor_vcpus * 2, 64] | min] | max }}" + max_children: "{{ [5, [ansible_facts.ansible_processor_nproc * 2, 64] | min] | max }}" start_servers: 2 min_spare_servers: 1 max_spare_servers: 3 diff --git a/roles/debian/php-fpm/README.md b/roles/debian/php-fpm/README.md index 1c6484680..063e97276 100644 --- a/roles/debian/php-fpm/README.md +++ b/roles/debian/php-fpm/README.md @@ -23,7 +23,7 @@ php: # It is important to scale up processes on bigger servers, so that more # requests can be handled. Double the number of vCPUs is a good default. # Can be between 5 and 64. - max_children: "{{ [5, [ansible_facts.processor_vcpus * 2, 64] | min] | max }}" + max_children: "{{ [5, [ansible_facts.ansible_processor_nproc * 2, 64] | min] | max }}" start_servers: 2 min_spare_servers: 1 max_spare_servers: 3