├── .ansible-lint ├── .gitignore ├── vars ├── Debian.yml └── RedHat.yml ├── .github ├── FUNDING.yml └── workflows │ ├── release.yml │ ├── ci.yml │ └── stale.yml ├── molecule └── default │ ├── requirements.yml │ ├── xdebug-test.php │ ├── molecule.yml │ └── converge.yml ├── .yamllint ├── defaults └── main.yml ├── templates └── xdebug.ini.j2 ├── tasks ├── configure.yml └── main.yml ├── meta └── main.yml ├── LICENSE └── README.md /.ansible-lint: -------------------------------------------------------------------------------- 1 | skip_list: 2 | - 'yaml' 3 | - 'role-name' 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | */__pycache__ 3 | *.pyc 4 | .cache 5 | 6 | -------------------------------------------------------------------------------- /vars/Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | __php_xdebug_module_path: /usr/lib/php7/modules 3 | __php_xdebug_config_filename: 20-xdebug.ini 4 | -------------------------------------------------------------------------------- /vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | __php_xdebug_module_path: /usr/lib64/php/modules 3 | __php_xdebug_config_filename: xdebug.ini 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | --- 3 | github: geerlingguy 4 | patreon: geerlingguy 5 | -------------------------------------------------------------------------------- /molecule/default/requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - src: geerlingguy.repo-remi 3 | - src: geerlingguy.php-versions 4 | - src: geerlingguy.php 5 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | line-length: 6 | max: 120 7 | level: warning 8 | 9 | ignore: | 10 | .github/workflows/stale.yml 11 | -------------------------------------------------------------------------------- /molecule/default/xdebug-test.php: -------------------------------------------------------------------------------- 1 | - 39 | ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} 40 | $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) 41 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 'on': 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: "0 7 * * 4" 10 | 11 | defaults: 12 | run: 13 | working-directory: 'geerlingguy.php-xdebug' 14 | 15 | jobs: 16 | 17 | lint: 18 | name: Lint 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Check out the codebase. 22 | uses: actions/checkout@v4 23 | with: 24 | path: 'geerlingguy.php-xdebug' 25 | 26 | - name: Set up Python 3. 27 | uses: actions/setup-python@v5 28 | with: 29 | python-version: '3.13' # Can't go to 3.14+ until Ansible 13.x 30 | 31 | - name: Install test dependencies. 32 | run: pip3 install yamllint 33 | 34 | - name: Lint code. 35 | run: | 36 | yamllint . 37 | 38 | molecule: 39 | name: Molecule 40 | runs-on: ubuntu-latest 41 | strategy: 42 | matrix: 43 | distro: 44 | - rockylinux9 45 | - ubuntu2204 46 | - debian11 47 | 48 | steps: 49 | - name: Check out the codebase. 50 | uses: actions/checkout@v4 51 | with: 52 | path: 'geerlingguy.php-xdebug' 53 | 54 | - name: Set up Python 3. 55 | uses: actions/setup-python@v5 56 | with: 57 | python-version: '3.13' # Can't go to 3.14+ until Ansible 13.x 58 | 59 | - name: Install test dependencies. 60 | run: pip3 install ansible molecule molecule-plugins[docker] docker 61 | 62 | - name: Run Molecule tests. 63 | run: molecule test 64 | env: 65 | PY_COLORS: '1' 66 | ANSIBLE_FORCE_COLOR: '1' 67 | MOLECULE_DISTRO: ${{ matrix.distro }} 68 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Close inactive issues 3 | 'on': 4 | schedule: 5 | - cron: "55 1 * * 6" # semi-random time 6 | 7 | jobs: 8 | close-issues: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | issues: write 12 | pull-requests: write 13 | steps: 14 | - uses: actions/stale@v8 15 | with: 16 | days-before-stale: 120 17 | days-before-close: 60 18 | exempt-issue-labels: bug,pinned,security,planned 19 | exempt-pr-labels: bug,pinned,security,planned 20 | stale-issue-label: "stale" 21 | stale-pr-label: "stale" 22 | stale-issue-message: | 23 | This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 24 | 25 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 26 | close-issue-message: | 27 | This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 28 | stale-pr-message: | 29 | This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 30 | 31 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 32 | close-pr-message: | 33 | This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 34 | repo-token: ${{ secrets.GITHUB_TOKEN }} 35 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Include OS-specific variables. 3 | include_vars: "{{ ansible_facts.os_family }}.yml" 4 | 5 | - name: Define php_xdebug_module_path. 6 | set_fact: 7 | php_xdebug_module_path: "{{ __php_xdebug_module_path }}" 8 | when: php_xdebug_module_path is not defined 9 | 10 | - name: Define php_xdebug_config_filename. 11 | set_fact: 12 | php_xdebug_config_filename: "{{ __php_xdebug_config_filename }}" 13 | when: php_xdebug_config_filename is not defined 14 | 15 | - name: Ensure dependencies for building from source are installed (RedHat). 16 | yum: 17 | name: '@development' 18 | state: present 19 | when: ansible_facts.os_family == 'RedHat' 20 | 21 | - name: Ensure dependencies for building from source are installed (Debian). 22 | apt: 23 | name: build-essential 24 | state: present 25 | when: ansible_facts.os_family == 'Debian' 26 | 27 | - name: Untar Xdebug. 28 | unarchive: 29 | src: "https://xdebug.org/files/xdebug-{{ php_xdebug_version }}.tgz" 30 | dest: "{{ workspace }}" 31 | creates: "{{ workspace }}/xdebug-{{ php_xdebug_version }}" 32 | copy: false 33 | mode: 0755 34 | 35 | - name: Build Xdebug. 36 | command: > 37 | {{ item }} 38 | chdir={{ workspace }}/xdebug-{{ php_xdebug_version }} 39 | creates={{ workspace }}/xdebug-{{ php_xdebug_version }}/modules/xdebug.so 40 | with_items: 41 | - phpize 42 | - ./configure 43 | - make 44 | 45 | - name: Ensure Xdebug module path exists. 46 | file: 47 | path: "{{ php_xdebug_module_path }}" 48 | state: directory 49 | owner: root 50 | group: root 51 | mode: 0755 52 | 53 | - name: Move Xdebug module into place. 54 | copy: 55 | src: "{{ workspace }}/xdebug-{{ php_xdebug_version }}/modules/xdebug.so" 56 | dest: "{{ php_xdebug_module_path }}/xdebug-{{ php_xdebug_version }}.so" 57 | remote_src: true 58 | mode: 0644 59 | notify: restart webserver 60 | 61 | - include_tasks: configure.yml 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: PHP-XDebug 2 | 3 | [![CI](https://github.com/geerlingguy/ansible-role-php-xdebug/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/ansible-role-php-xdebug/actions/workflows/ci.yml) 4 | 5 | Installs PHP [XDebug](http://xdebug.org/) on Linux servers. 6 | 7 | ## Requirements 8 | 9 | Prior to running this role, make sure the `php-devel` and `@Development Tools` (for RHEL/CentOS) or `php5-dev` + `build-essential` packages (for Debian/Ubuntu) are present on the system, as they are required for the build of Xdebug. 10 | 11 | ## Role Variables 12 | 13 | Available variables are listed below, along with default values (see `defaults/main.yml`): 14 | 15 | workspace: /root 16 | 17 | Where Xdebug setup files will be downloaded and built. 18 | 19 | php_xdebug_version: 3.3.2 20 | 21 | The version of Xdebug to be installed (see [Updates](https://xdebug.org/updates.php) for a current listing). 22 | 23 | php_xdebug_default_enable: 1 24 | php_xdebug_coverage_enable: 1 25 | 26 | Whether to enable XDebug coverage and default exception handling or not. Disable these for slightly improved PHP performance, enable these to use XDebug to the fullest extent. 27 | 28 | php_xdebug_module_path: /usr/lib64/php/modules 29 | 30 | The path where `xdebug.so` will be installed. 31 | 32 | php_xdebug_remote_enable: "false" 33 | 34 | Whether remote debugging is enabled. 35 | 36 | php_xdebug_remote_connect_back: "false" 37 | 38 | If this is set to true, Xdebug will respond to any request from any IP address; use only for local development on non-public installations! 39 | 40 | php_xdebug_remote_host: localhost 41 | php_xdebug_remote_port: "9000" 42 | 43 | The host and port on which Xdebug will listen. 44 | 45 | php_xdebug_remote_log: /tmp/xdebug.log 46 | 47 | The location of the xdebug log (useful if you're having trouble connecting). 48 | 49 | php_xdebug_idekey: sublime.xdebug 50 | 51 | The IDE key to use in the URL when making Xdebug requests (e.g. `http://example.local/?XDEBUG_SESSION_START=sublime.xdebug`). 52 | 53 | php_xdebug_max_nesting_level: 256 54 | 55 | The maximimum function nesting level before Xdebug bails and throws a fatal exception. 56 | 57 | php_xdebug_cli_disable: false 58 | 59 | (Debian/Ubuntu ONLY) Disable xdebug for the CLI SAPI. 60 | 61 | ## Dependencies 62 | 63 | - geerlingguy.php 64 | 65 | ## Example Playbook 66 | 67 | - hosts: webservers 68 | roles: 69 | - { role: geerlingguy.php-xdebug } 70 | 71 | ## License 72 | 73 | MIT / BSD 74 | 75 | ## Author Information 76 | 77 | This role was created in 2014 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). 78 | --------------------------------------------------------------------------------