├── .ansible-lint ├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .gitmodules ├── .yamllint ├── LICENSE ├── README.md ├── galaxy-deploy.yml ├── galaxy.yml ├── meta └── runtime.yml └── tests └── integration └── targets └── php_role_test └── tasks └── main.yml /.ansible-lint: -------------------------------------------------------------------------------- 1 | skip_list: 2 | - no-changed-when 3 | - risky-file-permissions 4 | - yaml 5 | - fqcn[action-core] 6 | - name[template] 7 | 8 | verbosity: 1 9 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: geerlingguy 4 | patreon: geerlingguy 5 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 'on': 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: "25 4 * * 2" 10 | 11 | defaults: 12 | run: 13 | working-directory: ansible_collections/geerlingguy/php_roles 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@v2 23 | with: 24 | path: ansible_collections/geerlingguy/php_roles 25 | 26 | - name: Set up Python 3. 27 | uses: actions/setup-python@v2 28 | with: 29 | python-version: '3.x' 30 | 31 | - name: Install test dependencies. 32 | run: pip3 install yamllint ansible-core ansible-lint 33 | 34 | - name: Lint code. 35 | run: | 36 | yamllint . 37 | ansible-lint 38 | 39 | integration: 40 | name: Integration 41 | runs-on: ubuntu-latest 42 | strategy: 43 | matrix: 44 | include: 45 | - distro: centos7 46 | python_interpreter: /usr/bin/python 47 | - distro: ubuntu1804 48 | python_interpreter: /usr/bin/python3 49 | 50 | steps: 51 | - name: Check out the codebase. 52 | uses: actions/checkout@v2 53 | with: 54 | path: ansible_collections/geerlingguy/php_roles 55 | 56 | - name: Set up Python 3. 57 | uses: actions/setup-python@v2 58 | with: 59 | python-version: '3.x' 60 | 61 | - name: Install test dependencies. 62 | run: | 63 | pip3 install ansible molecule[docker] docker 64 | ansible-galaxy collection install community.general 65 | 66 | - name: Run Ansible tests. 67 | run: > 68 | ansible-test integration --color 69 | --docker ubuntu2004 70 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Release 3 | 'on': 4 | push: 5 | tags: 6 | - '*' 7 | 8 | defaults: 9 | run: 10 | working-directory: ansible_collections/geerlingguy/php_roles 11 | 12 | jobs: 13 | 14 | release: 15 | name: Release 16 | runs-on: ubuntu-latest 17 | env: 18 | ANSIBLE_GALAXY_TOKEN: ${{ secrets.ANSIBLE_GALAXY_TOKEN }} 19 | ANSIBLE_FORCE_COLOR: 1 20 | 21 | steps: 22 | - name: Check out the codebase. 23 | uses: actions/checkout@v2 24 | with: 25 | path: ansible_collections/geerlingguy/php_roles 26 | 27 | - name: Set up Python 3. 28 | uses: actions/setup-python@v2 29 | with: 30 | python-version: '3.x' 31 | 32 | - name: Install Ansible. 33 | run: pip3 install ansible-core 34 | 35 | - name: Release to Ansible Galaxy. 36 | run: ansible-playbook -i 'localhost,' galaxy-deploy.yml -e "github_tag=${{ github.ref }}" 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.tar.gz 2 | tests/output -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "roles/php"] 2 | path = roles/php 3 | url = https://github.com/geerlingguy/ansible-role-php.git 4 | [submodule "roles/php_memcached"] 5 | path = roles/php_memcached 6 | url = https://github.com/geerlingguy/ansible-role-php-memcached.git 7 | [submodule "roles/php_mysql"] 8 | path = roles/php_mysql 9 | url = https://github.com/geerlingguy/ansible-role-php-mysql.git 10 | [submodule "roles/php_pear"] 11 | path = roles/php_pear 12 | url = https://github.com/geerlingguy/ansible-role-php-pear.git 13 | [submodule "roles/php_pecl"] 14 | path = roles/php_pecl 15 | url = https://github.com/geerlingguy/ansible-role-php-pecl.git 16 | [submodule "roles/php_pgsql"] 17 | path = roles/php_pgsql 18 | url = https://github.com/geerlingguy/ansible-role-php-pgsql.git 19 | [submodule "roles/php_redis"] 20 | path = roles/php_redis 21 | url = https://github.com/geerlingguy/ansible-role-php-redis.git 22 | [submodule "roles/php_tideways"] 23 | path = roles/php_tideways 24 | url = https://github.com/geerlingguy/ansible-role-php-tideways.git 25 | [submodule "roles/php_versions"] 26 | path = roles/php_versions 27 | url = https://github.com/geerlingguy/ansible-role-php-versions.git 28 | [submodule "roles/php_xdebug"] 29 | path = roles/php_xdebug 30 | url = https://github.com/geerlingguy/ansible-role-php-xdebug.git 31 | [submodule "roles/php_xhprof"] 32 | path = roles/php_xhprof 33 | url = https://github.com/geerlingguy/ansible-role-php-xhprof.git 34 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | line-length: 6 | max: 180 7 | level: warning 8 | 9 | ignore: | 10 | .github/stale.yml 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Jeff Geerling 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP Roles Collection for Ansible 2 | 3 | **DEPRECATED**: Due to the maintenance burden of trying to manage this collection in addition to the `php_*` roles, and my inability to move everything into the `geerlingguy.php` namespace, I have deprecated this collection and recommend you use my `php_*` roles (e.g. `geerlingguy.php`, `geerlingguy.php_version`, etc.) individually instead. 4 | 5 | [![MIT licensed][badge-license]][link-license] 6 | [![Galaxy Collection][badge-collection]][link-galaxy] 7 | [![CI][badge-gh-actions]][link-gh-actions] 8 | 9 | This collection contains all the PHP-related roles maintained by Jeff Geerling (geerlingguy). 10 | 11 | It includes: 12 | 13 | - [geerlingguy.php](https://galaxy.ansible.com/geerlingguy/php) 14 | - [geerlingguy.php_memcached](https://galaxy.ansible.com/geerlingguy/php-memcached) 15 | - [geerlingguy.php_mysql](https://galaxy.ansible.com/geerlingguy/php-mysql) 16 | - [geerlingguy.php_pear](https://galaxy.ansible.com/geerlingguy/php-pear) 17 | - [geerlingguy.php_pecl](https://galaxy.ansible.com/geerlingguy/php-pecl) 18 | - [geerlingguy.php_pgsql](https://galaxy.ansible.com/geerlingguy/php-pgsql) 19 | - [geerlingguy.php_redis](https://galaxy.ansible.com/geerlingguy/php-redis) 20 | - [geerlingguy.php_tideways](https://galaxy.ansible.com/geerlingguy/php-tideways) 21 | - [geerlingguy.php_versions](https://galaxy.ansible.com/geerlingguy/php-versions) 22 | - [geerlingguy.php_xdebug](https://galaxy.ansible.com/geerlingguy/php-xdebug) 23 | - [geerlingguy.php_xhprof](https://galaxy.ansible.com/geerlingguy/php-xhprof) 24 | 25 | ## Usage 26 | 27 | Install this collection locally: 28 | 29 | ansible-galaxy collection install geerlingguy.php_roles -p ./collections 30 | 31 | Then you can use the roles from the collection in your playbooks: 32 | 33 | ```yaml 34 | --- 35 | - hosts: all 36 | 37 | collections: 38 | - geerlingguy.php_roles 39 | 40 | roles: 41 | - php 42 | - role: php-versions 43 | vars: 44 | php_version: '7.3' 45 | ``` 46 | 47 | > If you want to be more explicit, you can use the fully-qualified role name when referring to a role in this collection, like `geerlingguy.php_roles.php` instead of just `php`. This could be helpful if, for example, you maintain a separate `php` role in another place on your local workstation. 48 | 49 | ## Development 50 | 51 | Currently, all the PHP roles (inside `roles/`) are Git submodules, and work on the roles themselves should take place in the upstream Role repository. At some point, the roles might move into this repository for their canonical home. 52 | 53 | This collection has some integration tests (inside `tests/`), however, which pull all the roles together and ensure they work in tandem on the latest supported platforms. 54 | 55 | The integrated tests use `ansible-test`. You can run them with the following command: 56 | 57 | ``` 58 | ansible-test integration --docker geerlingguy/docker-ubuntu1804-ansible 59 | ``` 60 | 61 | > Note: You can switch out `ubuntu1804` with any other supported operating system (e.g. `centos7`). 62 | 63 | ### Pushing a new version 64 | 65 | Before tagging a new version, make sure all the git submodules are up to date: 66 | 67 | ``` 68 | git submodule update --recursive --remote 69 | ``` 70 | 71 | Then commit and push all changes, and make sure all tests are passing. 72 | 73 | Then tag the new version of the collection and push the tag. 74 | 75 | Once pushed, GitHub actions will run the `galaxy-deploy.yml` playbook to deploy the new version. 76 | 77 | ## Author 78 | 79 | This collection was created in 2019 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/) and [Ansible for Kubernetes](https://www.ansibleforkubernetes.com). 80 | 81 | [badge-gh-actions]: https://github.com/geerlingguy/ansible-collection-php_roles/workflows/CI/badge.svg?event=push 82 | [link-gh-actions]: https://github.com/geerlingguy/ansible-collection-php_roles/actions?query=workflow%3ACI 83 | [badge-collection]: https://img.shields.io/badge/collection-geerlingguy.php_roles-blue 84 | [link-galaxy]: https://galaxy.ansible.com/geerlingguy/php_roles 85 | [badge-license]: https://img.shields.io/github/license/geerlingguy/ansible-collection-php_roles.svg 86 | [link-license]: https://github.com/geerlingguy/ansible-collection-php_roles/blob/master/LICENSE 87 | [badge-gh-actions]: https://github.com/geerlingguy/ansible-role-homebrew/workflows/CI/badge.svg?event=push 88 | -------------------------------------------------------------------------------- /galaxy-deploy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Automated release playbook for Ansible Collections. 3 | # 4 | # Originally based on Ericsysmin's 2020 blog post. Meant to be used in a GitHub 5 | # Actions CI environment. 6 | # 7 | # Requires a ANSIBLE_GALAXY_TOKEN secret to be configured on the GitHub repo. 8 | # 9 | # Usage: 10 | # ansible-playbook -i 'localhost,' galaxy-deploy.yml \ 11 | # -e "github_tag=${{ github.ref }}" 12 | 13 | - hosts: localhost 14 | connection: local 15 | gather_facts: false 16 | 17 | vars: 18 | namespace: geerlingguy 19 | collection: php_roles 20 | # Requires github_tag to be set when calling playbook. 21 | release_tag: "{{ github_tag.split('/')[-1] }}" 22 | 23 | pre_tasks: 24 | - name: Ensure ANSIBLE_GALAXY_TOKEN is set. 25 | fail: 26 | msg: A valid ANSIBLE_GALAXY_TOKEN must be set. 27 | when: "lookup('env','ANSIBLE_GALAXY_TOKEN') | length == 0" 28 | 29 | - name: Ensure the ~/.ansible directory exists. 30 | file: 31 | path: ~/.ansible 32 | state: directory 33 | 34 | - name: Write the Galaxy token to ~/.ansible/galaxy_token 35 | copy: 36 | content: | 37 | token: {{ lookup('env','ANSIBLE_GALAXY_TOKEN') }} 38 | dest: ~/.ansible/galaxy_token 39 | 40 | tasks: 41 | - name: Ensure the galaxy.yml tag is up to date. 42 | lineinfile: 43 | path: galaxy.yml 44 | regexp: "^version:" 45 | line: 'version: "{{ release_tag }}"' 46 | 47 | - name: Build the collection. 48 | command: ansible-galaxy collection build 49 | 50 | - name: Publish the collection. 51 | command: > 52 | ansible-galaxy collection publish ./{{ namespace }}-{{ collection }}-{{ release_tag }}.tar.gz 53 | -------------------------------------------------------------------------------- /galaxy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | namespace: geerlingguy 3 | name: php_roles 4 | description: An elegant collection of roles for PHP automation. 5 | version: "1.0.0" 6 | readme: README.md 7 | 8 | authors: 9 | - geerlingguy (https://www.jeffgeerling.com/) 10 | 11 | license: 12 | - MIT 13 | 14 | tags: 15 | - php 16 | - apache 17 | - lamp 18 | - lemp 19 | - nginx 20 | - apache 21 | - debian 22 | - ubuntu 23 | - centos 24 | - amazon 25 | - linux 26 | - rhel 27 | - fedora 28 | - drupal 29 | - wordpress 30 | - laravel 31 | 32 | dependencies: 33 | community.general: ">=3.0.0" 34 | 35 | repository: https://github.com/geerlingguy/ansible-collection-php_roles 36 | documentation: https://github.com/geerlingguy/ansible-collection-php_roles 37 | homepage: https://www.jeffgeerling.com 38 | issues: https://github.com/geerlingguy/ansible-collection-php_roles/issues 39 | 40 | build_ignore: 41 | - scripts 42 | - tests 43 | - .DS_Store 44 | -------------------------------------------------------------------------------- /meta/runtime.yml: -------------------------------------------------------------------------------- 1 | --- 2 | requires_ansible: ">=2.10" 3 | -------------------------------------------------------------------------------- /tests/integration/targets/php_role_test/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Update apt cache. 2 | ansible.builtin.apt: 3 | update_cache: true 4 | cache_valid_time: 600 5 | when: ansible_os_family == 'Debian' 6 | 7 | - name: Configure universal variables. 8 | ansible.builtin.set_fact: 9 | php_enable_webserver: false 10 | php_default_version_debian: "7.0" 11 | 12 | - name: Configure variables for RHEL/CentOS 7. 13 | ansible.builtin.set_fact: 14 | php_expected_version: "5.4" 15 | when: 16 | - ansible_os_family == 'RedHat' 17 | - ansible_distribution_major_version == '7' 18 | 19 | - name: Configure variables for Ubuntu 18.04. 20 | ansible.builtin.set_fact: 21 | php_default_version_debian: "7.2" 22 | php_expected_version: "7.2" 23 | when: 24 | - ansible_os_family == 'Debian' 25 | - ansible_distribution_version == '18.04' 26 | 27 | - name: Run the PHP role. 28 | ansible.builtin.include_role: 29 | name: geerlingguy.php_roles.php 30 | 31 | # TODO: Verify idempotence; see https://github.com/ansible/ansible/issues/60226. 32 | 33 | # Verify PHP is installed with the correct version. 34 | - name: Run the PHP version command. 35 | ansible.builtin.command: php -v 36 | changed_when: false 37 | register: php_version_command 38 | 39 | - name: Verify PHP is installed with the correct version. 40 | ansible.builtin.assert: 41 | that: php_expected_version in php_version_command.stdout 42 | --------------------------------------------------------------------------------