├── .editorconfig ├── .fixtures.yml ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── labeler.yml ├── release.yml └── workflows │ ├── ci.yml │ ├── labeler.yml │ ├── prepare_release.yml │ └── release.yml ├── .gitignore ├── .msync.yml ├── .overcommit.yml ├── .pmtignore ├── .puppet-lint.rc ├── .rubocop.yml ├── .rubocop_todo.yml ├── .sync.yml ├── CHANGELOG.md ├── Gemfile ├── HISTORY.md ├── LICENSE ├── README.md ├── REFERENCE.md ├── Rakefile ├── data └── default.yaml ├── hiera.yaml ├── lib ├── facter │ └── phpversion.rb └── puppet │ ├── functions │ └── php │ │ └── ensure_prefix.rb │ ├── parser │ └── functions │ │ └── to_hash_settings.rb │ └── provider │ └── package │ ├── pear.rb │ └── pecl.rb ├── manifests ├── apache_config.pp ├── apache_vhost.pp ├── cli.pp ├── composer.pp ├── composer │ └── auto_update.pp ├── config.pp ├── config │ └── setting.pp ├── dev.pp ├── embedded.pp ├── extension.pp ├── extension │ ├── config.pp │ └── install.pp ├── fpm.pp ├── fpm │ ├── config.pp │ ├── pool.pp │ └── service.pp ├── global.pp ├── globals.pp ├── init.pp ├── packages.pp ├── params.pp ├── pear.pp ├── phpunit.pp ├── phpunit │ └── auto_update.pp ├── repo.pp └── repo │ ├── debian.pp │ ├── redhat.pp │ ├── suse.pp │ └── ubuntu.pp ├── metadata.json ├── spec ├── acceptance │ └── php_spec.rb ├── classes │ ├── php_composer_spec.rb │ ├── php_fpm_config_spec.rb │ ├── php_fpm_service_spec.rb │ ├── php_fpm_spec.rb │ ├── php_repo_debian_spec.rb │ ├── php_repo_spec.rb │ ├── php_repo_ubuntu_spec.rb │ └── php_spec.rb ├── defines │ ├── config_spec.rb │ ├── extension_rhscl_spec.rb │ ├── extension_spec.rb │ └── fpm_pool_spec.rb ├── fixtures │ └── unit │ │ └── provider │ │ └── package │ │ └── pear │ │ ├── list_a │ │ ├── remote-info_benchmark │ │ └── remote-info_zip ├── functions │ ├── ensure_prefix.rb │ └── to_hash_settings_spec.rb ├── spec_helper.rb ├── spec_helper_acceptance.rb └── unit │ └── provider │ └── package │ ├── pear_spec.rb │ └── pecl_spec.rb ├── templates └── fpm │ ├── php-fpm.conf.erb │ └── pool.conf.erb └── types ├── composerchannel.pp ├── duration.pp ├── installoptions.pp ├── provider.pp └── sapi.pp /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | # Managed by modulesync - DO NOT EDIT 4 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 5 | 6 | root = true 7 | 8 | [*] 9 | charset = utf-8 10 | end_of_line = lf 11 | indent_size = 2 12 | tab_width = 2 13 | indent_style = space 14 | insert_final_newline = true 15 | trim_trailing_whitespace = true 16 | -------------------------------------------------------------------------------- /.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | repositories: 3 | stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" 4 | apt: "https://github.com/puppetlabs/puppetlabs-apt.git" 5 | translate: "https://github.com/puppetlabs/puppetlabs-translate.git" 6 | zypprepo: "https://github.com/deadpoint/puppet-zypprepo.git" 7 | inifile: "https://github.com/puppetlabs/puppetlabs-inifile.git" 8 | archive: "https://github.com/voxpupuli/puppet-archive.git" 9 | yumrepo_core: 10 | repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git 11 | puppet_version: ">= 6.0.0" 12 | zend_common: "https://github.com/zendtech/puppet-zend-common.git" 13 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution guidelines 2 | 3 | ## Table of contents 4 | 5 | * [Contributing](#contributing) 6 | * [Writing proper commits - short version](#writing-proper-commits-short-version) 7 | * [Writing proper commits - long version](#writing-proper-commits-long-version) 8 | * [Dependencies](#dependencies) 9 | * [Note for OS X users](#note-for-os-x-users) 10 | * [The test matrix](#the-test-matrix) 11 | * [Syntax and style](#syntax-and-style) 12 | * [Running the unit tests](#running-the-unit-tests) 13 | * [Unit tests in docker](#unit-tests-in-docker) 14 | * [Integration tests](#integration-tests) 15 | 16 | This module has grown over time based on a range of contributions from 17 | people using it. If you follow these contributing guidelines your patch 18 | will likely make it into a release a little more quickly. 19 | 20 | ## Contributing 21 | 22 | Please note that this project is released with a Contributor Code of Conduct. 23 | By participating in this project you agree to abide by its terms. 24 | [Contributor Code of Conduct](https://voxpupuli.org/coc/). 25 | 26 | * Fork the repo. 27 | * Create a separate branch for your change. 28 | * We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). 29 | * Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. 30 | * Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. 31 | * Squash your commits down into logical components. Make sure to rebase against our current master. 32 | * Push the branch to your fork and submit a pull request. 33 | 34 | Please be prepared to repeat some of these steps as our contributors review your code. 35 | 36 | Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions! 37 | 38 | ## Writing proper commits - short version 39 | 40 | * Make commits of logical units. 41 | * Check for unnecessary whitespace with "git diff --check" before committing. 42 | * Commit using Unix line endings (check the settings around "crlf" in git-config(1)). 43 | * Do not check in commented out code or unneeded files. 44 | * The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. 45 | * Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". 46 | * The body should provide a meaningful commit message, which: 47 | *uses the imperative, present tense: `change`, not `changed` or `changes`. 48 | * includes motivation for the change, and contrasts its implementation with the previous behavior. 49 | * Make sure that you have tests for the bug you are fixing, or feature you are adding. 50 | * Make sure the test suites passes after your commit: 51 | * When introducing a new feature, make sure it is properly documented in the README.md 52 | 53 | ## Writing proper commits - long version 54 | 55 | 1. Make separate commits for logically separate changes. 56 | 57 | Please break your commits down into logically consistent units 58 | which include new or changed tests relevant to the rest of the 59 | change. The goal of doing this is to make the diff easier to 60 | read for whoever is reviewing your code. In general, the easier 61 | your diff is to read, the more likely someone will be happy to 62 | review it and get it into the code base. 63 | 64 | If you are going to refactor a piece of code, please do so as a 65 | separate commit from your feature or bug fix changes. 66 | 67 | We also really appreciate changes that include tests to make 68 | sure the bug is not re-introduced, and that the feature is not 69 | accidentally broken. 70 | 71 | Describe the technical detail of the change(s). If your 72 | description starts to get too long, that is a good sign that you 73 | probably need to split up your commit into more finely grained 74 | pieces. 75 | 76 | Commits which plainly describe the things which help 77 | reviewers check the patch and future developers understand the 78 | code are much more likely to be merged in with a minimum of 79 | bike-shedding or requested changes. Ideally, the commit message 80 | would include information, and be in a form suitable for 81 | inclusion in the release notes for the version of Puppet that 82 | includes them. 83 | 84 | Please also check that you are not introducing any trailing 85 | whitespace or other "whitespace errors". You can do this by 86 | running "git diff --check" on your changes before you commit. 87 | 88 | 2. Sending your patches 89 | 90 | To submit your changes via a GitHub pull request, we _highly_ 91 | recommend that you have them on a topic branch, instead of 92 | directly on `master`. 93 | It makes things much easier to keep track of, especially if 94 | you decide to work on another thing before your first change 95 | is merged in. 96 | 97 | GitHub has some pretty good 98 | [general documentation](http://help.github.com/) on using 99 | their site. They also have documentation on 100 | [creating pull requests](http://help.github.com/send-pull-requests/). 101 | 102 | In general, after pushing your topic branch up to your 103 | repository on GitHub, you can switch to the branch in the 104 | GitHub UI and click "Pull Request" towards the top of the page 105 | in order to open a pull request. 106 | 107 | 108 | 3. Update the related GitHub issue. 109 | 110 | If there is a GitHub issue associated with the change you 111 | submitted, then you should update the ticket to include the 112 | location of your branch, along with any other commentary you 113 | may wish to make. 114 | 115 | ## Dependencies 116 | 117 | The testing and development tools have a bunch of dependencies, 118 | all managed by [bundler](http://bundler.io/) according to the 119 | [Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). 120 | 121 | By default the tests use a baseline version of Puppet. 122 | 123 | If you have Ruby 2.x or want a specific version of Puppet, 124 | you must set an environment variable such as: 125 | 126 | ```sh 127 | export PUPPET_GEM_VERSION="~> 6.1.0" 128 | ``` 129 | 130 | You can install all needed gems for spec tests into the modules directory by 131 | running: 132 | 133 | ```sh 134 | bundle config set --local path '.vendor/' 135 | bundle config set --local without 'development system_tests release' 136 | bundle install --jobs "$(nproc)" 137 | ``` 138 | 139 | If you also want to run acceptance tests: 140 | 141 | ```sh 142 | bundle config set --local path '.vendor/' 143 | bundle config set --local without 'development release' 144 | bundle config set --local with 'system_tests' 145 | bundle install --jobs "$(nproc)" 146 | ``` 147 | 148 | Our all in one solution if you don't know if you need to install or update gems: 149 | 150 | ```sh 151 | bundle config set --local path '.vendor/' 152 | bundle config set --local without 'development release' 153 | bundle config set --local with 'system_tests' 154 | bundle install --jobs "$(nproc)" 155 | bundle update 156 | bundle clean 157 | ``` 158 | 159 | As an alternative to the `--jobs "$(nproc)` parameter, you can set an 160 | environment variable: 161 | 162 | ```sh 163 | BUNDLE_JOBS="$(nproc)" 164 | ``` 165 | 166 | ### Note for OS X users 167 | 168 | `nproc` isn't a valid command under OS x. As an alternative, you can do: 169 | 170 | ```sh 171 | --jobs "$(sysctl -n hw.ncpu)" 172 | ``` 173 | 174 | ## The test matrix 175 | 176 | ### Syntax and style 177 | 178 | The test suite will run [Puppet Lint](http://puppet-lint.com/) and 179 | [Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to 180 | check various syntax and style things. You can run these locally with: 181 | 182 | ```sh 183 | bundle exec rake lint 184 | bundle exec rake validate 185 | ``` 186 | 187 | It will also run some [Rubocop](http://batsov.com/rubocop/) tests 188 | against it. You can run those locally ahead of time with: 189 | 190 | ```sh 191 | bundle exec rake rubocop 192 | ``` 193 | 194 | ### Running the unit tests 195 | 196 | The unit test suite covers most of the code, as mentioned above please 197 | add tests if you're adding new functionality. If you've not used 198 | [rspec-puppet](http://rspec-puppet.com/) before then feel free to ask 199 | about how best to test your new feature. 200 | 201 | To run the linter, the syntax checker and the unit tests: 202 | 203 | ```sh 204 | bundle exec rake test 205 | ``` 206 | 207 | To run your all the unit tests 208 | 209 | ```sh 210 | bundle exec rake spec 211 | ``` 212 | 213 | To run a specific spec test set the `SPEC` variable: 214 | 215 | ```sh 216 | bundle exec rake spec SPEC=spec/foo_spec.rb 217 | ``` 218 | 219 | #### Unit tests in docker 220 | 221 | Some people don't want to run the dependencies locally or don't want to install 222 | ruby. We ship a Dockerfile that enables you to run all unit tests and linting. 223 | You only need to run: 224 | 225 | ```sh 226 | docker build . 227 | ``` 228 | 229 | Please ensure that a docker daemon is running and that your user has the 230 | permission to talk to it. You can specify a remote docker host by setting the 231 | `DOCKER_HOST` environment variable. it will copy the content of the module into 232 | the docker image. So it will not work if a Gemfile.lock exists. 233 | 234 | ### Integration tests 235 | 236 | The unit tests just check the code runs, not that it does exactly what 237 | we want on a real machine. For that we're using 238 | [beaker](https://github.com/puppetlabs/beaker). 239 | 240 | This fires up a new virtual machine (using vagrant) and runs a series of 241 | simple tests against it after applying the module. You can run this 242 | with: 243 | 244 | ```sh 245 | BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker 246 | ``` 247 | 248 | or 249 | 250 | ```sh 251 | BEAKER_PUPPET_COLLECTION=none BEAKER_setfile=archlinux-64 bundle exec rake beaker 252 | ``` 253 | 254 | This latter example will use the distribution's own version of Puppet. 255 | 256 | You can replace the string `debian11` with any common operating system. 257 | The following strings are known to work: 258 | 259 | * ubuntu2004 260 | * ubuntu2204 261 | * debian11 262 | * debian12 263 | * centos9 264 | * archlinux 265 | * almalinux8 266 | * almalinux9 267 | * fedora36 268 | 269 | For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). 270 | 271 | The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) 272 | repository. 273 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | ## Affected Puppet, Ruby, OS and module versions/distributions 12 | 13 | - Puppet: 14 | - Ruby: 15 | - Distribution: 16 | - Module version: 17 | 18 | ## How to reproduce (e.g Puppet code you use) 19 | 20 | ## What are you seeing 21 | 22 | ## What behaviour did you expect instead 23 | 24 | ## Output log 25 | 26 | ## Any additional information you'd like to impart 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 9 | #### Pull Request (PR) description 10 | 13 | 14 | #### This Pull Request (PR) fixes the following issues 15 | 21 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | skip-changelog: 6 | - head-branch: ['^release-*', 'release'] 7 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | # https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes 6 | 7 | changelog: 8 | exclude: 9 | labels: 10 | - duplicate 11 | - invalid 12 | - modulesync 13 | - question 14 | - skip-changelog 15 | - wont-fix 16 | - wontfix 17 | 18 | categories: 19 | - title: Breaking Changes 🛠 20 | labels: 21 | - backwards-incompatible 22 | 23 | - title: New Features 🎉 24 | labels: 25 | - enhancement 26 | 27 | - title: Bug Fixes 🐛 28 | labels: 29 | - bug 30 | 31 | - title: Documentation Updates 📚 32 | labels: 33 | - documentation 34 | - docs 35 | 36 | - title: Dependency Updates ⬆️ 37 | labels: 38 | - dependencies 39 | 40 | - title: Other Changes 41 | labels: 42 | - "*" 43 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | name: CI 6 | 7 | # yamllint disable-line rule:truthy 8 | on: 9 | pull_request: {} 10 | push: 11 | branches: 12 | - main 13 | - master 14 | 15 | concurrency: 16 | group: ${{ github.ref_name }} 17 | cancel-in-progress: true 18 | 19 | jobs: 20 | puppet: 21 | name: Puppet 22 | uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v3 23 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | name: "Pull Request Labeler" 6 | 7 | # yamllint disable-line rule:truthy 8 | on: 9 | pull_request_target: {} 10 | 11 | jobs: 12 | labeler: 13 | permissions: 14 | contents: read 15 | pull-requests: write 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/labeler@v5 19 | -------------------------------------------------------------------------------- /.github/workflows/prepare_release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | name: 'Prepare Release' 6 | 7 | on: 8 | workflow_dispatch: 9 | inputs: 10 | version: 11 | description: 'Module version to be released. Must be a valid semver string without leading v. (1.2.3)' 12 | required: false 13 | 14 | jobs: 15 | release_prep: 16 | uses: 'voxpupuli/gha-puppet/.github/workflows/prepare_release.yml@v3' 17 | with: 18 | version: ${{ github.event.inputs.version }} 19 | allowed_owner: 'voxpupuli' 20 | secrets: 21 | # Configure secrets here: 22 | # https://docs.github.com/en/actions/security-guides/encrypted-secrets 23 | github_pat: '${{ secrets.PCCI_PAT_RELEASE_PREP }}' 24 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | name: Release 6 | 7 | # yamllint disable-line rule:truthy 8 | on: 9 | push: 10 | tags: 11 | - '*' 12 | 13 | jobs: 14 | release: 15 | name: Release 16 | uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v3 17 | with: 18 | allowed_owner: 'voxpupuli' 19 | secrets: 20 | # Configure secrets here: 21 | # https://docs.github.com/en/actions/security-guides/encrypted-secrets 22 | username: ${{ secrets.PUPPET_FORGE_USERNAME }} 23 | api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | /pkg/ 5 | /Gemfile.lock 6 | /Gemfile.local 7 | /vendor/ 8 | /.vendor/ 9 | /spec/fixtures/manifests/ 10 | /spec/fixtures/modules/ 11 | /.vagrant/ 12 | /.bundle/ 13 | /.ruby-version 14 | /coverage/ 15 | /log/ 16 | /.idea/ 17 | /.dependencies/ 18 | /.librarian/ 19 | /Puppetfile.lock 20 | *.iml 21 | .*.sw? 22 | /.yardoc/ 23 | /Guardfile 24 | bolt-debug.log 25 | .rerun.json 26 | -------------------------------------------------------------------------------- /.msync.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | modulesync_config_version: '9.5.0' 6 | -------------------------------------------------------------------------------- /.overcommit.yml: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | # 4 | # Hooks are only enabled if you take action. 5 | # 6 | # To enable the hooks run: 7 | # 8 | # ``` 9 | # bundle exec overcommit --install 10 | # # ensure .overcommit.yml does not harm to you and then 11 | # bundle exec overcommit --sign 12 | # ``` 13 | # 14 | # (it will manage the .git/hooks directory): 15 | # 16 | # Examples howto skip a test for a commit or push: 17 | # 18 | # ``` 19 | # SKIP=RuboCop git commit 20 | # SKIP=PuppetLint git commit 21 | # SKIP=RakeTask git push 22 | # ``` 23 | # 24 | # Don't invoke overcommit at all: 25 | # 26 | # ``` 27 | # OVERCOMMIT_DISABLE=1 git commit 28 | # ``` 29 | # 30 | # Read more about overcommit: https://github.com/brigade/overcommit 31 | # 32 | # To manage this config yourself in your module add 33 | # 34 | # ``` 35 | # .overcommit.yml: 36 | # unmanaged: true 37 | # ``` 38 | # 39 | # to your modules .sync.yml config 40 | --- 41 | PreCommit: 42 | RuboCop: 43 | enabled: true 44 | description: 'Runs rubocop on modified files only' 45 | command: ['bundle', 'exec', 'rubocop'] 46 | RakeTarget: 47 | enabled: true 48 | description: 'Runs lint on modified files only' 49 | targets: 50 | - 'lint' 51 | command: ['bundle', 'exec', 'rake'] 52 | YamlSyntax: 53 | enabled: true 54 | JsonSyntax: 55 | enabled: true 56 | TrailingWhitespace: 57 | enabled: true 58 | 59 | PrePush: 60 | RakeTarget: 61 | enabled: true 62 | description: 'Run rake targets' 63 | targets: 64 | - 'validate' 65 | - 'test' 66 | - 'rubocop' 67 | command: ['bundle', 'exec', 'rake'] 68 | -------------------------------------------------------------------------------- /.pmtignore: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | /docs/ 5 | /pkg/ 6 | /Gemfile 7 | /Gemfile.lock 8 | /Gemfile.local 9 | /vendor/ 10 | /.vendor/ 11 | /spec/ 12 | /Rakefile 13 | /.vagrant/ 14 | /.bundle/ 15 | /.ruby-version 16 | /coverage/ 17 | /log/ 18 | /.idea/ 19 | /.dependencies/ 20 | /.github/ 21 | /.librarian/ 22 | /Puppetfile.lock 23 | /Puppetfile 24 | *.iml 25 | /.editorconfig 26 | /.fixtures.yml 27 | /.gitignore 28 | /.msync.yml 29 | /.overcommit.yml 30 | /.pmtignore 31 | /.rspec 32 | /.rspec_parallel 33 | /.rubocop.yml 34 | /.sync.yml 35 | .*.sw? 36 | /.yardoc/ 37 | /.yardopts 38 | /Dockerfile 39 | /HISTORY.md 40 | -------------------------------------------------------------------------------- /.puppet-lint.rc: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | --fail-on-warnings 5 | --no-parameter_documentation-check 6 | --no-parameter_types-check 7 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | inherit_from: .rubocop_todo.yml 6 | inherit_gem: 7 | voxpupuli-test: rubocop.yml 8 | -------------------------------------------------------------------------------- /.rubocop_todo.yml: -------------------------------------------------------------------------------- 1 | # This configuration was generated by 2 | # `rubocop --auto-gen-config` 3 | # on 2023-08-18 06:32:34 UTC using RuboCop version 1.50.2. 4 | # The point is for the user to remove these configuration records 5 | # one by one as the offenses are removed from the code base. 6 | # Note that changes in the inspected code, or installation of new 7 | # versions of RuboCop, may require this file to be generated again. 8 | -------------------------------------------------------------------------------- /.sync.yml: -------------------------------------------------------------------------------- 1 | --- 2 | .travis.yml: 3 | docker_sets: 4 | - set: ubuntu1604-64 5 | options: 6 | script: 'bundle exec rspec spec/acceptance/php56_spec.rb' 7 | - set: centos7-64 8 | options: 9 | script: 'bundle exec rspec spec/acceptance/php56_spec.rb' 10 | - set: ubuntu2004-64 11 | options: 12 | script: 'bundle exec rspec spec/acceptance/php_spec.rb' 13 | - set: ubuntu1804-64 14 | options: 15 | script: 'bundle exec rspec spec/acceptance/php_spec.rb' 16 | - set: ubuntu1604-64 17 | options: 18 | script: 'bundle exec rspec spec/acceptance/php_spec.rb' 19 | - set: centos7-64 20 | options: 21 | script: 'bundle exec rspec spec/acceptance/php_spec.rb' 22 | - set: debian9-64 23 | options: 24 | script: 'bundle exec rspec spec/acceptance/php_spec.rb' 25 | secure: "GOhttACuJt+3s38m4WnW5RuTgwqaAoeEQnNT+X1Ukn7KdcIk4KV8NzYU/CC0VIm8lUOnBWYJKEC4ixX/J/4Wbxox2RAoKMQrO++L0DB1zTCJnq9SfoUBMaQhXvLu+PbxAR0p3P47ozra0C+pOWDpOaxT9ecufrPQt9W9Z4aY/bs=" 26 | spec/spec_helper_acceptance.rb: 27 | unmanaged: false 28 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | source ENV['GEM_SOURCE'] || 'https://rubygems.org' 5 | 6 | group :test do 7 | gem 'voxpupuli-test', '~> 9.0', :require => false 8 | gem 'coveralls', :require => false 9 | gem 'simplecov-console', :require => false 10 | gem 'puppet_metadata', '~> 5.0', :require => false 11 | end 12 | 13 | group :development do 14 | gem 'guard-rake', :require => false 15 | gem 'overcommit', '>= 0.39.1', :require => false 16 | end 17 | 18 | group :system_tests do 19 | gem 'voxpupuli-acceptance', '~> 3.5', :require => false 20 | end 21 | 22 | group :release do 23 | gem 'voxpupuli-release', '~> 3.0', :require => false 24 | end 25 | 26 | gem 'rake', :require => false 27 | gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] 28 | 29 | puppetversion = ENV['PUPPET_GEM_VERSION'] || [">= 7.24", "< 9"] 30 | gem 'puppet', puppetversion, :require => false, :groups => [:test] 31 | 32 | # vim: syntax=ruby 33 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | ## [v5.0.0](https://github.com/voxpupuli/puppet-php/tree/v5.0.0) (2017-08-07) 2 | ### Summary 3 | This backwards-incompatible release drops puppet 3, PHP 5.5 on Ubuntu, and the deprecated `php::extension` parameter `pecl_source`. It improves much of the internal code quality, and adds several useful features the most interesting of which is probably the `php::extension` parameter `ini_prefix`. 4 | 5 | ### Changed 6 | - Drop puppet 3 compatibility. 7 | - Bumped puppetlabs-apt lower bound to 4.1.0 8 | - Bumped puppetlabs-stdlib lower bound to 4.13.1 9 | 10 | ### Removed 11 | - Deprecated `php::extension` define parameters `pecl_source`. Use `source` instead. 12 | - PHP 5.5 support on ubuntu. 13 | 14 | ### Added 15 | - `php` class parameters `fpm_user` and `fpm_group` to customize php-fpm user/group. 16 | - `php::fpm` class parameters `user` and `group`. 17 | - `php::fpm::pool` define parameter `pm_process_idle_timeout` and pool.conf `pm.process_idle_timeout` directive. 18 | - `php::extension` class parameters `ini_prefix` and `install_options`. 19 | - Archlinux compatibility. 20 | - Bumped puppetlabs-apt upper bound to 5.0.0 21 | 22 | ### Fixed 23 | - Replaced validate functions with data types. 24 | - Linting issues. 25 | - Replace legacy facts with facts hash. 26 | - Simplify `php::extension` 27 | - Only apt dependency when `manage_repos => true` 28 | - No more example42/yum dependency 29 | 30 | ## 2017-02-11 Release [4.0.0] 31 | 32 | This is the last release with Puppet3 support! 33 | * Fix a bug turning `manage_repos` off on wheezy 34 | * Fix a deprecation warning on `apt::key` when using `manage_repos` on wheezy (#110). This change requires puppetlabs/apt at >= 1.8.0 35 | * Allow removal of config values (#124) 36 | * Add `phpversion` fact, for querying through PuppetDB or Foreman (#119) 37 | * Allow configuring the fpm pid file (#123) 38 | * Add embedded SAPI support (#115) 39 | * Add options to fpm config and pool configs (#139) 40 | * Add parameter logic for PHP 7 on Ubuntu/Debian (#180) 41 | * add SLES PHP 7.0 Support (#220) 42 | * allow packaged extensions to be loaded as zend extensions 43 | * Fix command to enable php extensions (#226) 44 | * Fix many rucocop warnings 45 | * Update module Ubuntu 14.04 default to official repository setup 46 | * Fix dependency for extentions with no package source 47 | * Allow packaged extensions to be loaded as Zend extensions 48 | * Support using an http proxy for downloading composer 49 | * Refactor classes php::fpm and php::fpm:service 50 | * Manage apache/PHP configurations on Debian and RHEL systems 51 | * use voxpupuli/archive to download composer 52 | * respect $manage_repos, do not include ::apt if set to false 53 | * Bump min version_requirement for Puppet + deps 54 | * allow pipe param for pecl extensions 55 | * Fix: composer auto_update: exec's environment must be array 56 | 57 | ### Breaking Changes 58 | * Deep merge `php::extensions` the same way as `php::settings`. This technically is a 59 | breaking change but should not affect many people. 60 | * PHP 5.6 is the default version on all systems now (except Ubuntu 16.04, where 7.0 is the default). 61 | * There's a php::globals class now, where global paramters (like the PHP version) are set. (#132) 62 | * Removal of php::repo::ubuntu::ppa (#218) 63 | 64 | ## 3.4.2 65 | * Fix a bug that changed the default of `php::manage_repos` to `false` on 66 | Debian-based operating systems except wheezy. It should be turned on by 67 | default. (#116) 68 | * Fix a bug that prevented reloading php-fpm on Ubuntu in some cases. 69 | (#117, #107) 70 | 71 | ## 3.4.1 72 | * Fix reloading php-fpm on Ubuntu trusty & utopic (#107) 73 | 74 | ## 3.4.0 75 | * New parameter `ppa` for class `php::repo::ubuntu` to specify the ppa 76 | name to use. We default to `ondrej/php5-oldstable` for precise and 77 | `ondrej/php5` otherwise. 78 | * New parameter `include` for `php::fpm::pool` resources to specify 79 | custom configuration files. 80 | 81 | ## 3.3.1 82 | * Make `systemd_interval` parameter for class `php::fpm::config` optional 83 | 84 | ## 3.3.0 85 | * `php::extension` resources: 86 | * New boolean parameter `settings_prefix` to automatically prefix all 87 | settings keys with the extensions names. Defaults to false to ensurre 88 | the current behaviour. 89 | * New string parameter `so_name` to set the DSO name of an extension if 90 | it doesn't match the package name. 91 | * New string parameter `php_api_version` to set a custom api version. If 92 | not `undef`, the `so_name` is prefixed with the full module path in the 93 | ini file. Defaults to `undef`. 94 | * The default of the parameter `listen_allowed_clients` of `php::fpm::pool` 95 | resources is now `undef` instead of `'127.0.0.1'`. This way it is more 96 | intuitive to change the default tcp listening socket at `127.0.0.1:9000` 97 | to a unix socket by only setting the `listen` parameter instead of 98 | additionally needing to unset `listen_allowed_clients`. This has no 99 | security implications. 100 | * New parameters for the `php::fpm::config` class: 101 | * `error_log` 102 | * `syslog_facility` 103 | * `syslog_ident` 104 | * `systemd_interval` 105 | * A bug that prevented merging the global `php::settings` parameter into 106 | SAPI configs for `php::cli` and `php::fpm` was fixed. 107 | * The dotdeb repos are now only installed for Debian wheezy as Debian jessie 108 | has a sufficiently recent PHP version. 109 | 110 | ## 3.2.2 111 | * Fix a typo in hiera keys `php::settings` & `php::fpm::settings` (#83) 112 | 113 | ## 3.2.1 114 | * Fixed default `yum_repo` key in `php::repo::redhat` 115 | * On Ubuntu precise we now use the ondrej/php5-oldstable ppa. This can be 116 | manually enabled with by setting `$php::repo::ubuntu::oldstable` to 117 | `true`. 118 | * `$php::ensure` now defaults to `present` instead of `latest`. Though, 119 | strictly speaking, this represents a functional change, we consider this 120 | to be a bugfix because automatic updates should be enabled explicitely. 121 | * `$php::ensure` is not anymore passed to `php::extension` resources as 122 | default ensure parameter because this doesn't make sense. 123 | 124 | ## 3.2.0 125 | * Support for FreeBSD added by Frank Wall 126 | * RedHat now uses remi-php56 yum repo by default 127 | * The resource `php::fpm::pool` is now public, you can use it in your 128 | manifests without using `$php::fpm::pools` 129 | * We now have autogenerated documentation using `puppetlabs/strings` 130 | 131 | ## 3.1.0 132 | * New parameter `pool_purge` for `php::extension` to remove files not 133 | managed by puppet from the pool directory. 134 | * The `pecl_source` parameter for `php::extension` was renamend to 135 | `source` because it is also useful for PEAR extensions. 136 | `pecl_source` can still be used but is deprecated and will be 137 | removed in the next major release. 138 | * Parameters referring to time in `php::fpm::config` can now be 139 | specified with units (i.e. `'60s'`, `'1d'`): 140 | * `emergency_restart_threshold` 141 | * `emergency_restart_interval` 142 | * `process_control_timeout` 143 | * The PEAR version is not independant of `$php::ensure` and can be 144 | configured with `$php::pear_ensure` 145 | * Give special thanks to the contributors of this release: 146 | * Petr Sedlacek 147 | * Sherlan Moriah 148 | 149 | ## 3.0.1 150 | * Fix typo in package suffix for php-fpm on RHEL in params.pp 151 | 152 | ## 3.0.0 153 | * Removes `$php::fpm::pool::error_log`. Use the `php_admin_flag` and 154 | `php_admin_value` parameters to set the php settings `log_errors` and 155 | `error_log` instead. 156 | * Removes support for PHP 5.3 on Debian-based systems. See the notes in the 157 | README for more information. 158 | * Removes the `php_version` fact which had only worked on the later puppet runs. 159 | * Moves CLI-package handling to `php::packages` 160 | * Allows changing the package prefix via `php::package_prefix`. 161 | * Moves FPM-package handling from `php::fpm::package` to `php::fpm` 162 | * Changes `php::packages`, so that `php::packages::packages` becomes 163 | `php::packages::names` and are installed and `php::packages::names_to_prefix` 164 | are installed prefixed by `php::package_prefix`. 165 | * PHPUnit is now installed as phar in the same way composer is installed, 166 | causing all parameters to change 167 | * The `php::extension` resource has a new parameter: `zend`. If set to true, 168 | exenstions that were installed with pecl are loaded with `zend_extension`. 169 | 170 | ## 2.0.4 171 | * Style fixes all over the place 172 | * Module dependencies are now bound to the current major version 173 | 174 | ## 2.0.3 175 | * Some issues & bugs with extensions were fixed 176 | * If you set the `provider` parameter of an extension to `"none"`, no 177 | extension packages will be installed 178 | * The EPEL yum repo has been added for RedHat systems 179 | 180 | ## 2.0.2 181 | * Adds support for `header_packages` on all extensions 182 | * Adds `install_options` to pear package provider 183 | 184 | ## 2.0.1 185 | * This is a pure bug fix release 186 | * Fix for CVE 2014-0185 (https://bugs.php.net/bug.php?id=67060) 187 | 188 | ## 2.0.0 189 | * Remove augeas and switch to puppetlabs/inifile for configs 190 | * Old: `settings => [‘set PHP/short_open_tag On‘]` 191 | * New: `settings => {‘PHP/short_open_tag’ => ‘On‘}` 192 | * Settings parmeter cleanups 193 | * The parameter `config` of `php::extension` resources is now called `settings` 194 | * The parameters `user` and `group` of `php::fpm` have been moved to `php::fpm::config` 195 | * New parameter `php::settings` for global settings (i.e. CLI & FPM) 196 | * New parameter `php::cli` to disable CLI if supported 197 | 198 | ## 1.1.2 199 | * SLES: PHP 5.5 will now be installed 200 | * Pecl extensions now autoload the .so based on $name instead of $title 201 | 202 | ## 1.1.1 203 | * some nasty bugs with the pecl php::extension provider were fixed 204 | * php::extension now has a new pecl_source parameter for specifying custom 205 | source channels for the pecl provider 206 | 207 | ## 1.1.0 208 | * add phpunit to main class 209 | * fix variable access for augeas 210 | 211 | ## 1.0.2 212 | * use correct suse apache service name 213 | * fix anchoring of augeas 214 | 215 | ## 1.0.1 216 | * fixes #9 undefined pool_base_dir 217 | 218 | ## 1.0.0 219 | Initial release 220 | 221 | [4.1.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v4.0.0...v4.1.0 222 | [4.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v3.4.2...v4.0.0 223 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012-2013 Christian "Jippi" Winther 4 | Copyright (c) 2012-2013 Tobias Nyholm 5 | Copyright (c) 2014-2015 Mayflower GmbH 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Puppet Forge](http://img.shields.io/puppetforge/v/puppet/php.svg)](https://forge.puppetlabs.com/puppet/php) 2 | 3 | # voxpupuli/php Puppet Module 4 | 5 | voxpupuli/php is a Puppet module for managing PHP with a strong focus 6 | on php-fpm. The module aims to use sane defaults for the supported 7 | architectures. We strive to support all recent versions of Debian, 8 | Ubuntu, RedHat/CentOS, openSUSE/SLES and FreeBSD. Managing Apache 9 | with `mod_php` is not supported. 10 | 11 | This originally was a fork of [jippi/puppet-php](https://github.com/jippi/puppet-php) 12 | (nodes-php on Puppet Forge) but has since been rewritten in large parts. 13 | 14 | ## Usage 15 | 16 | Quickest way to get started is simply `include`'ing the _`php` class_. 17 | 18 | ```puppet 19 | include 'php' 20 | ``` 21 | 22 | Or, you can override defaults and specify additional custom 23 | configurations by declaring `class { 'php': }` with parameters: 24 | 25 | ```puppet 26 | class { 'php': 27 | ensure => latest, 28 | manage_repos => true, 29 | fpm => true, 30 | dev => true, 31 | composer => true, 32 | pear => true, 33 | phpunit => false, 34 | } 35 | ``` 36 | 37 | Optionally the PHP version or configuration root directory can be changed also: 38 | 39 | ```puppet 40 | class { 'php::globals': 41 | php_version => '7.0', 42 | config_root => '/etc/php/7.0', 43 | }-> 44 | class { 'php': 45 | manage_repos => true 46 | } 47 | ``` 48 | 49 | There are more configuration options available. Please refer to the 50 | auto-generated documentation at [REFERENCE.md](REFERENCE.md). 51 | 52 | ### Defining `php.ini` settings 53 | 54 | PHP configuration parameters in `php.ini` files can be defined as parameter 55 | `settings` on the main `php` class, or `php::fpm` / `php::cli` classes, 56 | or `php::extension` resources for each component independently. 57 | 58 | These settings are written into their respective `php.ini` file. Global 59 | settings in `php::settings` are merged with the settings of all components. 60 | Please note that settings of extensions are always independent. 61 | 62 | In the following example the PHP options and timezone will be set in 63 | all PHP configurations, i.e. the PHP cli application and all php-fpm pools. 64 | 65 | ```puppet 66 | class { 'php': 67 | settings => { 68 | 'PHP/max_execution_time' => '90', 69 | 'PHP/max_input_time' => '300', 70 | 'PHP/memory_limit' => '64M', 71 | 'PHP/post_max_size' => '32M', 72 | 'PHP/upload_max_filesize' => '32M', 73 | 'Date/date.timezone' => 'Europe/Berlin', 74 | }, 75 | } 76 | ``` 77 | 78 | ### Installing extensions 79 | 80 | PHP configuration parameters in `php.ini` files can be defined 81 | as parameter `extensions` on the main `php` class. They are 82 | activated for all activated SAPIs. 83 | 84 | ```puppet 85 | class { 'php': 86 | extensions => { 87 | bcmath => { }, 88 | imagick => { 89 | provider => pecl, 90 | }, 91 | xmlrpc => { }, 92 | memcached => { 93 | provider => 'pecl', 94 | header_packages => [ 'libmemcached-devel', ], 95 | }, 96 | apc => { 97 | provider => 'pecl', 98 | settings => { 99 | 'apc/stat' => '1', 100 | 'apc/stat_ctime' => '1', 101 | }, 102 | sapi => 'fpm', 103 | }, 104 | }, 105 | } 106 | ``` 107 | 108 | See [the documentation](REFERENCE.md#php--extension) of the `php::extension` 109 | resource for all available parameters and default values. 110 | 111 | ### Defining php-fpm pools 112 | 113 | If different php-fpm pools are required, you can use `php::fpm::pool` 114 | defined resource type. A single pool called `www` will be configured 115 | by default. Specify additional pools like so: 116 | 117 | ```puppet 118 | php::fpm::pool { 'www2': 119 | listen => '127.0.1.1:9000', 120 | } 121 | ``` 122 | 123 | For an overview of all possible parameters for `php::fpm::pool` resources please 124 | see [its documentation](REFERENCE.md#php--fpm--pool). 125 | 126 | ### Overriding php-fpm user 127 | 128 | By default, php-fpm is set up to run as Apache. If you need to customize that user, you can do that like so: 129 | 130 | ```puppet 131 | class { 'php': 132 | fpm_user => 'nginx', 133 | fpm_group => 'nginx', 134 | } 135 | ``` 136 | 137 | ### PHP with one FPM pool per user 138 | 139 | This will create one vhost. $users is an array of people having php files at 140 | $fqdn/$user. This code uses voxpupuli/php and voxpupuli/nginx to create 141 | the vhost and one php fpm pool per user. This was tested on Archlinux with 142 | nginx 1.13 and PHP 7.2.3. 143 | 144 | ```puppet 145 | $users = ['bob', 'alice'] 146 | 147 | class { 'php': 148 | ensure => 'present', 149 | manage_repos => false, 150 | fpm => true, 151 | dev => false, 152 | composer => false, 153 | pear => true, 154 | phpunit => false, 155 | fpm_pools => {}, 156 | } 157 | 158 | include nginx 159 | 160 | nginx::resource::server{$facts['fqdn']: 161 | www_root => '/var/www', 162 | autoindex => 'on', 163 | } 164 | nginx::resource::location{'dontexportprivatedata': 165 | server => $facts['fqdn'], 166 | location => '~ /\.', 167 | location_deny => ['all'], 168 | } 169 | $users.each |$user| { 170 | # create one fpm pool. will be owned by the specific user 171 | # fpm socket will be owned by the nginx user 'http' 172 | php::fpm::pool{$user: 173 | user => $user, 174 | group => $user, 175 | listen_owner => 'http', 176 | listen_group => 'http', 177 | listen_mode => '0660', 178 | listen => "/var/run/php-fpm/${user}-fpm.sock", 179 | } 180 | nginx::resource::location { "${name}_root": 181 | ensure => 'present', 182 | server => $facts['fqdn'], 183 | location => "~ .*${user}\/.*\.php$", 184 | index_files => ['index.php'], 185 | fastcgi => "unix:/var/run/php-fpm/${user}-fpm.sock", 186 | include => ['fastcgi.conf'], 187 | } 188 | } 189 | ``` 190 | 191 | ### Alternative examples using Hiera 192 | 193 | Alternative to the Puppet DSL code examples above, you may optionally define your PHP configuration using Hiera. 194 | 195 | Below are all the examples you see above, but defined in YAML format for use with Hiera. 196 | 197 | ```yaml 198 | --- 199 | php::ensure: latest 200 | php::manage_repos: true 201 | php::fpm: true 202 | php::fpm_user: 'nginx' 203 | php::fpm_group: 'nginx' 204 | php::dev: true 205 | php::composer: true 206 | php::pear: true 207 | php::phpunit: false 208 | php::settings: 209 | 'PHP/max_execution_time': '90' 210 | 'PHP/max_input_time': '300' 211 | 'PHP/memory_limit': '64M' 212 | 'PHP/post_max_size': '32M' 213 | 'PHP/upload_max_filesize': '32M' 214 | 'Date/date.timezone': 'Europe/Berlin' 215 | php::extensions: 216 | bcmath: {} 217 | xmlrpc: {} 218 | imagick: 219 | provider: pecl 220 | memcached: 221 | provider: pecl 222 | header_packages: 223 | - libmemcached-dev 224 | apc: 225 | provider: pecl 226 | settings: 227 | 'apc/stat': 1 228 | 'apc/stat_ctime': 1 229 | sapi: 'fpm' 230 | php::fpm::pools: 231 | www2: 232 | listen: '127.0.1.1:9000' 233 | ``` 234 | 235 | ## Notes 236 | 237 | ### Inheriting configuration across multiple Hiera sources 238 | 239 | Configuration from Hiera such as `php::fpm::pools` is automatically 240 | lookup up using the "first" merge method. This means that the first 241 | value found is used. If you instead want to merge the hash keys 242 | across multiple Hiera sources, you can use [`lookup_options`] to 243 | set [`hash` or `deep` behaviors] such as in the example 244 | [data/default.yaml](data/default.yaml): 245 | 246 | ```yaml 247 | lookup_options: 248 | php::fpm::pools: 249 | merge: hash 250 | ``` 251 | 252 | [`lookup_options`]: https://puppet.com/docs/puppet/latest/hiera_merging.html#setting_lookup_options_to_refine_the_result_of_a_lookup 253 | [`hash` or `deep` behaviors]: https://puppet.com/docs/puppet/latest/hiera_merging.html#merge_behaviors 254 | 255 | ### Ubuntu systems and Ondřej's PPA 256 | 257 | The older Ubuntu PPAs run by Ondřej have been deprecated (ondrej/php5, ondrej/php5.6) 258 | in favor of a new PPA: ondrej/php which contains all 3 versions of PHP: 5.5, 5.6, and 7.0 259 | Here's an example in hiera of getting PHP 5.6 installed with php-fpm, pear/pecl, and composer: 260 | 261 | ```puppet 262 | php::globals::php_version: '5.6' 263 | php::fpm: true 264 | php::dev: true 265 | php::composer: true 266 | php::pear: true 267 | php::phpunit: false 268 | ``` 269 | 270 | If you do not specify a php version, in Ubuntu the default will be 7.0 if you are 271 | running Xenial (16.04), otherwise PHP 5.6 will be installed (for other versions) 272 | 273 | ### Apache support 274 | 275 | Apache with `mod_php` is not supported by this module. Please use 276 | [puppetlabs/apache](https://forge.puppetlabs.com/puppetlabs/apache) instead. 277 | 278 | We prefer using php-fpm. You can find an example Apache vhost in 279 | `manifests/apache_vhost.pp` that shows you how to use `mod_proxy_fcgi` to 280 | connect to php-fpm. 281 | 282 | ### ZendPHP support 283 | 284 | > Be sure to require the `zend/zend_common` puppet module 285 | > to ensure the correct package repository is being used. 286 | 287 | To use ZendPHP, configure the global zend parameters. 288 | 289 | ```puppet 290 | class { 'php::globals': 291 | php_version => '7.4', 292 | flavor => 'zend', 293 | zend_creds => { 294 | 'username' => '', 295 | 'password' => '', 296 | }, 297 | }-> 298 | class { 'php': 299 | fpm => true, 300 | fpm_pools => { 301 | www => { 302 | listen => "127.0.0.1:9000", 303 | }, 304 | } 305 | } 306 | ``` 307 | 308 | #### ZendPHP soft dependencies on RedHat/CentOS/Rocky 309 | 310 | Due to the nature of ZendPHP delivering patched, LTS versions of PHP and its extensions, 311 | RedHat systems sometimes depend on `epel` and the `powertools` repo. 312 | 313 | If you're trying to use ZendPHP and running into issues of missing dependencies, 314 | first try installing epel. If the dependencies still can't be found, try 315 | enabling `powertools`. 316 | 317 | ```puppet 318 | if $facts['os']['family'] == 'RedHat' { 319 | package { 'epel-release': } 320 | 321 | if Float($php_version) < 7.4 { 322 | # Depends on puppet/yum 323 | class { 'yum': 324 | managed_repos => ['powertools'], 325 | repos => { 326 | 'powertools' => { 327 | enabled => true, 328 | }, 329 | }, 330 | } 331 | } 332 | } 333 | ``` 334 | 335 | ### RedHat/CentOS SCL Users 336 | 337 | If you plan to use the SCL repositories with this module you must do the following adjustments: 338 | 339 | #### General config 340 | 341 | This ensures that the module will create configurations in the directory 342 | `/etc/opt/rh//` (also in php.d/ for extensions). Anyway you have to 343 | manage the SCL repo's by your own. 344 | 345 | ```puppet 346 | class { 'php::globals': 347 | php_version => 'rh-php71', 348 | rhscl_mode => 'rhscl', 349 | } 350 | -> class { 'php': 351 | manage_repos => false 352 | } 353 | ``` 354 | 355 | #### Extensions 356 | 357 | Extensions in SCL are being installed with packages that cover 1 or more .so files. This is kinda incompatible with 358 | this module, since this module specifies an extension by name and derives the name of the package and the config (.ini) 359 | from it. To manage extensions of SCL packages you must use the following parameters: 360 | 361 | ```puppet 362 | class { 'php': 363 | ... 364 | extensions => { 365 | 'soap' => { 366 | ini_prefix => '20-', 367 | }, 368 | } 369 | } 370 | ``` 371 | 372 | By this you tell the module to configure bz2 and calender while ensuring only the package `common`. Additionally to the 373 | installation of 'common' the ini files 'calender.ini' and 'bz2.ini' will be created by the scheme 374 | ``. 375 | 376 | A list of commonly used modules: 377 | 378 | ```puppet 379 | { 380 | extensions => { 381 | 'xml' => { 382 | ini_prefix => '20-', 383 | multifile_settings => true, 384 | settings => { 385 | 'dom' => {}, 386 | 'simplexml' => {}, 387 | 'xmlwriter' => {}, 388 | 'xsl' => {}, 389 | 'wddx' => {}, 390 | 'xmlreader' => {}, 391 | }, 392 | }, 393 | 'soap' => { 394 | ini_prefix => '20-', 395 | }, 396 | 'imap' => { 397 | ini_prefix => '20-', 398 | }, 399 | 'intl' => { 400 | ini_prefix => '20-', 401 | }, 402 | 'gd' => { 403 | ini_prefix => '20-', 404 | }, 405 | 'mbstring' => { 406 | ini_prefix => '20-', 407 | }, 408 | 'xmlrpc' => { 409 | ini_prefix => '20-', 410 | }, 411 | 'pdo' => { 412 | ini_prefix => '20-', 413 | multifile_settings => true, 414 | settings => { 415 | 'pdo' => {}, 416 | 'pdo_sqlite' => {}, 417 | 'sqlite3' => {}, 418 | }, 419 | }, 420 | 'process' => { 421 | ini_prefix => '20-', 422 | multifile_settings => true, 423 | settings => { 424 | 'posix' => {}, 425 | 'shmop' => {}, 426 | 'sysvmsg' => {}, 427 | 'sysvsem' => {}, 428 | 'sysvshm' => {}, 429 | }, 430 | }, 431 | 'mysqlnd' => { 432 | ini_prefix => '30-', 433 | multifile_settings => true, 434 | settings => { 435 | 'mysqlnd' => {}, 436 | 'mysql' => {}, 437 | 'mysqli' => {}, 438 | 'pdo_mysql' => {}, 439 | 'sysvshm' => {}, 440 | }, 441 | }, 442 | } 443 | } 444 | ``` 445 | 446 | ### Facts 447 | 448 | We deliver a `phpversion` fact with this module. This is explicitly **NOT** intended 449 | to be used within your puppet manifests as it will only work on your second puppet 450 | run. Its intention is to make querying PHP versions per server easy via PuppetDB or Foreman. 451 | 452 | ### FreeBSD support 453 | 454 | On FreeBSD systems we purge the system-wide `extensions.ini` in favour of 455 | per-module configuration files. 456 | 457 | Please also note that support for Composer and PHPUnit on FreeBSD is untested 458 | and thus likely incomplete. 459 | 460 | ### Running the test suite 461 | 462 | To run the tests install the ruby dependencies with `bundler` and execute 463 | `rake`: 464 | 465 | ```bash 466 | bundle install --path vendor/bundle 467 | bundle exec rake 468 | ``` 469 | 470 | ## Bugs & New Features 471 | 472 | If you happen to stumble upon a bug, please feel free to create a pull request 473 | with a fix (optionally with a test), and a description of the bug and how it 474 | was resolved. 475 | 476 | Or if you're not into coding, simply create an issue adding steps to let us 477 | reproduce the bug and we will happily fix it. 478 | 479 | If you have a good idea for a feature or how to improve this module in general, 480 | please create an issue to discuss it. We are very open to feedback. Pull 481 | requests are always welcome. 482 | 483 | We hate orphaned and unmaintained Puppet modules as much as you do and 484 | therefore promise that we will continue to maintain this module and keep 485 | response times to issues short. If we happen to lose interest, we will write 486 | a big fat warning into this README to let you know. 487 | 488 | ## License 489 | 490 | The project is released under the permissive MIT license. 491 | 492 | The source can be found at 493 | [github.com/voxpupuli/puppet-php](https://github.com/voxpupuli/puppet-php/). 494 | 495 | This Puppet module was originally maintained by some fellow puppeteers at 496 | [Mayflower GmbH](https://mayflower.de) and is now maintained by 497 | [Vox Pupuli](https://voxpupuli.org/). 498 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | # Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), 5 | # otherwise attempt to load it directly. 6 | begin 7 | require 'voxpupuli/test/rake' 8 | rescue LoadError 9 | begin 10 | require 'puppetlabs_spec_helper/rake_tasks' 11 | rescue LoadError 12 | end 13 | end 14 | 15 | # load optional tasks for acceptance 16 | # only available if gem group releases is installed 17 | begin 18 | require 'voxpupuli/acceptance/rake' 19 | rescue LoadError 20 | end 21 | 22 | # load optional tasks for releases 23 | # only available if gem group releases is installed 24 | begin 25 | require 'voxpupuli/release/rake_tasks' 26 | rescue LoadError 27 | # voxpupuli-release not present 28 | else 29 | GCGConfig.user = 'voxpupuli' 30 | GCGConfig.project = 'puppet-php' 31 | end 32 | 33 | desc "Run main 'test' task and report merged results to coveralls" 34 | task test_with_coveralls: [:test] do 35 | if Dir.exist?(File.expand_path('../lib', __FILE__)) 36 | require 'coveralls/rake/task' 37 | Coveralls::RakeTask.new 38 | Rake::Task['coveralls:push'].invoke 39 | else 40 | puts 'Skipping reporting to coveralls. Module has no lib dir' 41 | end 42 | end 43 | 44 | # vim: syntax=ruby 45 | -------------------------------------------------------------------------------- /data/default.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | lookup_options: 4 | php::fpm::pools: 5 | merge: first 6 | 7 | -------------------------------------------------------------------------------- /hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 5 3 | hierarchy: 4 | - name: default.yaml 5 | paths: 6 | - 'default.yaml' 7 | -------------------------------------------------------------------------------- /lib/facter/phpversion.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Facter.add(:phpversion) do 4 | setcode do 5 | output = Facter::Util::Resolution.exec('php -v') 6 | 7 | unless output.nil? 8 | output.split("\n").first.split. 9 | grep(%r{^(?:(\d+)\.)(?:(\d+)\.)?(\*|\d+)}).first 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/puppet/functions/php/ensure_prefix.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # @summary Ensures a prefix for all elements in an array or the keys in a hash. 4 | # 5 | # This function ensures a prefix for all elements in an array or the keys in a hash. 6 | # If called with an empty, or `nil` prefix, will return the original data. 7 | # 8 | # @example Calling the function with an Array 9 | # php::ensure_prefix(['a', 'p.b', 'c'], 'p.') 10 | # # Will return: ['p.a', 'p.b', 'p.c'] 11 | # 12 | # @example Calling the function with a Hash 13 | # php::ensure_prefix({'a' => 1, 'b' => 2, 'p.c' => 3}, 'p.') 14 | # # Will return: {'p.a' => 1, 'p.b' => 2, 'p.c' => 3} 15 | Puppet::Functions.create_function(:'php::ensure_prefix') do 16 | # @param enumerable An Array or Hash 17 | # @param prefix An empty prefix 18 | # @return Will return the original enumerable unmodified. 19 | dispatch :noop do 20 | param 'Variant[Array, Hash]', :enumerable 21 | param 'Variant[Undef, String[0,0]]', :prefix 22 | return_type 'Variant[Array[String], Hash[String, Any]]' 23 | end 24 | 25 | # @param array The input Array. 26 | # @param prefix A string that you want prefixed to all elements in the array if not already present. 27 | # @return The `array` with each element prefixed with `prefix`. 28 | dispatch :ensure_prefix_array do 29 | param 'Array', :array 30 | param 'String[1]', :prefix 31 | return_type 'Array[String]' 32 | end 33 | 34 | # @param hash The input Hash. 35 | # @param prefix A string that you want prefixed to all keys in the hash if not already present. 36 | # @return The `hash` with each key prefixed with `prefix`. 37 | dispatch :ensure_prefix_hash do 38 | param 'Hash', :hash 39 | param 'String[1]', :prefix 40 | return_type 'Hash[String, Any]' 41 | end 42 | 43 | def noop(enumerable, _prefix) 44 | enumerable 45 | end 46 | 47 | def ensure_prefix_array(array, prefix) 48 | array.map { |item| prefix_item(item, prefix) } 49 | end 50 | 51 | def ensure_prefix_hash(hash, prefix) 52 | hash.transform_keys { |key| prefix_item(key, prefix) } 53 | end 54 | 55 | private 56 | 57 | def prefix_item(raw, prefix) 58 | string = raw.to_s 59 | string.start_with?(prefix) ? string : prefix + string 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /lib/puppet/parser/functions/to_hash_settings.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Puppet::Parser::Functions 4 | newfunction(:to_hash_settings, type: :rvalue, doc: <<-EOS 5 | This function converts a +{key => value}+ hash into a nested hash and can add an id to the outer key. 6 | The optional id string as second parameter is prepended to the resource name. 7 | 8 | *Examples:* 9 | 10 | to_hash_settings({'a' => 1, 'b' => 2}) 11 | 12 | Would return: 13 | { 14 | 'a' => {'key' => 'a', 'value' => 1}, 15 | 'b' => {'key' => 'b', 'value' => 2} 16 | } 17 | 18 | and: 19 | 20 | to_hash_settings({'a' => 1, 'b' => 2}, 'foo') 21 | 22 | Would return: 23 | { 24 | 'foo: a' => {'key' => 'a', 'value' => 1}, 25 | 'foo: b' => {'key' => 'b', 'value' => 2} 26 | } 27 | EOS 28 | ) do |arguments| 29 | hash, id = arguments 30 | id = (id.nil? ? '' : "#{id}: ") 31 | 32 | raise(Puppet::ParseError, 'to_hash_settings(): Requires hash to work with') unless hash.is_a?(Hash) 33 | 34 | return hash.each_with_object({}) do |kv, acc| 35 | acc[id + kv[0]] = { 'key' => kv[0], 'value' => kv[1] } 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/puppet/provider/package/pear.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'puppet/provider/package' 4 | 5 | Puppet::Type.type(:package).provide :pear, parent: Puppet::Provider::Package do 6 | desc 'Package management via `pear`.' 7 | 8 | has_feature :versionable 9 | has_feature :upgradeable 10 | has_feature :install_options 11 | 12 | commands pear: 'pear' 13 | 14 | ENV['TERM'] = 'dumb' # remove colors 15 | 16 | def self.pearlist(only = nil) 17 | channel = nil 18 | 19 | packages = pear('list', '-a').split("\n").map do |line| 20 | # current channel 21 | %r{INSTALLED PACKAGES, CHANNEL (.*):}i.match(line) { |m| channel = m[1].downcase } 22 | 23 | # parse one package 24 | pearsplit(line, channel) 25 | end.compact 26 | 27 | return packages unless only 28 | 29 | packages.find do |pkg| 30 | pkg[:name].casecmp(only[:name].downcase).zero? 31 | end 32 | end 33 | 34 | def self.pearsplit(desc, channel) 35 | desc.strip! 36 | 37 | # rubocop:disable Lint/DuplicateBranch 38 | case desc 39 | when '' then nil 40 | when %r{^installed}i then nil 41 | when %r{no packages installed}i then nil 42 | when %r{^=} then nil 43 | when %r{^package}i then nil 44 | when %r{^(\S+)\s+(\S+)\s+(\S+)\s*$} 45 | name = Regexp.last_match(1) 46 | version = Regexp.last_match(2) 47 | state = Regexp.last_match(3) 48 | 49 | { 50 | name: name, 51 | vendor: channel, 52 | ensure: state == 'stable' ? version : state, 53 | provider: self.name 54 | } 55 | else 56 | Puppet.warning format('Could not match %s', desc) 57 | nil 58 | end 59 | # rubocop:enable Lint/DuplicateBranch 60 | end 61 | 62 | def self.instances 63 | pearlist.map do |hash| 64 | new(hash) 65 | end 66 | end 67 | 68 | def install(useversion = true) 69 | command = ['-D', 'auto_discover=1', 'upgrade'] 70 | 71 | if @resource[:install_options] 72 | command += join_options(@resource[:install_options]) 73 | else 74 | command << '--alldeps' 75 | end 76 | 77 | if !@resource[:ensure].is_a?(Symbol) && useversion 78 | command << '-f' 79 | pear_pkg = "#{@resource[:source] || @resource[:name]}-#{@resource[:ensure]}" 80 | else 81 | pear_pkg = @resource[:source] || @resource[:name] 82 | end 83 | command << pear_pkg 84 | 85 | if @resource[:responsefile] 86 | Puppet::Util::Execution.execute( 87 | [command(:pear)] + command, 88 | stdinfile: @resource[:responsefile] 89 | ) 90 | else 91 | pear(*command) 92 | end 93 | end 94 | 95 | def latest 96 | target = @resource[:source] || @resource[:name] 97 | pear('remote-info', target).lines.find do |set| 98 | set =~ %r{^Latest} 99 | end.split[1] 100 | end 101 | 102 | def query 103 | self.class.pearlist(@resource) 104 | end 105 | 106 | def uninstall 107 | output = pear 'uninstall', @resource[:name] 108 | raise Puppet::Error, output unless output =~ %r{^uninstall ok} 109 | end 110 | 111 | def update 112 | install(false) 113 | end 114 | end 115 | -------------------------------------------------------------------------------- /lib/puppet/provider/package/pecl.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'puppet/provider/package' 4 | 5 | Puppet::Type.type(:package).provide :pecl, parent: :pear do 6 | desc 'Package management via `pecl`.' 7 | 8 | has_feature :versionable 9 | has_feature :upgradeable 10 | has_feature :install_options 11 | 12 | commands pear: 'pear' 13 | 14 | def self.instances 15 | pear_packages = super 16 | 17 | pear_packages.select do |pkg| 18 | pkg.properties[:vendor] == 'pecl.php.net' 19 | end 20 | end 21 | 22 | def convert_to_pear 23 | @resource[:source] = "pecl.php.net/#{@resource[:name]}" 24 | end 25 | 26 | def install(useversion = true) 27 | convert_to_pear 28 | super(useversion) 29 | end 30 | 31 | def latest 32 | convert_to_pear 33 | super 34 | end 35 | 36 | def uninstall 37 | convert_to_pear 38 | super 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /manifests/apache_config.pp: -------------------------------------------------------------------------------- 1 | # Install and configure php apache settings 2 | # 3 | # === Parameters 4 | # 5 | # [*inifile*] 6 | # The path to the ini php-apache ini file 7 | # 8 | # [*settings*] 9 | # Hash with nested hash of key => value to set in inifile 10 | # 11 | class php::apache_config ( 12 | Stdlib::Absolutepath $inifile = $php::params::apache_inifile, 13 | Hash $settings = {} 14 | ) inherits php::params { 15 | assert_private() 16 | 17 | $real_settings = lookup('php::apache::settings', Hash, { 'strategy' => 'deep', 'merge_hash_arrays' => true }, $settings) 18 | 19 | php::config { 'apache': 20 | file => $inifile, 21 | config => $real_settings, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /manifests/apache_vhost.pp: -------------------------------------------------------------------------------- 1 | # Configures an apache vhost for php 2 | # 3 | # === Parameters 4 | # 5 | # [*vhost*] 6 | # The vhost address 7 | # 8 | # [*docroot*] 9 | # The vhost docroot 10 | # 11 | # [*port*] 12 | # The vhost port 13 | # 14 | # [*default_vhost*] 15 | # defines if vhost is the default vhost 16 | # 17 | # [*fastcgi_socket*] 18 | # address of the fastcgi socket 19 | # 20 | define php::apache_vhost ( 21 | String[1] $vhost = 'example.com', 22 | Stdlib::Absolutepath $docroot = '/var/www', 23 | Integer[1] $port = 80, 24 | Boolean $default_vhost = true, 25 | String[1] $fastcgi_socket = 'fcgi://127.0.0.1:9000/$1' 26 | ) { 27 | ::apache::vhost { $vhost: 28 | docroot => $docroot, 29 | default_vhost => $default_vhost, 30 | port => $port, 31 | override => 'all', 32 | custom_fragment => "ProxyPassMatch ^/(.*\\.php(/.*)?)$ ${fastcgi_socket}", 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /manifests/cli.pp: -------------------------------------------------------------------------------- 1 | # Install and configure php CLI 2 | # 3 | # === Parameters 4 | # 5 | # [*inifile*] 6 | # The path to the ini php5-cli ini file 7 | # 8 | # [*settings*] 9 | # Hash with nested hash of key => value to set in inifile 10 | # 11 | class php::cli ( 12 | Stdlib::Absolutepath $inifile = $php::params::cli_inifile, 13 | Hash $settings = {} 14 | ) inherits php::params { 15 | assert_private() 16 | 17 | if $php::globals::rhscl_mode { 18 | # stupid fixes for scl 19 | file { '/usr/bin/pear': 20 | ensure => 'link', 21 | target => "${$php::params::php_bin_dir}/pear", 22 | } 23 | 24 | file { '/usr/bin/pecl': 25 | ensure => 'link', 26 | target => "${$php::params::php_bin_dir}/pecl", 27 | } 28 | 29 | file { '/usr/bin/php': 30 | ensure => 'link', 31 | target => "${$php::params::php_bin_dir}/php", 32 | } 33 | } 34 | 35 | $real_settings = lookup('php::cli::settings', Hash, { 'strategy' => 'deep', 'merge_hash_arrays' => true }, $settings) 36 | 37 | if $inifile != $php::params::config_root_inifile { 38 | # only create a cli specific inifile if the filenames are different 39 | php::config { 'cli': 40 | file => $inifile, 41 | config => $real_settings, 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /manifests/composer.pp: -------------------------------------------------------------------------------- 1 | # Install composer package manager 2 | # 3 | # === Parameters 4 | # 5 | # [*source*] 6 | # Holds URL to the Composer source file 7 | # 8 | # [*path*] 9 | # Holds path to the Composer executable 10 | # 11 | # [*channel*] 12 | # Holds the Update channel (stable|preview|snapshot|1|2) 13 | # 14 | # [*proxy_type*] 15 | # proxy server type (none|http|https|ftp) 16 | # 17 | # [*proxy_server*] 18 | # specify a proxy server, with port number if needed. ie: https://example.com:8080. 19 | # 20 | # [*auto_update*] 21 | # Defines if composer should be auto updated 22 | # 23 | # [*max_age*] 24 | # Defines the time in days after which an auto-update gets executed 25 | # 26 | # [*root_group*] 27 | # UNIX group of the root user 28 | # 29 | class php::composer ( 30 | String $source = $php::params::composer_source, 31 | Stdlib::Absolutepath $path = $php::params::composer_path, 32 | Optional[String[1]] $proxy_type = undef, 33 | Optional[String[1]] $proxy_server = undef, 34 | Php::ComposerChannel $channel = 'stable', 35 | Boolean $auto_update = true, 36 | Integer $max_age = $php::params::composer_max_age, 37 | Variant[Integer, String] $root_group = $php::params::root_group, 38 | ) inherits php::params { 39 | assert_private() 40 | 41 | archive { 'download composer': 42 | path => $path, 43 | source => $source, 44 | proxy_type => $proxy_type, 45 | proxy_server => $proxy_server, 46 | } 47 | -> file { $path: 48 | mode => '0555', 49 | owner => root, 50 | group => $root_group, 51 | } 52 | 53 | if $auto_update { 54 | class { 'php::composer::auto_update': 55 | max_age => $max_age, 56 | source => $source, 57 | path => $path, 58 | channel => $channel, 59 | proxy_type => $proxy_type, 60 | proxy_server => $proxy_server, 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /manifests/composer/auto_update.pp: -------------------------------------------------------------------------------- 1 | # Install composer package manager 2 | # 3 | # === Parameters 4 | # 5 | # [*max_age*] 6 | # Defines number of days after which Composer should be updated 7 | # 8 | # [*source*] 9 | # Holds URL to the Composer source file 10 | # 11 | # [*path*] 12 | # Holds path to the Composer executable 13 | # 14 | # [*channel*] 15 | # Holds the Update channel (stable|preview|snapshot|1|2) 16 | # 17 | # [*proxy_type*] 18 | # proxy server type (none|http|https|ftp) 19 | # 20 | # [*proxy_server*] 21 | # specify a proxy server, with port number if needed. ie: https://example.com:8080. 22 | # 23 | # 24 | # === Examples 25 | # 26 | # include php::composer::auto_update 27 | # class { "php::composer::auto_update": 28 | # "max_age" => 90 29 | # } 30 | # 31 | class php::composer::auto_update ( 32 | Integer[1] $max_age, 33 | String[1] $source, 34 | Stdlib::Absolutepath $path, 35 | Php::ComposerChannel $channel = 'stable', 36 | Optional[String[1]] $proxy_type = undef, 37 | Optional[String[1]] $proxy_server = undef, 38 | ) { 39 | assert_private() 40 | if $proxy_server { 41 | if $proxy_server =~ Stdlib::HTTPUrl { 42 | $_proxy_server = $proxy_server 43 | } else { 44 | if $proxy_type { 45 | $_proxy_server = "${proxy_type}://${proxy_server}" 46 | } else { 47 | fail('proxy_type must be defined if proxy_server is not full URL (https://example.com)') 48 | } 49 | } 50 | $env = [ 51 | 'HOME=/root', 52 | "http_proxy=${_proxy_server}", 53 | "https_proxy=${_proxy_server}", 54 | ] 55 | } else { 56 | $env = ['HOME=/root'] 57 | } 58 | 59 | exec { 'update composer': 60 | # touch binary when an update is attempted to update its mtime for idempotency when no update is available 61 | command => "${path} --no-interaction --quiet self-update --${channel}; touch ${path}", 62 | environment => $env, 63 | onlyif => "test `find '${path}' -mtime +${max_age}`", 64 | path => ['/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin', '/usr/local/sbin'], 65 | require => [File[$path], Class['php::cli']], 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /manifests/config.pp: -------------------------------------------------------------------------------- 1 | # Configure php.ini settings for a PHP SAPI 2 | # 3 | # === Parameters 4 | # 5 | # [*file*] 6 | # The path to ini file 7 | # 8 | # [*config*] 9 | # Nested hash of key => value to apply to php.ini 10 | # 11 | # === Examples 12 | # 13 | # php::config { '$unique-name': 14 | # file => '$full_path_to_ini_file' 15 | # config => { 16 | # {'Date/date.timezone' => 'Europe/Berlin'} 17 | # } 18 | # } 19 | # 20 | define php::config ( 21 | Stdlib::Absolutepath $file, 22 | Hash $config 23 | ) { 24 | if $caller_module_name != $module_name { 25 | warning('php::config is private') 26 | } 27 | 28 | create_resources(::php::config::setting,to_hash_settings($config, $file), { file => $file }) 29 | } 30 | -------------------------------------------------------------------------------- /manifests/config/setting.pp: -------------------------------------------------------------------------------- 1 | # Configure php.ini settings 2 | # 3 | # === Parameters 4 | # 5 | # [*key*] 6 | # The key of the value, like `ini_setting` 7 | # 8 | # [*file*] 9 | # The path to ini file 10 | # 11 | # [*value*] 12 | # The value to set 13 | # 14 | # === Examples 15 | # 16 | # php::config::setting { 'Date/date.timezone': 17 | # file => '$full_path_to_ini_file' 18 | # value => 'Europe/Berlin' 19 | # } 20 | # 21 | define php::config::setting ( 22 | String[1] $key, 23 | Stdlib::Absolutepath $file, 24 | Optional[Variant[Integer, String]] $value = undef, 25 | ) { 26 | assert_private() 27 | 28 | $split_name = split($key, '/') 29 | if count($split_name) == 1 { 30 | $section = '' # lint:ignore:empty_string_assignment 31 | $setting = $split_name[0] 32 | } else { 33 | $section = $split_name[0] 34 | $setting = $split_name[1] 35 | } 36 | 37 | if $value == undef { 38 | $_ensure = 'absent' 39 | } else { 40 | $_ensure = 'present' 41 | } 42 | 43 | ini_setting { $name: 44 | ensure => $_ensure, 45 | value => $value, 46 | path => $file, 47 | section => $section, 48 | setting => $setting, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /manifests/dev.pp: -------------------------------------------------------------------------------- 1 | # Install the development package with headers for PHP 2 | # 3 | # === Parameters 4 | # 5 | # [*ensure*] 6 | # The PHP ensure of PHP dev to install 7 | # 8 | # [*package*] 9 | # The package name for the PHP development files 10 | # 11 | class php::dev ( 12 | String $ensure = $php::ensure, 13 | String $package = "${php::package_prefix}${php::params::dev_package_suffix}", 14 | Boolean $manage_repos = $php::manage_repos, 15 | ) inherits php::params { 16 | assert_private() 17 | 18 | # On FreeBSD, Arch there is no 'devel' package. If dev_package_suffix is undef, consider to not install. 19 | $real_package = $php::params::dev_package_suffix ? { 20 | undef => [], 21 | default => $package, 22 | } 23 | 24 | if $facts['os']['family'] == 'Debian' { 25 | # we can set the dependency only if we manage repos 26 | $require = $manage_repos ? { 27 | true => Class['apt::update'], 28 | false => undef, 29 | } 30 | } else { 31 | $require = undef 32 | } 33 | 34 | # Default PHP come with xml module and no seperate package for it 35 | if $facts['os']['name'] == 'Ubuntu' { 36 | stdlib::ensure_packages(["${php::package_prefix}xml"], { ensure => present, require => $require, }) 37 | } 38 | package { $real_package: 39 | ensure => $ensure, 40 | require => Class['php::packages'], 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /manifests/embedded.pp: -------------------------------------------------------------------------------- 1 | # Install and configure php embedded SAPI 2 | # 3 | # === Parameters 4 | # 5 | # [*inifile*] 6 | # The path to the ini php5-embeded ini file 7 | # 8 | # [*settings*] 9 | # Hash with nested hash of key => value to set in inifile 10 | # 11 | # [*package*] 12 | # Specify which package to install 13 | # 14 | # [*ensure*] 15 | # Specify which version of the package to install 16 | # 17 | class php::embedded ( 18 | String $ensure = $php::ensure, 19 | String $package = "${php::package_prefix}${php::params::embedded_package_suffix}", 20 | Stdlib::Absolutepath $inifile = $php::params::embedded_inifile, 21 | Hash $settings = {}, 22 | ) inherits php::params { 23 | assert_private() 24 | 25 | $real_settings = lookup( 26 | 'php::embedded::settings', 27 | Hash, { 28 | 'strategy' => 'deep', 29 | 'merge_hash_arrays' => true 30 | }, 31 | $settings 32 | ) 33 | 34 | $real_package = $facts['os']['family'] ? { 35 | 'Debian' => "lib${package}", 36 | default => $package, 37 | } 38 | 39 | package { $real_package: 40 | ensure => $ensure, 41 | require => Class['php::packages'], 42 | } 43 | -> php::config { 'embedded': 44 | file => $inifile, 45 | config => $real_settings, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /manifests/extension.pp: -------------------------------------------------------------------------------- 1 | # Install a PHP extension package 2 | # 3 | # === Parameters 4 | # 5 | # [*ensure*] 6 | # The ensure of the package to install 7 | # Could be "present", "absent", "latest", "installed" or a pinned version 8 | # 9 | # [*package_prefix*] 10 | # Prefix to prepend to the package name for the package provider 11 | # 12 | # [*package_name*] 13 | # Full package name for the package provider (e.g. php7.2-xml for 14 | # simlexml extension) 15 | # 16 | # [*provider*] 17 | # The provider used to install the package 18 | # Could be "pecl", "apt", "dpkg" or any other OS package provider 19 | # If set to "none", no package will be installed 20 | # 21 | # [*source*] 22 | # The source to install the extension from. Possible values 23 | # depend on the *provider* used 24 | # 25 | # [*so_name*] 26 | # The DSO name of the package (e.g. opcache for zendopcache) 27 | # 28 | # [*ini_prefix*] 29 | # An optional filename prefix for the settings file of the extension 30 | # 31 | # [*php_api_version*] 32 | # This parameter is used to build the full path to the extension 33 | # directory for zend_extension in PHP < 5.5 (e.g. 20100525) 34 | # 35 | # [*header_packages*] 36 | # System packages dependencies to install for extensions (e.g. for 37 | # memcached libmemcached-dev on Debian) 38 | # 39 | # [*compiler_packages*] 40 | # System packages dependencies to install for compiling extensions 41 | # (e.g. build-essential on Debian) 42 | # 43 | # [*zend*] 44 | # Boolean parameter, whether to load extension as zend_extension. 45 | # Defaults to false. 46 | # 47 | # [*settings*] 48 | # Hash of parameters for the specific extension, which will be written to the extensions config file by 49 | # php::extension::config or a hash of mutliple settings files, each with parameters 50 | # (multifile_settings must be true) 51 | # (f.ex. {p => '..'} or {'bz2' => {..}, {'math' => {...}}) 52 | # 53 | # [*multifile_settings*] 54 | # Set this to true if you specify multiple setting files in *settings*. This must be used when the PHP package 55 | # distribution bundles extensions in a single package (like 'common' bundles extensions 'bz2', ...) and each of 56 | # the extension comes with a separate settings file. 57 | # 58 | # [*settings_prefix*] 59 | # Boolean/String parameter, whether to prefix all setting keys with 60 | # the extension name or specified name. Defaults to false. 61 | # 62 | # [*sapi*] 63 | # String parameter, whether to specify ALL sapi or a specific sapi. 64 | # Defaults to ALL. 65 | # 66 | # [*responsefile*] 67 | # File containing answers for interactive extension setup. Supported 68 | # *providers*: pear, pecl. 69 | # 70 | # [*install_options*] 71 | # Array of String or Hash options to pass to the provider. 72 | # 73 | define php::extension ( 74 | String $ensure = $php::ensure, 75 | Optional[Php::Provider] $provider = undef, 76 | Optional[String] $source = undef, 77 | Optional[String] $so_name = undef, 78 | Optional[String] $ini_prefix = undef, 79 | Optional[String] $php_api_version = undef, 80 | String $package_prefix = $php::package_prefix, 81 | Optional[String[1]] $package_name = undef, 82 | Boolean $zend = false, 83 | Variant[Hash, Hash[String, Hash]] $settings = {}, 84 | Boolean $multifile_settings = false, 85 | Php::Sapi $sapi = 'ALL', 86 | Variant[Boolean, String] $settings_prefix = false, 87 | Optional[Stdlib::AbsolutePath] $responsefile = undef, 88 | Variant[String, Array[String]] $header_packages = [], 89 | Variant[String, Array[String]] $compiler_packages = $php::params::compiler_packages, 90 | Php::InstallOptions $install_options = undef, 91 | ) { 92 | if ! defined(Class['php']) { 93 | warning('php::extension is private') 94 | } 95 | 96 | php::extension::install { $title: 97 | ensure => $ensure, 98 | provider => $provider, 99 | source => $source, 100 | responsefile => $responsefile, 101 | package_prefix => $package_prefix, 102 | package_name => $package_name, 103 | header_packages => $header_packages, 104 | compiler_packages => $compiler_packages, 105 | install_options => $install_options, 106 | } 107 | 108 | # PEAR packages don't require any further configuration, they just need to "be there". 109 | if $provider != 'pear' { 110 | $_settings = $multifile_settings ? { 111 | true => $settings, 112 | false => { downcase($title) => $settings } # emulate a hash if no multifile settings 113 | } 114 | 115 | $_settings.each |$settings_name, $settings_hash| { 116 | if $so_name { 117 | $so_name = $multifile_settings ? { 118 | true => downcase($settings_name), 119 | false => pick(downcase($so_name), downcase($name), downcase($settings_name)), 120 | } 121 | } else { 122 | $so_name = $multifile_settings ? { 123 | true => downcase($settings_name), 124 | false => pick(downcase($name), downcase($settings_name)), 125 | } 126 | } 127 | 128 | php::extension::config { $settings_name: 129 | ensure => $ensure, 130 | provider => $provider, 131 | so_name => $so_name, 132 | ini_prefix => $ini_prefix, 133 | php_api_version => $php_api_version, 134 | zend => $zend, 135 | settings => $settings_hash, 136 | settings_prefix => $settings_prefix, 137 | sapi => $sapi, 138 | subscribe => Php::Extension::Install[$title], 139 | } 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /manifests/extension/config.pp: -------------------------------------------------------------------------------- 1 | # Configure a PHP extension package 2 | # 3 | # === Parameters 4 | # 5 | # [*ensure*] 6 | # The ensure of the package to install 7 | # Could be "latest", "installed" or a pinned version 8 | # 9 | # [*provider*] 10 | # The provider used to install the package 11 | # Could be "pecl", "apt", "dpkg" or any other OS package provider 12 | # If set to "none", no package will be installed 13 | # 14 | # [*so_name*] 15 | # The DSO name of the package (e.g. opcache for zendopcache) 16 | # 17 | # [*ini_prefix*] 18 | # An optional filename prefix for the settings file of the extension 19 | # 20 | # [*php_api_version*] 21 | # This parameter is used to build the full path to the extension 22 | # directory for zend_extension in PHP < 5.5 (e.g. 20100525) 23 | # 24 | # [*header_packages*] 25 | # System packages dependencies to install for extensions (e.g. for 26 | # memcached libmemcached-dev on Debian) 27 | # 28 | # [*compiler_packages*] 29 | # System packages dependencies to install for compiling extensions 30 | # (e.g. build-essential on Debian) 31 | # 32 | # [*zend*] 33 | # Boolean parameter, whether to load extension as zend_extension. 34 | # Defaults to false. 35 | # 36 | # [*settings*] 37 | # Nested hash of global config parameters for php.ini 38 | # 39 | # [*settings_prefix*] 40 | # Boolean/String parameter, whether to prefix all setting keys with 41 | # the extension name or specified name. Defaults to false. 42 | # 43 | # [*sapi*] 44 | # String parameter, whether to specify ALL sapi or a specific sapi. 45 | # Defaults to ALL. 46 | # 47 | define php::extension::config ( 48 | String $ensure = 'installed', 49 | Optional[Php::Provider] $provider = undef, 50 | Optional[String] $so_name = downcase($name), 51 | Optional[String] $ini_prefix = undef, 52 | Optional[String] $php_api_version = undef, 53 | Boolean $zend = false, 54 | Hash $settings = {}, 55 | Variant[Boolean, String] $settings_prefix = false, 56 | Php::Sapi $sapi = 'ALL', 57 | ) { 58 | if ! defined(Class['php']) { 59 | warning('php::extension::config is private') 60 | } 61 | 62 | if $zend == true { 63 | $extension_key = 'zend_extension' 64 | $module_path = $php_api_version? { 65 | undef => undef, 66 | default => "/usr/lib/php5/${php_api_version}/", 67 | } 68 | } else { 69 | $extension_key = 'extension' 70 | $module_path = undef 71 | } 72 | 73 | $ini_name = downcase($so_name) 74 | 75 | # Ensure "." prefix is present in setting keys if requested 76 | $full_settings = $settings_prefix ? { 77 | true => php::ensure_prefix($settings, "${so_name}."), 78 | false => $settings, 79 | String => php::ensure_prefix($settings, "${settings_prefix}."), 80 | } 81 | 82 | if $provider != 'pear' { 83 | $final_settings = deep_merge({ "${extension_key}" => "${module_path}${so_name}.so" }, $full_settings) 84 | } else { 85 | $final_settings = $full_settings 86 | } 87 | 88 | if $facts['os']['name'] == 'Ubuntu' and $zend != true and $name == 'mysql' { 89 | # Do not manage the .ini file if it's mysql. PHP 7.0+ do not have 90 | # mysql.so. If mysql.ini exists and version is 7.0+, then remove it. 91 | $real_ensure = 'absent' 92 | } else { 93 | $real_ensure = $ensure 94 | } 95 | 96 | $config_root_ini = pick_default($php::config_root_ini, $php::params::config_root_ini) 97 | if $real_ensure != 'absent' { 98 | php::config { $title: 99 | file => "${config_root_ini}/${ini_prefix}${ini_name}.ini", 100 | config => $final_settings, 101 | } 102 | 103 | # Ubuntu/Debian systems use the mods-available folder. We need to enable 104 | # settings files ourselves with php5enmod command. 105 | $ext_tool_enable = pick_default($php::ext_tool_enable, $php::params::ext_tool_enable) 106 | $ext_tool_query = pick_default($php::ext_tool_query, $php::params::ext_tool_query) 107 | $ext_tool_enabled = pick_default($php::ext_tool_enabled, $php::params::ext_tool_enabled) 108 | 109 | if $facts['os']['family'] == 'Debian' and $ext_tool_enabled { 110 | $cmd = "${ext_tool_enable} -s ${sapi} ${so_name}" 111 | $execname = "ext_tool_enable_${so_name}" 112 | 113 | $_sapi = $sapi ? { 114 | 'ALL' => 'cli', 115 | default => $sapi, 116 | } 117 | if $final_settings[$extension_key] { 118 | exec { $execname: 119 | command => $cmd, 120 | onlyif => "${ext_tool_query} -s ${_sapi} -m ${so_name} | /bin/grep 'No module matches ${so_name}'", 121 | require => ::Php::Config[$title], 122 | } 123 | 124 | if $php::fpm { 125 | Package[$php::fpm::package] ~> Exec[$execname] 126 | } 127 | } 128 | } 129 | } else { 130 | file { "${config_root_ini}/${ini_prefix}${ini_name}.ini": 131 | ensure => 'absent', 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /manifests/extension/install.pp: -------------------------------------------------------------------------------- 1 | # Install a PHP extension package 2 | # 3 | # === Parameters 4 | # 5 | # [*ensure*] 6 | # The ensure of the package to install 7 | # Could be "latest", "installed" or a pinned version 8 | # 9 | # [*package_prefix*] 10 | # Prefix to prepend to the package name for the package provider 11 | # 12 | # [*package_name*] 13 | # Full package name for the package provider (e.g. php7.2-xml for 14 | # simlexml extension) 15 | # 16 | # [*provider*] 17 | # The provider used to install the package 18 | # Could be "pecl", "apt", "dpkg" or any other OS package provider 19 | # If set to "none", no package will be installed 20 | # 21 | # [*source*] 22 | # The source to install the extension from. Possible values 23 | # depend on the *provider* used 24 | # 25 | # [*header_packages*] 26 | # System packages dependencies to install for extensions (e.g. for 27 | # memcached libmemcached-dev on Debian) 28 | # 29 | # [*compiler_packages*] 30 | # System packages dependencies to install for compiling extensions 31 | # (e.g. build-essential on Debian) 32 | # 33 | # [*responsefile*] 34 | # File containing answers for interactive extension setup. Supported 35 | # *providers*: pear, pecl. 36 | # 37 | # [*install_options*] 38 | # Array of String or Hash options to pass to the provider. 39 | # 40 | define php::extension::install ( 41 | String $ensure = 'installed', 42 | Optional[Php::Provider] $provider = undef, 43 | Optional[String] $source = undef, 44 | String $package_prefix = $php::package_prefix, 45 | Optional[String[1]] $package_name = undef, 46 | Optional[Stdlib::AbsolutePath] $responsefile = undef, 47 | Variant[String, Array[String]] $header_packages = [], 48 | Variant[String, Array[String]] $compiler_packages = $php::params::compiler_packages, 49 | Php::InstallOptions $install_options = undef, 50 | ) { 51 | if ! defined(Class['php']) { 52 | warning('php::extension::install is private') 53 | } 54 | 55 | case $provider { 56 | /pecl|pear/: { 57 | $real_package = $title 58 | 59 | unless empty($header_packages) { 60 | ensure_resource('package', $header_packages) 61 | Package[$header_packages] -> Package[$real_package] 62 | } 63 | unless empty($compiler_packages) { 64 | ensure_resource('package', $compiler_packages) 65 | Package[$compiler_packages] -> Package[$real_package] 66 | } 67 | 68 | $package_require = [ 69 | Class['php::pear'], 70 | Class['php::dev'], 71 | ] 72 | } 73 | 74 | 'none' : { 75 | debug("No package installed for php::extension: `${title}`.") 76 | } 77 | 78 | default: { 79 | $real_package = $package_name ? { 80 | undef => "${package_prefix}${title}", 81 | default => $package_name, 82 | } 83 | $package_require = undef 84 | } 85 | } 86 | 87 | unless $provider == 'none' { 88 | if ! defined(Package[$real_package]) { 89 | package { $real_package: 90 | ensure => $ensure, 91 | provider => $provider, 92 | source => $source, 93 | responsefile => $responsefile, 94 | install_options => $install_options, 95 | require => $package_require, 96 | } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /manifests/fpm.pp: -------------------------------------------------------------------------------- 1 | # Install and configure mod_php for fpm 2 | # 3 | # === Parameters 4 | # 5 | # [*user*] 6 | # The user that php-fpm should run as 7 | # 8 | # [*group*] 9 | # The group that php-fpm should run as 10 | # 11 | # [*service_enable*] 12 | # Enable/disable FPM service 13 | # 14 | # [*service_ensure*] 15 | # Ensure FPM service is either 'running' or 'stopped' 16 | # 17 | # [*service_name*] 18 | # This is the name of the php-fpm service. It defaults to reasonable OS 19 | # defaults but can be different in case of using php7.0/other OS/custom fpm service 20 | # 21 | # [*service_provider*] 22 | # This is the name of the service provider, in case there is a non 23 | # OS default service provider used to start FPM. 24 | # Defaults to 'undef', pick system defaults. 25 | # 26 | # [*pools*] 27 | # Hash of php::fpm::pool resources that will be created. Defaults 28 | # to a single php::fpm::pool named www with default parameters. 29 | # 30 | # [*log_owner*] 31 | # The php-fpm log owner 32 | # 33 | # [*log_group*] 34 | # The group owning php-fpm logs 35 | # 36 | # [*package*] 37 | # Specify which package to install 38 | # 39 | # [*ensure*] 40 | # Specify which version of the package to install 41 | # 42 | # [*inifile*] 43 | # Path to php.ini for fpm 44 | # 45 | # [*settings*] 46 | # fpm settings hash 47 | # 48 | # [*global_pool_settings*] 49 | # Hash of defaults params php::fpm::pool resources that will be created. 50 | # Defaults is empty hash. 51 | # 52 | # [*pool_purge*] 53 | # Whether to purge pool config files not created 54 | # by this module 55 | # 56 | # [*reload_fpm_on_config_changes*] 57 | # by default, we reload the service on changes. 58 | # But certain options, like socket owner, will only be applied during a restart. 59 | # If set to false, a restart will be executed instead of a reload. 60 | # This default will be changed in a future release. 61 | # 62 | class php::fpm ( 63 | Optional[String] $ensure = $php::ensure, 64 | String[1] $user = $php::fpm_user, 65 | String[1] $group = $php::fpm_group, 66 | Enum['running', 'stopped'] $service_ensure = $php::fpm_service_ensure, 67 | Boolean $service_enable = $php::fpm_service_enable, 68 | String[1] $service_name = $php::fpm_service_name, 69 | Optional[String[1]] $service_provider = $php::fpm_service_provider, 70 | String $package = $php::real_fpm_package, 71 | Stdlib::Absolutepath $inifile = $php::fpm_inifile, 72 | Hash $settings = $php::real_settings, 73 | Hash $global_pool_settings = $php::real_fpm_global_pool_settings, 74 | Hash $pools = $php::real_fpm_pools, 75 | String[1] $log_owner = $php::log_owner, 76 | String[1] $log_group = $php::log_group, 77 | Boolean $pool_purge = $php::pool_purge, 78 | Boolean $reload_fpm_on_config_changes = $php::reload_fpm_on_config_changes, 79 | ) { 80 | if ! defined(Class['php']) { 81 | warning('php::fpm is private') 82 | } 83 | 84 | $real_settings = $settings 85 | 86 | # On FreeBSD fpm is not a separate package, but included in the 'php' package. 87 | # Implies that the option SET+=FPM was set when building the port. 88 | $real_package = $facts['os']['family'] ? { 89 | 'FreeBSD' => [], 90 | default => $package, 91 | } 92 | 93 | package { $real_package: 94 | ensure => $ensure, 95 | require => Class['php::packages'], 96 | } 97 | 98 | class { 'php::fpm::config': 99 | user => $user, 100 | group => $group, 101 | inifile => $inifile, 102 | settings => $real_settings, 103 | log_owner => $log_owner, 104 | log_group => $log_group, 105 | pool_purge => $pool_purge, 106 | require => Package[$real_package], 107 | } 108 | 109 | contain 'php::fpm::config' 110 | contain 'php::fpm::service' 111 | 112 | Class['php::fpm::config'] ~> Class['php::fpm::service'] 113 | 114 | $real_global_pool_settings = $global_pool_settings 115 | $real_pools = $pools 116 | create_resources(::php::fpm::pool, $real_pools, $real_global_pool_settings) 117 | } 118 | -------------------------------------------------------------------------------- /manifests/fpm/config.pp: -------------------------------------------------------------------------------- 1 | # Configure php-fpm service 2 | # 3 | # === Parameters 4 | # 5 | # [*config_file*] 6 | # The path to the fpm config file 7 | # 8 | # [*user*] 9 | # The user that runs php-fpm 10 | # 11 | # [*group*] 12 | # The group that runs php-fpm 13 | # 14 | # [*inifile*] 15 | # The path to ini file 16 | # 17 | # [*settings*] 18 | # Nested hash of key => value to apply to php.ini 19 | # 20 | # [*pool_base_dir*] 21 | # The folder that contains the php-fpm pool configs 22 | # 23 | # [*pool_purge*] 24 | # Whether to purge pool config files not created 25 | # by this module 26 | # 27 | # [*error_log*] 28 | # Path to error log file. If it's set to "syslog", log is 29 | # sent to syslogd instead of being written in a local file. 30 | # 31 | # [*log_level*] 32 | # The php-fpm log level 33 | # 34 | # [*emergency_restart_threshold*] 35 | # The php-fpm emergency_restart_threshold 36 | # 37 | # [*emergency_restart_interval*] 38 | # The php-fpm emergency_restart_interval 39 | # 40 | # [*process_control_timeout*] 41 | # The php-fpm process_control_timeout 42 | # 43 | # [*process_max*] 44 | # The maximum number of processes FPM will fork. 45 | # 46 | # [*rlimit_files*] 47 | # Set open file descriptor rlimit for the master process. 48 | # 49 | # [*systemd_interval*] 50 | # The interval between health report notification to systemd 51 | # 52 | # [*log_owner*] 53 | # The php-fpm log owner 54 | # 55 | # [*log_group*] 56 | # The group owning php-fpm logs 57 | # 58 | # [*log_dir_mode*] 59 | # The octal mode of the directory 60 | # 61 | # [*syslog_facility*] 62 | # Used to specify what type of program is logging the message 63 | # 64 | # [*syslog_ident*] 65 | # Prepended to every message 66 | # 67 | # [*root_group*] 68 | # UNIX group of the root user 69 | # 70 | # [*pid_file*] 71 | # Path to fpm pid file 72 | # 73 | # [*manage_run_dir*] 74 | # Manage the run directory 75 | # 76 | class php::fpm::config ( 77 | Stdlib::Absolutepath $config_file = $php::params::fpm_config_file, 78 | String $user = $php::params::fpm_user, 79 | String $group = $php::params::fpm_group, 80 | String $inifile = $php::params::fpm_inifile, 81 | Stdlib::Absolutepath $pid_file = $php::params::fpm_pid_file, 82 | Hash $settings = {}, 83 | Stdlib::Absolutepath $pool_base_dir = $php::params::fpm_pool_dir, 84 | Boolean $pool_purge = false, 85 | String $error_log = $php::params::fpm_error_log, 86 | String $log_level = 'notice', 87 | Integer $emergency_restart_threshold = 0, 88 | Php::Duration $emergency_restart_interval = 0, 89 | Php::Duration $process_control_timeout = 0, 90 | Integer $process_max = 0, 91 | Optional[Integer[1]] $rlimit_files = undef, 92 | Optional[Php::Duration] $systemd_interval = undef, 93 | String $log_owner = $php::params::fpm_user, 94 | String $log_group = $php::params::fpm_group, 95 | Stdlib::Filemode $log_dir_mode = $php::params::fpm_log_dir_mode, 96 | String[1] $root_group = $php::params::root_group, 97 | String $syslog_facility = 'daemon', 98 | String $syslog_ident = 'php-fpm', 99 | Boolean $manage_run_dir = true 100 | ) inherits php::params { 101 | assert_private() 102 | 103 | file { $config_file: 104 | ensure => file, 105 | content => template('php/fpm/php-fpm.conf.erb'), 106 | owner => 'root', 107 | group => $root_group, 108 | mode => '0644', 109 | } 110 | 111 | if $manage_run_dir { 112 | file { '/var/run/php-fpm': 113 | ensure => directory, 114 | owner => 'root', 115 | group => $root_group, 116 | mode => '0755', 117 | } 118 | } 119 | 120 | ensure_resource('file', '/var/log/php-fpm/', 121 | { 122 | ensure => directory, 123 | owner => 'root', 124 | group => $root_group, 125 | mode => $log_dir_mode, 126 | } 127 | ) 128 | 129 | file { $pool_base_dir: 130 | ensure => directory, 131 | owner => 'root', 132 | group => $root_group, 133 | mode => '0755', 134 | } 135 | 136 | if $pool_purge { 137 | File[$pool_base_dir] { 138 | purge => true, 139 | recurse => true, 140 | } 141 | } 142 | 143 | if $inifile != $php::params::config_root_inifile { 144 | php::config { 'fpm': 145 | file => $inifile, 146 | config => $settings, 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /manifests/fpm/pool.pp: -------------------------------------------------------------------------------- 1 | # Configure fpm pools 2 | # 3 | # === Parameters 4 | # 5 | # See the official php-fpm documentation for parameters that are not 6 | # documented here: http://php.net/manual/en/install.fpm.configuration.php. 7 | # 8 | # [*ensure*] 9 | # Remove pool if set to `'absent'`, add otherwise 10 | # 11 | # [*listen*] 12 | # On what socket to listen for FastCGI connections, i.e. 13 | # `'127.0.0.1:9000'' or `'/var/run/php5-fpm.sock'` 14 | # 15 | # [*listen_backlog*] 16 | # 17 | # [*listen_allowed_clients*] 18 | # 19 | # [*listen_owner*] 20 | # Set owner of the Unix socket 21 | # 22 | # [*listen_group*] 23 | # Set the group of the Unix socket 24 | # 25 | # [*listen_mode*] 26 | # 27 | # [*user*] 28 | # The user that php-fpm should run as 29 | # 30 | # [*group*] 31 | # The group that php-fpm should run as 32 | # 33 | # [*apparmor_hat*] 34 | # The Apparmor hat to use 35 | # 36 | # [*pm*] 37 | # 38 | # [*pm_max_children*] 39 | # 40 | # [*pm_start_servers*] 41 | # 42 | # [*pm_min_spare_servers*] 43 | # 44 | # [*pm_max_spare_servers*] 45 | # 46 | # [*pm_max_requests*] 47 | # 48 | # [*pm_process_idle_timeout*] 49 | # 50 | # [*pm_status_path*] 51 | # 52 | # [*ping_path*] 53 | # 54 | # [*ping_response*] 55 | # 56 | # [*access_log*] 57 | # The path to the file to write access log requests to 58 | # 59 | # [*access_log_format*] 60 | # The format to save the access log entries as 61 | # 62 | # [*request_terminate_timeout*] 63 | # 64 | # [*request_slowlog_timeout*] 65 | # 66 | # [*security_limit_extensions*] 67 | # 68 | # [*slowlog*] 69 | # 70 | # [*template*] 71 | # The template to use for the pool 72 | # 73 | # [*rlimit_files*] 74 | # 75 | # [*rlimit_core*] 76 | # 77 | # [*chroot*] 78 | # 79 | # [*chdir*] 80 | # 81 | # [*catch_workers_output*] 82 | # 83 | # [*include*] 84 | # Other configuration files to include on this pool 85 | # 86 | # [*env*] 87 | # List of environment variables that are passed to the php-fpm from the 88 | # outside and will be available to php scripts in this pool 89 | # 90 | # [*env_value*] 91 | # Hash of environment variables and values as strings to use in php 92 | # scripts in this pool 93 | # 94 | # [*clear_env*] 95 | # Whether the environment should be cleared. 96 | # 97 | # [*options*] 98 | # An optional hash for any other data. 99 | # 100 | # [*php_value*] 101 | # Hash of php_value directives 102 | # 103 | # [*php_flag*] 104 | # Hash of php_flag directives 105 | # 106 | # [*php_admin_value*] 107 | # Hash of php_admin_value directives 108 | # 109 | # [*php_admin_flag*] 110 | # Hash of php_admin_flag directives 111 | # 112 | # [*php_directives*] 113 | # List of custom directives that are appended to the pool config 114 | # 115 | # [*root_group*] 116 | # UNIX group of the root user 117 | # 118 | # [*base_dir*] 119 | # The folder that contains the php-fpm pool configs. This defaults to a 120 | # sensible default depending on your operating system, like 121 | # '/etc/php5/fpm/pool.d' or '/etc/php-fpm.d' 122 | # 123 | define php::fpm::pool ( 124 | Enum['present', 'absent'] $ensure = 'present', 125 | String[1] $listen = '127.0.0.1:9000', 126 | Integer[-1] $listen_backlog = -1, 127 | Optional[String[1]] $listen_allowed_clients = undef, 128 | Optional[String[1]] $listen_owner = undef, 129 | Optional[String[1]] $listen_group = undef, 130 | Optional[Stdlib::Filemode] $listen_mode = undef, 131 | String[1] $user = $php::fpm::config::user, 132 | String[1] $group = $php::fpm::config::group, 133 | Optional[String[1]] $apparmor_hat = undef, 134 | String[1] $pm = 'dynamic', 135 | Integer[1] $pm_max_children = 50, 136 | Integer[0] $pm_start_servers = 5, 137 | Integer[0] $pm_min_spare_servers = 5, 138 | Integer[0] $pm_max_spare_servers = 35, 139 | Integer[0] $pm_max_requests = 0, 140 | Php::Duration $pm_process_idle_timeout = '10s', 141 | Optional[Stdlib::Absolutepath] $pm_status_path = undef, 142 | Optional[Stdlib::Absolutepath] $ping_path = undef, 143 | String[1] $ping_response = 'pong', 144 | Optional[Stdlib::Absolutepath] $access_log = undef, 145 | String[1] $access_log_format = '"%R - %u %t \"%m %r\" %s"', 146 | Php::Duration $request_terminate_timeout = 0, 147 | Php::Duration $request_slowlog_timeout = 0, 148 | Array[String[1]] $security_limit_extensions = [], 149 | Stdlib::Absolutepath $slowlog = "/var/log/php-fpm/${name}-slow.log", 150 | String[1] $template = 'php/fpm/pool.conf.erb', 151 | Optional[Integer] $rlimit_files = undef, 152 | Optional[Integer] $rlimit_core = undef, 153 | Optional[Stdlib::Absolutepath] $chroot = undef, 154 | Optional[Stdlib::Absolutepath] $chdir = undef, 155 | Enum['yes', 'no'] $catch_workers_output = 'no', 156 | Optional[String[1]] $include = undef, 157 | Array[String[1]] $env = [], 158 | Hash $env_value = {}, 159 | Boolean $clear_env = true, 160 | Hash $options = {}, 161 | Hash $php_value = {}, 162 | Hash $php_flag = {}, 163 | Hash $php_admin_value = {}, 164 | Hash $php_admin_flag = {}, 165 | Array[String[1]] $php_directives = [], 166 | String[1] $root_group = $php::params::root_group, 167 | Optional[Stdlib::Absolutepath] $base_dir = undef, 168 | ) { 169 | # The base class must be included first because it is used by parameter defaults 170 | if ! defined(Class['php']) { 171 | warning('You must include the php base class before using any php defined resources') 172 | } 173 | 174 | $pool = $title 175 | 176 | # Hack-ish to default to user for group too 177 | $group_final = $group ? { 178 | undef => $user, 179 | default => $group 180 | } 181 | 182 | # On FreeBSD fpm is not a separate package, but included in the 'php' package. 183 | # Implies that the option SET+=FPM was set when building the port. 184 | $real_package = $facts['os']['name'] ? { 185 | 'FreeBSD' => [], 186 | default => $php::fpm::package, 187 | } 188 | 189 | $pool_base_dir = pick_default($base_dir, $php::fpm::config::pool_base_dir, $php::params::fpm_pool_dir) 190 | if ($ensure == 'absent') { 191 | file { "${pool_base_dir}/${pool}.conf": 192 | ensure => absent, 193 | notify => Class['php::fpm::service'], 194 | } 195 | } else { 196 | file { "${pool_base_dir}/${pool}.conf": 197 | ensure => file, 198 | notify => Class['php::fpm::service'], 199 | require => Package[$real_package], 200 | content => template($template), 201 | owner => root, 202 | group => $root_group, 203 | mode => '0640', 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /manifests/fpm/service.pp: -------------------------------------------------------------------------------- 1 | # Manage fpm service 2 | # 3 | # === Parameters 4 | # 5 | # [*service_name*] 6 | # name of the php-fpm service 7 | # 8 | # [*ensure*] 9 | # 'ensure' value for the service 10 | # 11 | # [*enable*] 12 | # Defines if the service is enabled 13 | # 14 | # [*provider*] 15 | # Defines if the service provider to use 16 | # 17 | # [*reload_fpm_on_config_changes*] 18 | # by default, we reload the service on changes. 19 | # But certain options, like socket owner, will only be applied during a restart. 20 | # If set to false, a restart will be executed instead of a reload. 21 | # This default will be changed in a future release. 22 | # 23 | class php::fpm::service ( 24 | String[1] $service_name = $php::fpm::service_name, 25 | Enum['running', 'stopped'] $ensure = $php::fpm::service_ensure, 26 | Boolean $enable = $php::fpm::service_enable, 27 | Optional[String[1]] $provider = $php::fpm::service_provider, 28 | Boolean $reload_fpm_on_config_changes = $php::fpm::reload_fpm_on_config_changes, 29 | ) { 30 | if ! defined(Class['php::fpm']) { 31 | warning('php::fpm::service is private') 32 | } 33 | 34 | if $reload_fpm_on_config_changes { 35 | $restart = $facts['service_provider'] ? { 36 | 'systemd' => "systemctl reload ${service_name}", 37 | default => "service ${service_name} reload" 38 | } 39 | } else { 40 | $restart = undef 41 | } 42 | service { $service_name: 43 | ensure => $ensure, 44 | enable => $enable, 45 | provider => $provider, 46 | hasrestart => true, 47 | restart => $restart, 48 | hasstatus => true, 49 | } 50 | 51 | ::Php::Extension <| |> ~> Service[$service_name] 52 | } 53 | -------------------------------------------------------------------------------- /manifests/global.pp: -------------------------------------------------------------------------------- 1 | # Install and configure mod_php for fpm 2 | # 3 | # === Parameters 4 | # 5 | # [*inifile*] 6 | # Absolute path to the global php.ini file. Defaults 7 | # to the OS specific default location as defined in params. 8 | # [*settings*] 9 | # Hash of settings to apply to the global php.ini file. 10 | # Defaults to OS specific defaults (i.e. add nothing) 11 | # 12 | 13 | # 14 | class php::global ( 15 | Stdlib::Absolutepath $inifile = $php::config_root_inifile, 16 | Hash $settings = {} 17 | ) inherits php { 18 | assert_private() 19 | 20 | # No deep merging required since the settings we have are the global settings. 21 | $real_settings = $settings 22 | 23 | php::config { 'global': 24 | file => $inifile, 25 | config => $real_settings, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /manifests/globals.pp: -------------------------------------------------------------------------------- 1 | # PHP globals class 2 | # 3 | # === Parameters 4 | # 5 | # [*php_version*] 6 | # The version of php. 7 | # 8 | # [*config_root*] 9 | # The configuration root directory. 10 | # 11 | # [*fpm_pid_file*] 12 | # Path to pid file for fpm 13 | # 14 | # [*rhscl_mode*] 15 | # The mode specifies the specifics in paths for the various RedHat SCL environments so that the module is configured 16 | # correctly on their pathnames. 17 | # 18 | # @param flavor 19 | # Flavor of PHP, either 'community' or 'zend'. 20 | # 21 | # @param zend_creds 22 | # Hash of ZendPHP repo credentials; {username => '', password => ''} 23 | # 24 | 25 | class php::globals ( 26 | Optional[Pattern[/^(rh-)?(php)?[578](\.)?[0-9]/]] $php_version = undef, 27 | Optional[Stdlib::Absolutepath] $config_root = undef, 28 | Optional[Stdlib::Absolutepath] $fpm_pid_file = undef, 29 | Optional[Enum['rhscl', 'remi']] $rhscl_mode = undef, 30 | Optional[Hash] $zend_creds = undef, 31 | Enum['community', 'zend'] $flavor = 'community', 32 | ) { 33 | if ($php_version == undef) { 34 | $globals_php_version = $facts['os']['name'] ? { 35 | 'Debian' => $facts['os']['release']['major'] ? { 36 | '10' => '7.3', 37 | '11' => '7.4', 38 | '12' => '8.2', 39 | default => fail("Unsupported Debian release: ${fact('os.release.major')}"), 40 | }, 41 | 'Ubuntu' => $facts['os']['release']['major'] ? { 42 | '18.04' => '7.2', 43 | '20.04' => '7.4', 44 | '22.04' => '8.1', 45 | '24.04' => '8.3', 46 | default => fail("Unsupported Ubuntu release: ${fact('os.release.major')}"), 47 | }, 48 | default => '5.x', 49 | } 50 | } else { 51 | $globals_php_version = $php_version 52 | } 53 | 54 | case $facts['os']['family'] { 55 | 'Debian': { 56 | if $facts['os']['name'] == 'Ubuntu' { 57 | case $globals_php_version { 58 | /^[578].[0-9]/: { 59 | case $flavor { 60 | 'zend': { 61 | $default_config_root = "/etc/php/${globals_php_version}-zend" 62 | $fpm_service_name = "php${globals_php_version}-zend-fpm" 63 | $package_prefix = "php${globals_php_version}-zend-" 64 | } 65 | default: { 66 | $default_config_root = "/etc/php/${globals_php_version}" 67 | $fpm_service_name = "php${globals_php_version}-fpm" 68 | $package_prefix = "php${globals_php_version}-" 69 | } 70 | } 71 | $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid" 72 | $fpm_error_log = "/var/log/php${globals_php_version}-fpm.log" 73 | $ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}" 74 | $ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}" 75 | } 76 | default: { 77 | # Default php installation from Ubuntu official repository use the following paths until 16.04 78 | # For PPA please use the $php_version to override it. 79 | $default_config_root = '/etc/php5' 80 | $default_fpm_pid_file = '/var/run/php5-fpm.pid' 81 | $fpm_error_log = '/var/log/php5-fpm.log' 82 | $fpm_service_name = 'php5-fpm' 83 | $ext_tool_enable = '/usr/sbin/php5enmod' 84 | $ext_tool_query = '/usr/sbin/php5query' 85 | $package_prefix = 'php5-' 86 | } 87 | } 88 | } else { 89 | if $flavor == 'zend' and versioncmp($facts['os']['release']['major'], '11') > 0 { 90 | fail("Zend PHP is unsupported on this Debian release: ${fact('os.release.major')}") 91 | } 92 | case $globals_php_version { 93 | /^5\.6/, 94 | /^7\.[0-9]/, 95 | /^8\.[0-9]/: { 96 | case $flavor { 97 | 'zend': { 98 | $default_config_root = "/etc/php/${globals_php_version}-zend" 99 | $fpm_service_name = "php${globals_php_version}-zend-fpm" 100 | $package_prefix = "php${globals_php_version}-zend-" 101 | } 102 | default: { 103 | $default_config_root = "/etc/php/${globals_php_version}" 104 | $fpm_service_name = "php${globals_php_version}-fpm" 105 | $package_prefix = "php${globals_php_version}-" 106 | } 107 | } 108 | $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid" 109 | $fpm_error_log = "/var/log/php${globals_php_version}-fpm.log" 110 | $ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}" 111 | $ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}" 112 | } 113 | default: { 114 | $default_config_root = '/etc/php5' 115 | $default_fpm_pid_file = '/var/run/php5-fpm.pid' 116 | $fpm_error_log = '/var/log/php5-fpm.log' 117 | $fpm_service_name = 'php5-fpm' 118 | $ext_tool_enable = '/usr/sbin/php5enmod' 119 | $ext_tool_query = '/usr/sbin/php5query' 120 | $package_prefix = 'php5-' 121 | } 122 | } 123 | } 124 | } 125 | 'Suse': { 126 | case $globals_php_version { 127 | /^7/: { 128 | $default_config_root = '/etc/php7' 129 | $package_prefix = 'php7-' 130 | $default_fpm_pid_file = '/var/run/php7-fpm.pid' 131 | $fpm_error_log = '/var/log/php7-fpm.log' 132 | } 133 | default: { 134 | $default_config_root = '/etc/php5' 135 | $package_prefix = 'php5-' 136 | $default_fpm_pid_file = '/var/run/php5-fpm.pid' 137 | $fpm_error_log = '/var/log/php5-fpm.log' 138 | } 139 | } 140 | } 141 | 'RedHat': { 142 | case $flavor { 143 | 'zend': { 144 | $php_version_sans_dot = $php_version.regsubst(/\./, '', 'G') 145 | $default_config_root = "/etc/opt/zend/php${php_version_sans_dot}zend" 146 | $default_fpm_pid_file = '/var/run/php-fpm/php-fpm.pid' 147 | $fpm_service_name = "php${php_version_sans_dot}zend-php-fpm" 148 | $package_prefix = "php${php_version_sans_dot}zend-php-" 149 | } 150 | 151 | default: { 152 | case $rhscl_mode { 153 | 'remi': { 154 | $rhscl_root = "/opt/remi/${php_version}/root" 155 | $default_config_root = "/etc/opt/remi/${php_version}" 156 | $default_fpm_pid_file = '/var/run/php-fpm/php-fpm.pid' 157 | $package_prefix = "${php_version}-php-" 158 | $fpm_service_name = "${php_version}-php-fpm" 159 | } 160 | 'rhscl': { 161 | $rhscl_root = "/opt/rh/${php_version}/root" 162 | $default_config_root = "/etc/opt/rh/${php_version}" # rhscl registers contents by copy in /etc/opt/rh 163 | $default_fpm_pid_file = "/var/opt/rh/${php_version}/run/php-fpm/php-fpm.pid" 164 | $package_prefix = "${php_version}-php-" 165 | $fpm_service_name = "${php_version}-php-fpm" 166 | } 167 | undef: { 168 | $default_config_root = '/etc/php.d' 169 | $default_fpm_pid_file = '/var/run/php-fpm/php-fpm.pid' 170 | $fpm_service_name = undef 171 | $package_prefix = undef 172 | } 173 | default: { 174 | fail("Unsupported rhscl_mode '${rhscl_mode}'") 175 | } 176 | } 177 | } 178 | } 179 | } 180 | 'FreeBSD': { 181 | case $globals_php_version { 182 | /^(\d)\.(\d)$/: { 183 | $package_prefix = "php${1}${2}-" 184 | } 185 | default: { 186 | $package_prefix = 'php56-' 187 | } 188 | } 189 | $default_config_root = '/usr/local/etc' 190 | $default_fpm_pid_file = '/var/run/php-fpm.pid' 191 | $fpm_service_name = undef 192 | } 193 | 'Archlinux': { 194 | $default_config_root = '/etc/php' 195 | $default_fpm_pid_file = '/run/php-fpm/php-fpm.pid' 196 | } 197 | default: { 198 | fail("Unsupported osfamily: ${facts['os']['family']}") 199 | } 200 | } 201 | 202 | $globals_config_root = pick($config_root, $default_config_root) 203 | $globals_fpm_pid_file = pick($fpm_pid_file, $default_fpm_pid_file) 204 | } 205 | -------------------------------------------------------------------------------- /manifests/init.pp: -------------------------------------------------------------------------------- 1 | # Base class with global configuration parameters that pulls in all 2 | # enabled components. 3 | # 4 | # === Parameters 5 | # 6 | # [*ensure*] 7 | # Specify which version of PHP packages to install, defaults to 'present'. 8 | # Please note that 'absent' to remove packages is not supported! 9 | # 10 | # [*manage_repos*] 11 | # Include repository (dotdeb, ppa, etc.) to install recent PHP from 12 | # 13 | # [*fpm*] 14 | # Install and configure php-fpm 15 | # 16 | # [*fpm_service_enable*] 17 | # Enable/disable FPM service 18 | # 19 | # [*fpm_service_ensure*] 20 | # Ensure FPM service is either 'running' or 'stopped' 21 | # 22 | # [*fpm_service_name*] 23 | # This is the name of the php-fpm service. It defaults to reasonable OS 24 | # defaults but can be different in case of using php7.0/other OS/custom fpm service 25 | # 26 | # [*fpm_service_provider*] 27 | # This is the name of the service provider, in case there is a non 28 | # OS default service provider used to start FPM. 29 | # Defaults to 'undef', pick system defaults. 30 | # 31 | # [*fpm_pools*] 32 | # Hash of php::fpm::pool resources that will be created. Defaults 33 | # to a single php::fpm::pool named www with default parameters. 34 | # 35 | # [*fpm_global_pool_settings*] 36 | # Hash of defaults params php::fpm::pool resources that will be created. 37 | # Defaults to empty hash. 38 | # 39 | # [*fpm_inifile*] 40 | # Path to php.ini for fpm 41 | # 42 | # [*fpm_package*] 43 | # Name of fpm package to install 44 | # 45 | # [*fpm_user*] 46 | # The user that php-fpm should run as 47 | # 48 | # [*fpm_group*] 49 | # The group that php-fpm should run as 50 | # 51 | # [*dev*] 52 | # Install php header files, needed to install pecl modules 53 | # 54 | # [*composer*] 55 | # Install and auto-update composer 56 | # 57 | # [*pear*] 58 | # Install PEAR 59 | # 60 | # [*phpunit*] 61 | # Install phpunit 62 | # 63 | # [*apache_config*] 64 | # Manage apache's mod_php configuration 65 | # 66 | # [*proxy_type*] 67 | # proxy server type (none|http|https|ftp) 68 | # 69 | # [*proxy_server*] 70 | # specify a proxy server, with port number if needed. ie: https://example.com:8080. 71 | # 72 | # [*extensions*] 73 | # Install PHP extensions, this is overwritten by hiera hash `php::extensions` 74 | # 75 | # [*package_prefix*] 76 | # This is the prefix for constructing names of php packages. This defaults 77 | # to a sensible default depending on your operating system, like 'php-' or 78 | # 'php5-'. 79 | # 80 | # [*config_root_ini*] 81 | # This is the path to the config .ini files of the extensions. This defaults 82 | # to a sensible default depending on your operating system, like 83 | # '/etc/php5/mods-available' or '/etc/php5/conf.d'. 84 | # 85 | # [*config_root_inifile*] 86 | # The path to the global php.ini file. This defaults to a sensible default 87 | # depending on your operating system. 88 | # 89 | # [*ext_tool_enable*] 90 | # Absolute path to php tool for enabling extensions in debian/ubuntu systems. 91 | # This defaults to '/usr/sbin/php5enmod'. 92 | # 93 | # [*ext_tool_query*] 94 | # Absolute path to php tool for querying information about extensions in 95 | # debian/ubuntu systems. This defaults to '/usr/sbin/php5query'. 96 | # 97 | # [*ext_tool_enabled*] 98 | # Enable or disable the use of php tools on debian based systems 99 | # debian/ubuntu systems. This defaults to 'true'. 100 | # 101 | # [*log_owner*] 102 | # The php-fpm log owner 103 | # 104 | # [*log_group*] 105 | # The group owning php-fpm logs 106 | # 107 | # [*embedded*] 108 | # Enable embedded SAPI 109 | # 110 | # [*pear_ensure*] 111 | # The package ensure of PHP pear to install and run pear auto_discover 112 | # 113 | # [*settings*] 114 | # PHP configuration parameters in php.ini files as a hash. For example, 115 | # 'Date/date.timezone' => 'Australia/Melbourne' sets data.timezone 116 | # to 'Australia/Melbourne' under [Date] section, and 117 | # 'PHP/memory_limit' => '256M' sets memory_limit to 256M. 118 | # 119 | # [*cli_settings*] 120 | # Additional hash of PHP configuration parameters for PHP CLI. When a 121 | # setting key already exists in $settings, the value provided from the 122 | # $cli_settings parameter overrides the value from $settings parameter. 123 | # For example, 'PHP/memory_limit' => '1000M' sets memory_limit to 1000M 124 | # for the PHP cli ini file, regardless of the values from $settings. 125 | # 126 | # [*pool_purge*] 127 | # Whether to purge pool config files not created 128 | # by this module 129 | # 130 | # [*reload_fpm_on_config_changes*] 131 | # by default, we reload the service on changes. 132 | # But certain options, like socket owner, will only be applied during a restart. 133 | # If set to false, a restart will be executed instead of a reload. 134 | # This default will be changed in a future release. 135 | # 136 | class php ( 137 | String $ensure = $php::params::ensure, 138 | Boolean $manage_repos = $php::params::manage_repos, 139 | Boolean $fpm = true, 140 | Boolean $fpm_service_enable = $php::params::fpm_service_enable, 141 | Enum['running', 'stopped'] $fpm_service_ensure = $php::params::fpm_service_ensure, 142 | String[1] $fpm_service_name = $php::params::fpm_service_name, 143 | Optional[String[1]] $fpm_service_provider = undef, 144 | Hash $fpm_pools = $php::params::fpm_pools, 145 | Hash $fpm_global_pool_settings = {}, 146 | Stdlib::Absolutepath $fpm_inifile = $php::params::fpm_inifile, 147 | Optional[String[1]] $fpm_package = undef, 148 | String[1] $fpm_user = $php::params::fpm_user, 149 | String[1] $fpm_group = $php::params::fpm_group, 150 | Stdlib::Filemode $fpm_log_dir_mode = $php::params::fpm_log_dir_mode, 151 | Boolean $embedded = false, 152 | Boolean $dev = true, 153 | Boolean $composer = true, 154 | Boolean $pear = $php::params::pear, 155 | String $pear_ensure = $php::params::pear_ensure, 156 | Boolean $phpunit = false, 157 | Boolean $apache_config = false, 158 | Optional[String[1]] $proxy_type = undef, 159 | Optional[String[1]] $proxy_server = undef, 160 | Hash $extensions = {}, 161 | Hash $settings = {}, 162 | Hash $cli_settings = {}, 163 | Optional[String[1]] $package_prefix = $php::params::package_prefix, 164 | Stdlib::Absolutepath $config_root_ini = $php::params::config_root_ini, 165 | Stdlib::Absolutepath $config_root_inifile = $php::params::config_root_inifile, 166 | Optional[Stdlib::Absolutepath] $ext_tool_enable = $php::params::ext_tool_enable, 167 | Optional[Stdlib::Absolutepath] $ext_tool_query = $php::params::ext_tool_query, 168 | Boolean $ext_tool_enabled = $php::params::ext_tool_enabled, 169 | String $log_owner = $php::params::fpm_user, 170 | String $log_group = $php::params::fpm_group, 171 | Boolean $pool_purge = $php::params::pool_purge, 172 | Boolean $reload_fpm_on_config_changes = true, 173 | ) inherits php::params { 174 | $real_fpm_package = pick($fpm_package, "${package_prefix}${php::params::fpm_package_suffix}") 175 | 176 | $real_settings = $settings 177 | $real_extensions = $extensions 178 | $real_fpm_pools = $fpm_pools 179 | $real_fpm_global_pool_settings = $fpm_global_pool_settings 180 | 181 | # Merge in additional or overridden settings for php::cli::settings. 182 | $final_cli_settings = $real_settings + $cli_settings 183 | 184 | if $manage_repos { 185 | contain php::repo 186 | } 187 | 188 | class { 'php::packages': } 189 | -> class { 'php::cli': 190 | settings => $final_cli_settings, 191 | } 192 | contain php::packages 193 | contain php::cli 194 | 195 | # Configure global PHP settings in php.ini 196 | if $facts['os']['family'] != 'Debian' { 197 | Class['php::packages'] 198 | -> class { 'php::global': 199 | settings => $real_settings, 200 | } 201 | contain php::global 202 | } 203 | 204 | if $fpm { contain 'php::fpm' } 205 | if $embedded { 206 | if $facts['os']['family'] == 'RedHat' and $fpm { 207 | # Both fpm and embeded SAPIs are using same php.ini 208 | fail('Enabling both cli and embedded sapis is not currently supported') 209 | } 210 | 211 | class { 'php::embedded': 212 | settings => $real_settings, 213 | } 214 | contain php::embedded 215 | } 216 | if $dev { 217 | contain php::dev 218 | } 219 | if $composer { 220 | class { 'php::composer': 221 | proxy_type => $proxy_type, 222 | proxy_server => $proxy_server, 223 | } 224 | } 225 | if $pear { 226 | class { 'php::pear': 227 | ensure => $pear_ensure, 228 | } 229 | } 230 | if $phpunit { 231 | contain php::phpunit 232 | } 233 | if $apache_config { 234 | class { 'php::apache_config': 235 | settings => $real_settings, 236 | } 237 | contain php::apache_config 238 | } 239 | 240 | create_resources('php::extension', $real_extensions, { 241 | require => Class['php::cli'], 242 | }) 243 | 244 | # On FreeBSD purge the system-wide extensions.ini. It is going 245 | # to be replaced with per-module configuration files. 246 | if $facts['os']['family'] == 'FreeBSD' { 247 | # Purge the system-wide extensions.ini 248 | file { '/usr/local/etc/php/extensions.ini': 249 | ensure => absent, 250 | require => Class['php::packages'], 251 | } 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /manifests/packages.pp: -------------------------------------------------------------------------------- 1 | # Install common PHP packages 2 | # 3 | # === Parameters 4 | # 5 | # [*ensure*] 6 | # Specify which version of PHP packages to install 7 | # 8 | # [*names*] 9 | # List of the names of the package to install 10 | # 11 | # [*names_to_prefix*] 12 | # List of packages names that should be prefixed with the common 13 | # package prefix `$php::package_prefix` 14 | # 15 | class php::packages ( 16 | String $ensure = $php::ensure, 17 | Boolean $manage_repos = $php::manage_repos, 18 | Array $names_to_prefix = prefix($php::params::common_package_suffixes, $php::package_prefix), 19 | Array $names = $php::params::common_package_names, 20 | ) inherits php::params { 21 | assert_private() 22 | 23 | $real_names = union($names, $names_to_prefix) 24 | if $facts['os']['family'] == 'Debian' { 25 | if $manage_repos { 26 | include apt 27 | Class['apt::update'] -> Package[$real_names] 28 | } 29 | package { $real_names: 30 | ensure => $ensure, 31 | } 32 | } else { 33 | package { $real_names: 34 | ensure => $ensure, 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /manifests/params.pp: -------------------------------------------------------------------------------- 1 | # PHP params class 2 | # 3 | class php::params inherits php::globals { 4 | $ensure = 'present' 5 | $fpm_service_enable = true 6 | $fpm_service_ensure = 'running' 7 | $composer_source = 'https://getcomposer.org/composer-stable.phar' 8 | $composer_path = '/usr/local/bin/composer' 9 | $composer_max_age = 30 10 | $pear_ensure = 'present' 11 | $pear_package_suffix = 'pear' 12 | $phpunit_source = 'https://phar.phpunit.de/phpunit.phar' 13 | $phpunit_path = '/usr/local/bin/phpunit' 14 | $phpunit_max_age = 30 15 | $pool_purge = false 16 | $fpm_log_dir_mode = '0770' 17 | 18 | $fpm_pools = { 19 | 'www' => { 20 | 'catch_workers_output' => 'no', 21 | 'listen' => '127.0.0.1:9000', 22 | 'listen_backlog' => -1, 23 | 'pm' => 'dynamic', 24 | 'pm_max_children' => 50, 25 | 'pm_max_requests' => 0, 26 | 'pm_max_spare_servers' => 35, 27 | 'pm_min_spare_servers' => 5, 28 | 'pm_start_servers' => 5, 29 | 'request_terminate_timeout' => 0, 30 | }, 31 | } 32 | 33 | case $facts['os']['family'] { 34 | 'Debian': { 35 | $config_root = $php::globals::globals_config_root 36 | $config_root_ini = "${config_root}/mods-available" 37 | $config_root_inifile = "${config_root}/php.ini" 38 | $common_package_names = [] 39 | $common_package_suffixes = ['cli', 'common'] 40 | $cli_inifile = "${config_root}/cli/php.ini" 41 | $dev_package_suffix = 'dev' 42 | $fpm_pid_file = $php::globals::globals_fpm_pid_file 43 | $fpm_config_file = "${config_root}/fpm/php-fpm.conf" 44 | $fpm_error_log = $php::globals::fpm_error_log 45 | $fpm_inifile = "${config_root}/fpm/php.ini" 46 | $fpm_package_suffix = 'fpm' 47 | $fpm_pool_dir = "${config_root}/fpm/pool.d" 48 | $fpm_service_name = $php::globals::fpm_service_name 49 | $fpm_user = 'www-data' 50 | $fpm_group = 'www-data' 51 | $apache_inifile = "${config_root}/apache2/php.ini" 52 | $embedded_package_suffix = 'embed' 53 | $embedded_inifile = "${config_root}/embed/php.ini" 54 | $package_prefix = $php::globals::package_prefix 55 | $compiler_packages = 'build-essential' 56 | $root_group = 'root' 57 | $ext_tool_enable = $php::globals::ext_tool_enable 58 | $ext_tool_query = $php::globals::ext_tool_query 59 | $ext_tool_enabled = true 60 | $pear = true 61 | 62 | case $php::globals::flavor { 63 | 'zend': { 64 | $manage_repos = true 65 | } 66 | 67 | default: { 68 | case $facts['os']['name'] { 69 | 'Debian': { 70 | $manage_repos = false 71 | } 72 | 73 | 'Ubuntu': { 74 | $manage_repos = false 75 | } 76 | 77 | default: { 78 | $manage_repos = false 79 | } 80 | } 81 | } 82 | } 83 | } 84 | 85 | 'Suse': { 86 | if ($php::globals::php_version != undef) { 87 | $php_version_major = regsubst($php::globals::php_version, '^(\d+)\.(\d+)$','\1') 88 | } else { 89 | $php_version_major = 5 90 | } 91 | 92 | $config_root = $php::globals::globals_config_root 93 | $config_root_ini = "${config_root}/conf.d" 94 | $config_root_inifile = "${config_root}/php.ini" 95 | $common_package_names = ["php${php_version_major}"] 96 | $common_package_suffixes = [] 97 | $cli_inifile = "${config_root}/cli/php.ini" 98 | $dev_package_suffix = 'devel' 99 | $fpm_pid_file = $php::globals::globals_fpm_pid_file 100 | $fpm_config_file = "${config_root}/fpm/php-fpm.conf" 101 | $fpm_error_log = $php::globals::fpm_error_log 102 | $fpm_inifile = "${config_root}/fpm/php.ini" 103 | $fpm_package_suffix = 'fpm' 104 | $fpm_pool_dir = "${config_root}/fpm/pool.d" 105 | $fpm_service_name = 'php-fpm' 106 | $fpm_user = 'wwwrun' 107 | $fpm_group = 'www' 108 | $embedded_package_suffix = 'embed' 109 | $embedded_inifile = "${config_root}/embed/php.ini" 110 | $package_prefix = $php::globals::package_prefix 111 | $manage_repos = true 112 | $root_group = 'root' 113 | $ext_tool_enable = undef 114 | $ext_tool_query = undef 115 | $ext_tool_enabled = false 116 | $pear = true 117 | 118 | case $facts['os']['name'] { 119 | 'SLES': { 120 | $compiler_packages = [] 121 | } 122 | 'OpenSuSE': { 123 | $compiler_packages = 'devel_basis' 124 | } 125 | default: { 126 | fail("Unsupported operating system ${facts['os']['name']}") 127 | } 128 | } 129 | } 130 | 'RedHat': { 131 | $config_root = $php::globals::globals_config_root 132 | 133 | case $php::globals::flavor { 134 | 'zend': { 135 | $config_root_ini = "${config_root}/php.d" 136 | $config_root_inifile = "${config_root}/php.ini" 137 | $cli_inifile = $config_root_inifile 138 | $fpm_inifile = $config_root_inifile 139 | $fpm_config_file = "${config_root}/php-fpm.conf" 140 | $fpm_pool_dir = "${config_root}/php-fpm.d" 141 | } 142 | 143 | default: { 144 | case $php::globals::rhscl_mode { 145 | 'remi': { 146 | $config_root_ini = "${config_root}/php.d" 147 | $config_root_inifile = "${config_root}/php.ini" 148 | $cli_inifile = $config_root_inifile 149 | $fpm_inifile = $config_root_inifile 150 | $fpm_config_file = "${config_root}/php-fpm.conf" 151 | $fpm_pool_dir = "${config_root}/php-fpm.d" 152 | $php_bin_dir = "${php::globals::rhscl_root}/bin" 153 | } 154 | 'rhscl': { 155 | $config_root_ini = "${config_root}/php.d" 156 | $config_root_inifile = "${config_root}/php.ini" 157 | $cli_inifile = "${config_root}/php-cli.ini" 158 | $fpm_inifile = "${config_root}/php-fpm.ini" 159 | $fpm_config_file = "${config_root}/php-fpm.conf" 160 | $fpm_pool_dir = "${config_root}/php-fpm.d" 161 | $php_bin_dir = "${php::globals::rhscl_root}/bin" 162 | } 163 | undef: { 164 | # no rhscl 165 | $config_root_ini = $config_root 166 | $config_root_inifile = '/etc/php.ini' 167 | $cli_inifile = '/etc/php-cli.ini' 168 | $fpm_inifile = '/etc/php-fpm.ini' 169 | $fpm_config_file = '/etc/php-fpm.conf' 170 | $fpm_pool_dir = '/etc/php-fpm.d' 171 | } 172 | default: { 173 | fail("Unsupported rhscl_mode '${php::globals::rhscl_mode}'") 174 | } 175 | } 176 | } 177 | } 178 | 179 | $apache_inifile = $config_root_inifile 180 | $embedded_inifile = $config_root_inifile 181 | $common_package_names = [] 182 | $common_package_suffixes = ['cli', 'common'] 183 | $dev_package_suffix = 'devel' 184 | $fpm_pid_file = $php::globals::globals_fpm_pid_file 185 | $fpm_error_log = '/var/log/php-fpm/error.log' 186 | $fpm_package_suffix = 'fpm' 187 | $fpm_service_name = pick($php::globals::fpm_service_name, 'php-fpm') 188 | $fpm_user = 'apache' 189 | $fpm_group = 'apache' 190 | $embedded_package_suffix = 'embedded' 191 | $package_prefix = pick($php::globals::package_prefix, 'php-') 192 | $compiler_packages = ['gcc', 'gcc-c++', 'make'] 193 | $manage_repos = $php::globals::flavor ? { 194 | 'zend' => true, 195 | default => false, 196 | } 197 | $root_group = 'root' 198 | $ext_tool_enable = undef 199 | $ext_tool_query = undef 200 | $ext_tool_enabled = false 201 | $pear = true 202 | } 203 | 'FreeBSD': { 204 | $config_root = $php::globals::globals_config_root 205 | $config_root_ini = "${config_root}/php" 206 | $config_root_inifile = "${config_root}/php.ini" 207 | # No common packages, because the required PHP base package will be 208 | # pulled in as a dependency. This preserves the ability to choose 209 | # any available PHP version by setting the 'package_prefix' parameter. 210 | $common_package_names = [] 211 | $common_package_suffixes = ['extensions'] 212 | $cli_inifile = "${config_root}/php-cli.ini" 213 | $dev_package_suffix = undef 214 | $fpm_pid_file = $php::globals::globals_fpm_pid_file 215 | $fpm_config_file = "${config_root}/php-fpm.conf" 216 | $fpm_error_log = '/var/log/php-fpm.log' 217 | $fpm_inifile = "${config_root}/php-fpm.ini" 218 | $fpm_package_suffix = undef 219 | $fpm_pool_dir = "${config_root}/php-fpm.d" 220 | $fpm_service_name = 'php_fpm' 221 | $fpm_user = 'www' 222 | $fpm_group = 'www' 223 | $embedded_package_suffix = 'embed' 224 | $embedded_inifile = "${config_root}/php-embed.ini" 225 | $package_prefix = $php::globals::package_prefix 226 | $compiler_packages = ['gcc'] 227 | $manage_repos = false 228 | $root_group = 'wheel' 229 | $ext_tool_enable = undef 230 | $ext_tool_query = undef 231 | $ext_tool_enabled = false 232 | $pear = true 233 | } 234 | 'Archlinux': { 235 | $config_root_ini = '/etc/php/conf.d' 236 | $config_root_inifile = '/etc/php/php.ini' 237 | $common_package_names = [] 238 | $common_package_suffixes = [] 239 | $cli_inifile = '/etc/php/php.ini' 240 | $dev_package_suffix = undef 241 | $fpm_pid_file = '/run/php-fpm/php-fpm.pid' 242 | $fpm_config_file = '/etc/php/php-fpm.conf' 243 | $fpm_error_log = 'syslog' 244 | $fpm_inifile = '/etc/php/php.ini' 245 | $fpm_package_suffix = 'fpm' 246 | $fpm_pool_dir = '/etc/php/php-fpm.d' 247 | $fpm_service_name = 'php-fpm' 248 | $fpm_user = 'http' 249 | $fpm_group = 'http' 250 | $apache_inifile = '/etc/php/php.ini' 251 | $embedded_package_suffix = 'embedded' 252 | $embedded_inifile = '/etc/php/php.ini' 253 | $package_prefix = 'php-' 254 | $compiler_packages = ['gcc', 'make'] 255 | $manage_repos = false 256 | $root_group = 'root' 257 | $ext_tool_enable = undef 258 | $ext_tool_query = undef 259 | $ext_tool_enabled = false 260 | $pear = false 261 | } 262 | default: { 263 | fail("Unsupported osfamily: ${facts['os']['family']}") 264 | } 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /manifests/pear.pp: -------------------------------------------------------------------------------- 1 | # Install PEAR package manager 2 | # 3 | # === Parameters 4 | # 5 | # [*ensure*] 6 | # The package ensure of PHP pear to install and run pear auto_discover 7 | # 8 | # [*package*] 9 | # The package name for PHP pear 10 | # 11 | class php::pear ( 12 | String $ensure = $php::pear_ensure, 13 | Optional[String] $package = undef, 14 | Boolean $manage_repos = $php::manage_repos, 15 | ) inherits php::params { 16 | assert_private() 17 | 18 | # Defaults for the pear package name 19 | if $package { 20 | $package_name = $package 21 | } else { 22 | if $facts['os']['name'] == 'Amazon' { 23 | # On Amazon Linux the package name is also just 'php-pear'. 24 | # This would normally not be problematic but if you specify a 25 | # package_prefix other than 'php' then it will fail. 26 | $package_name = "php-${php::params::pear_package_suffix}" 27 | } 28 | else { 29 | case $facts['os']['family'] { 30 | 'Debian': { 31 | # Debian is a litte stupid: The pear package is called 'php-pear' 32 | # even though others are called 'php5-fpm' or 'php5-dev' 33 | $package_name = "php-${php::params::pear_package_suffix}" 34 | } 35 | default: { 36 | # This is the default for all other architectures 37 | $package_name = "${php::package_prefix}${php::params::pear_package_suffix}" 38 | } 39 | } 40 | } 41 | } 42 | 43 | # the apt module provides apt::update. apt is only included if we manage any repos 44 | $require = $manage_repos ? { 45 | true => Class['apt::update'], 46 | false => undef, 47 | } 48 | # Default PHP come with xml module and no seperate package for it 49 | if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '18.04') >= 0 { 50 | stdlib::ensure_packages(["${php::package_prefix}xml"], { ensure => present, require => $require, }) 51 | 52 | package { $package_name: 53 | ensure => $ensure, 54 | require => [$require,Class['php::cli'],Package["${php::package_prefix}xml"]], 55 | } 56 | } else { 57 | package { $package_name: 58 | ensure => $ensure, 59 | require => Class['php::cli'], 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /manifests/phpunit.pp: -------------------------------------------------------------------------------- 1 | # Install phpunit, PHP testing framework 2 | # 3 | # === Parameters 4 | # 5 | # [*source*] 6 | # Holds URL to the phpunit source file 7 | # 8 | # [*path*] 9 | # Holds path to the phpunit executable 10 | # 11 | # [*auto_update*] 12 | # Defines if phpunit should be auto updated 13 | # 14 | # [*max_age*] 15 | # Defines the time in days after which an auto-update gets executed 16 | # 17 | class php::phpunit ( 18 | String $source = $php::params::phpunit_source, 19 | Stdlib::Absolutepath $path = $php::params::phpunit_path, 20 | String[1] $root_group = $php::params::root_group, 21 | Boolean $auto_update = true, 22 | Integer $max_age = $php::params::phpunit_max_age, 23 | ) inherits php::params { 24 | assert_private() 25 | 26 | stdlib::ensure_packages(['wget']) 27 | 28 | exec { 'download phpunit': 29 | command => "wget ${source} -O ${path}", 30 | creates => $path, 31 | path => ['/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin', '/usr/local/sbin'], 32 | require => [Class['php::cli'],Package['wget']], 33 | } 34 | -> file { $path: 35 | mode => '0555', 36 | owner => root, 37 | group => $root_group, 38 | } 39 | 40 | if $auto_update { 41 | class { 'php::phpunit::auto_update': 42 | max_age => $max_age, 43 | source => $source, 44 | path => $path, 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /manifests/phpunit/auto_update.pp: -------------------------------------------------------------------------------- 1 | # Install phpunit package manager 2 | # 3 | # === Parameters 4 | # 5 | # [*max_age*] 6 | # Defines number of days after which phpunit should be updated 7 | # 8 | # [*source*] 9 | # Holds URL to the phpunit source file 10 | # 11 | # [*path*] 12 | # Holds path to the phpunit executable 13 | # 14 | class php::phpunit::auto_update ( 15 | Integer[1] $max_age, 16 | String[1] $source, 17 | Stdlib::Absolutepath $path, 18 | ) { 19 | assert_private() 20 | 21 | exec { 'update phpunit': 22 | command => "wget ${source} -O ${path}", 23 | onlyif => "test `find '${path}' -mtime +${max_age}`", 24 | path => ['/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin', '/usr/local/sbin'], 25 | require => File[$path], 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /manifests/repo.pp: -------------------------------------------------------------------------------- 1 | # Configure package repository 2 | # 3 | class php::repo { 4 | $msg_no_repo = "No repo available for ${facts['os']['family']}/${facts['os']['name']}" 5 | 6 | if $php::params::flavor == 'zend' { 7 | class { 'zend_common::repo': 8 | creds => $php::globals::zend_creds, 9 | } 10 | } else { 11 | case $facts['os']['family'] { 12 | 'Debian': { 13 | # no contain here because apt does that already 14 | case $facts['os']['name'] { 15 | 'Debian': { 16 | include php::repo::debian 17 | } 18 | 'Ubuntu': { 19 | include php::repo::ubuntu 20 | } 21 | default: { 22 | fail($msg_no_repo) 23 | } 24 | } 25 | } 26 | 'FreeBSD': {} 27 | 'Suse': { 28 | contain php::repo::suse 29 | } 30 | 'RedHat': { 31 | contain 'php::repo::redhat' 32 | } 33 | default: { 34 | fail($msg_no_repo) 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /manifests/repo/debian.pp: -------------------------------------------------------------------------------- 1 | # Configure debian apt repo 2 | # 3 | # === Parameters 4 | # 5 | # [*location*] 6 | # Location of the apt repository 7 | # 8 | # [*repos*] 9 | # Apt repository names 10 | # 11 | # [*include_src*] 12 | # Add source source repository 13 | # 14 | # [*key*] 15 | # Public key in apt::key format 16 | # 17 | # [*dotdeb*] 18 | # Enable special dotdeb handling 19 | # 20 | # [*sury*] 21 | # Enable special sury handling 22 | # 23 | class php::repo::debian ( 24 | String[1] $location = 'https://packages.dotdeb.org', 25 | String[1] $repos = 'all', 26 | Boolean $include_src = false, 27 | Hash $key = { 28 | 'id' => '6572BBEF1B5FF28B28B706837E3F070089DF5277', 29 | 'source' => 'http://www.dotdeb.org/dotdeb.gpg', 30 | }, 31 | Boolean $dotdeb = true, 32 | Boolean $sury = true, 33 | ) { 34 | assert_private() 35 | 36 | if $facts['os']['name'] != 'Debian' { 37 | fail("class php::repo::debian does not work on OS ${facts['os']['name']}") 38 | } 39 | include 'apt' 40 | 41 | if ($dotdeb and versioncmp($facts['os']['release']['major'], '9') < 1) { 42 | apt::source { 'source_php_dotdeb': 43 | location => $location, 44 | repos => $repos, 45 | include => { 46 | 'src' => $include_src, 47 | 'deb' => true, 48 | }, 49 | key => $key, 50 | } 51 | } 52 | 53 | if ($sury and versioncmp($facts['os']['release']['major'], '9') >= 0) { 54 | apt::source { 'source_php_sury': 55 | location => 'https://packages.sury.org/php/', 56 | repos => 'main', 57 | include => { 58 | 'src' => $include_src, 59 | 'deb' => true, 60 | }, 61 | key => { 62 | id => '15058500A0235D97F5D10063B188E2B695BD4743', 63 | source => 'https://packages.sury.org/php/apt.gpg', 64 | }, 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /manifests/repo/redhat.pp: -------------------------------------------------------------------------------- 1 | # Configure a yum repo for RedHat-based systems 2 | # 3 | # === Parameters 4 | # 5 | # [*yum_repo*] 6 | # Class name of the repo under ::yum::repo 7 | # 8 | 9 | class php::repo::redhat ( 10 | String[1] $yum_repo = 'remi_php56', 11 | ) { 12 | $releasever = $facts['os']['name'] ? { 13 | /(?i:Amazon)/ => '6', 14 | default => '$releasever', # Yum var 15 | } 16 | 17 | yumrepo { 'remi': 18 | descr => 'Remi\'s RPM repository for Enterprise Linux $releasever - $basearch', 19 | mirrorlist => "https://rpms.remirepo.net/enterprise/${releasever}/remi/mirror", 20 | enabled => 1, 21 | gpgcheck => 1, 22 | gpgkey => 'https://rpms.remirepo.net/RPM-GPG-KEY-remi', 23 | priority => 1, 24 | } 25 | 26 | yumrepo { 'remi-php56': 27 | descr => 'Remi\'s PHP 5.6 RPM repository for Enterprise Linux $releasever - $basearch', 28 | mirrorlist => "https://rpms.remirepo.net/enterprise/${releasever}/php56/mirror", 29 | enabled => 1, 30 | gpgcheck => 1, 31 | gpgkey => 'https://rpms.remirepo.net/RPM-GPG-KEY-remi2023', 32 | priority => 1, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /manifests/repo/suse.pp: -------------------------------------------------------------------------------- 1 | # Configure suse repo 2 | # 3 | # === Parameters 4 | # 5 | # [*reponame*] 6 | # Name of the Zypper repository 7 | # 8 | # [*baseurl*] 9 | # Base URL of the Zypper repository 10 | # 11 | class php::repo::suse ( 12 | String[1] $reponame = 'mayflower-php56', 13 | String[1] $baseurl = 'http://download.opensuse.org/repositories/home:/mayflower:/php5.6_based/SLE_11_SP3/', 14 | ) { 15 | zypprepo { $reponame: 16 | baseurl => $baseurl, 17 | enabled => 1, 18 | autorefresh => 1, 19 | } 20 | ~> exec { 'zypprepo-accept-key': 21 | command => 'zypper --gpg-auto-import-keys update -y', 22 | path => '/usr/bin:/bin', 23 | refreshonly => true, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /manifests/repo/ubuntu.pp: -------------------------------------------------------------------------------- 1 | # Configure ubuntu ppa 2 | # 3 | # === Parameters 4 | # 5 | # [*version*] 6 | # PHP version to manage (e.g. 5.6) 7 | # 8 | class php::repo::ubuntu ( 9 | Pattern[/^\d\.\d/] $version = '5.6', 10 | ) { 11 | if $facts['os']['name'] != 'Ubuntu' { 12 | fail("class php::repo::ubuntu does not work on OS ${facts['os']['name']}") 13 | } 14 | include 'apt' 15 | 16 | if ($version == '5.5') { 17 | fail('PHP 5.5 is no longer available for download') 18 | } 19 | 20 | $version_repo = $version ? { 21 | '5.4' => 'ondrej/php5-oldstable', 22 | default => 'ondrej/php' 23 | } 24 | 25 | ::apt::ppa { "ppa:${version_repo}": 26 | package_manage => true, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "puppet-php", 3 | "version": "11.0.1-rc0", 4 | "author": "Vox Pupuli", 5 | "summary": "Generic PHP module that supports many platforms", 6 | "license": "MIT", 7 | "source": "https://github.com/voxpupuli/puppet-php", 8 | "project_page": "https://github.com/voxpupuli/puppet-php", 9 | "issues_url": "https://github.com/voxpupuli/puppet-php/issues", 10 | "description": "Puppet module that aims to manage PHP and extensions in a generic way on many platforms with sane defaults and easy configuration", 11 | "dependencies": [ 12 | { 13 | "name": "puppetlabs/stdlib", 14 | "version_requirement": ">= 9.0.0 < 10.0.0" 15 | }, 16 | { 17 | "name": "puppetlabs/apt", 18 | "version_requirement": ">= 4.4.0 < 11.0.0" 19 | }, 20 | { 21 | "name": "puppetlabs/inifile", 22 | "version_requirement": ">= 1.4.1 < 7.0.0" 23 | }, 24 | { 25 | "name": "puppet/zypprepo", 26 | "version_requirement": ">= 2.0.0 < 6.0.0" 27 | }, 28 | { 29 | "name": "puppet/archive", 30 | "version_requirement": ">= 1.0.0 < 8.0.0" 31 | } 32 | ], 33 | "requirements": [ 34 | { 35 | "name": "puppet", 36 | "version_requirement": ">= 7.0.0 < 9.0.0" 37 | }, 38 | { 39 | "name": "openvox", 40 | "version_requirement": ">= 7.0.0 < 9.0.0" 41 | } 42 | ], 43 | "operatingsystem_support": [ 44 | { 45 | "operatingsystem": "Ubuntu", 46 | "operatingsystemrelease": [ 47 | "20.04", 48 | "22.04", 49 | "24.04" 50 | ] 51 | }, 52 | { 53 | "operatingsystem": "Debian", 54 | "operatingsystemrelease": [ 55 | "10", 56 | "11", 57 | "12" 58 | ] 59 | }, 60 | { 61 | "operatingsystem": "RedHat", 62 | "operatingsystemrelease": [ 63 | "7" 64 | ] 65 | }, 66 | { 67 | "operatingsystem": "CentOS", 68 | "operatingsystemrelease": [ 69 | "7" 70 | ] 71 | }, 72 | { 73 | "operatingsystem": "FreeBSD", 74 | "operatingsystemrelease": [ 75 | "11" 76 | ] 77 | }, 78 | { 79 | "operatingsystem": "SLES", 80 | "operatingsystemrelease": [ 81 | "11" 82 | ] 83 | }, 84 | { 85 | "operatingsystem": "OpenSUSE" 86 | } 87 | ] 88 | } 89 | -------------------------------------------------------------------------------- /spec/acceptance/php_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper_acceptance' 4 | 5 | describe 'php with default settings' do 6 | context 'default parameters' do 7 | it 'works with defaults' do 8 | pp = 'include php' 9 | # Run it twice and test for idempotency 10 | apply_manifest(pp, catch_failures: true) 11 | apply_manifest(pp, catch_changes: true) 12 | end 13 | 14 | packagename = case default[:platform] 15 | when %r{ubuntu-20.04}, %r{debian-11} 16 | 'php7.4-fpm' 17 | when %r{ubuntu-22.04} 18 | 'php8.1-fpm' 19 | when %r{ubuntu-24.04} 20 | 'php8.3-fpm' 21 | when %r{ubuntu-18.04} 22 | 'php7.2-fpm' 23 | when %r{debian-10} 24 | 'php7.3-fpm' 25 | when %r{debian-12} 26 | 'php8.2-fpm' 27 | else 28 | 'php-fpm' 29 | end 30 | describe package(packagename) do 31 | it { is_expected.to be_installed } 32 | end 33 | 34 | describe service(packagename) do 35 | it { is_expected.to be_running } 36 | it { is_expected.to be_enabled } 37 | end 38 | end 39 | 40 | context 'default parameters with extensions' do 41 | case default[:platform] 42 | when %r{ubuntu-24.04}, %r{ubuntu-22.04}, %r{ubuntu-20.04}, %r{ubuntu-18.04} 43 | it 'works with defaults' do 44 | case default[:platform] 45 | when %r{ubuntu-24.04} 46 | simplexmlpackagename = 'php8.3-xml' 47 | when %r{ubuntu-22.04} 48 | simplexmlpackagename = 'php8.1-xml' 49 | when %r{ubuntu-20.04} 50 | simplexmlpackagename = 'php7.4-xml' 51 | when %r{ubuntu-18.04} 52 | simplexmlpackagename = 'php7.2-xml' 53 | end 54 | pp = <<-EOS 55 | class{ 'php': 56 | extensions => { 57 | 'intl' => {}, 58 | 'gd' => {}, 59 | 'net-url' => { 60 | package_prefix => 'php-', 61 | }, 62 | 'simplexml' => { 63 | package_name => '#{simplexmlpackagename}', 64 | } 65 | } 66 | } 67 | EOS 68 | # Run it twice and test for idempotency 69 | apply_manifest(pp, catch_failures: true) 70 | apply_manifest(pp, catch_changes: true) 71 | end 72 | else 73 | it 'works with defaults' do 74 | pp = <<-EOS 75 | class{ 'php': 76 | extensions => { 77 | 'intl' => {}, 78 | 'gd' => {} 79 | } 80 | } 81 | EOS 82 | # Run it twice and test for idempotency 83 | apply_manifest(pp, catch_failures: true) 84 | apply_manifest(pp, catch_changes: true) 85 | end 86 | end 87 | 88 | packagename = case default[:platform] 89 | when %r{ubuntu-20.04}, %r{debian-11} 90 | 'php7.4-fpm' 91 | when %r{ubuntu-22.04} 92 | 'php8.1-fpm' 93 | when %r{ubuntu-24.04} 94 | 'php8.3-fpm' 95 | when %r{ubuntu-18.04} 96 | 'php7.2-fpm' 97 | when %r{debian-10} 98 | 'php7.3-fpm' 99 | when %r{debian-12} 100 | 'php8.2-fpm' 101 | else 102 | 'php-fpm' 103 | end 104 | describe package(packagename) do 105 | it { is_expected.to be_installed } 106 | end 107 | 108 | describe service(packagename) do 109 | it { is_expected.to be_running } 110 | it { is_expected.to be_enabled } 111 | end 112 | end 113 | end 114 | -------------------------------------------------------------------------------- /spec/classes/php_composer_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::composer', type: :class do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | 12 | let :pre_condition do 13 | 'class { "php": composer => false }' 14 | end 15 | 16 | describe 'works without params' do 17 | it { is_expected.to compile.with_all_deps } 18 | end 19 | 20 | describe 'when called with no parameters' do 21 | it { is_expected.to contain_class('php::composer::auto_update') } 22 | it { is_expected.to contain_archive('download composer') } 23 | end 24 | 25 | describe 'when auto_update is disabled' do 26 | let(:params) { { auto_update: false } } 27 | 28 | it { is_expected.not_to contain_class('php::composer::auto_update') } 29 | end 30 | 31 | describe 'when called with proxy_server parameters' do 32 | let(:params) { { proxy_server: 'http://example.com' } } 33 | 34 | it { is_expected.to contain_archive('download composer').with(proxy_server: 'http://example.com') } 35 | it { is_expected.to contain_exec('update composer').with(environment: ['HOME=/root', 'http_proxy=http://example.com', 'https_proxy=http://example.com']) } 36 | end 37 | 38 | describe 'when called with proxy_server and proxy_type parameters' do 39 | let(:params) { { proxy_server: 'example.com', proxy_type: 'http' } } 40 | 41 | it { is_expected.to contain_archive('download composer').with(proxy_server: 'example.com') } 42 | it { is_expected.to contain_archive('download composer').with(proxy_type: 'http') } 43 | it { is_expected.to contain_exec('update composer').with(environment: ['HOME=/root', 'http_proxy=http://example.com', 'https_proxy=http://example.com']) } 44 | end 45 | 46 | describe 'when called with proxy_server without proxy_type parameters' do 47 | let(:params) { { proxy_server: 'example.com' } } 48 | 49 | it { is_expected.to compile.and_raise_error(%r{proxy_type must be defined if proxy_server is not full URL \(https://example.com\)}) } 50 | end 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /spec/classes/php_fpm_config_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rspec' 4 | require 'spec_helper' 5 | 6 | describe 'php::fpm::config' do 7 | on_supported_os.each do |os, facts| 8 | context "on #{os}" do 9 | let :facts do 10 | facts 11 | end 12 | 13 | describe 'works without params' do 14 | it { is_expected.to compile.with_all_deps } 15 | it { is_expected.to contain_class('php::globals') } 16 | it { is_expected.to contain_class('php::params') } 17 | end 18 | 19 | describe 'creates config file' do 20 | let(:params) do 21 | { 22 | inifile: '/etc/php5/conf.d/unique-name.ini', 23 | settings: { 24 | 'apc.enabled' => 1 25 | } 26 | } 27 | end 28 | 29 | it do 30 | is_expected.to contain_class('php::fpm::config').with( 31 | inifile: '/etc/php5/conf.d/unique-name.ini', 32 | settings: { 33 | 'apc.enabled' => 1 34 | } 35 | ) 36 | end 37 | 38 | it do 39 | is_expected.to contain_php__config('fpm').with( 40 | file: '/etc/php5/conf.d/unique-name.ini', 41 | config: { 42 | 'apc.enabled' => 1 43 | } 44 | ) 45 | end 46 | end 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /spec/classes/php_fpm_service_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::fpm::service', type: :class do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | 12 | let(:pre_condition) { 'class {"php": fpm => true}' } 13 | 14 | describe 'works without default' do 15 | it { is_expected.to compile.with_all_deps } 16 | it { is_expected.to contain_class('php::cli') } 17 | it { is_expected.to contain_class('php::composer::auto_update') } 18 | it { is_expected.to contain_class('php::composer') } 19 | it { is_expected.to contain_class('php::dev') } 20 | it { is_expected.to contain_class('php::fpm::config') } 21 | it { is_expected.to contain_class('php::fpm') } 22 | it { is_expected.to contain_class('php::packages') } 23 | it { is_expected.to contain_class('php::globals') } 24 | it { is_expected.to contain_class('php::params') } 25 | 26 | it { is_expected.to contain_class('php::pear') } if facts[:osfamily] != 'Archlinux' 27 | end 28 | 29 | describe 'when called with no parameters' do 30 | case facts[:os]['family'] 31 | when 'Debian' 32 | case facts[:os]['release']['major'] 33 | when '18.04' 34 | it { is_expected.to contain_service('php7.2-fpm').with_ensure('running') } 35 | when '22.04' 36 | it { is_expected.to contain_service('php8.1-fpm').with_ensure('running') } 37 | when '24.04' 38 | it { is_expected.to contain_service('php8.3-fpm').with_ensure('running') } 39 | when '10' 40 | it { is_expected.to contain_service('php7.3-fpm').with_ensure('running') } 41 | when '20.04', '11' 42 | it { is_expected.to contain_service('php7.4-fpm').with_ensure('running') } 43 | end 44 | when 'FreeBSD' 45 | it { is_expected.to contain_service('php_fpm').with_ensure('running') } 46 | when 'Suse' 47 | it { is_expected.to contain_service('php-fpm').with_ensure('running') } 48 | end 49 | end 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /spec/classes/php_fpm_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::fpm', type: :class do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | let(:pre_condition) { 'class {"php": fpm => false}' } 12 | 13 | describe 'works without params' do 14 | it { is_expected.to compile.with_all_deps } 15 | end 16 | 17 | describe 'when called with no parameters' do 18 | # rubocop:disable RSpec/RepeatedExample 19 | case facts[:os]['family'] 20 | when 'Debian' 21 | case facts[:os]['release']['major'] 22 | when '18.04' 23 | it { is_expected.to contain_package('php7.2-fpm').with_ensure('present') } 24 | it { is_expected.to contain_service('php7.2-fpm').with_ensure('running') } 25 | when '22.04' 26 | it { is_expected.to contain_package('php8.1-fpm').with_ensure('present') } 27 | it { is_expected.to contain_service('php8.1-fpm').with_ensure('running') } 28 | when '24.04' 29 | it { is_expected.to contain_package('php8.3-fpm').with_ensure('present') } 30 | it { is_expected.to contain_service('php8.3-fpm').with_ensure('running') } 31 | when '20.04', '11' 32 | it { is_expected.to contain_package('php7.4-fpm').with_ensure('present') } 33 | it { is_expected.to contain_service('php7.4-fpm').with_ensure('running') } 34 | when '10' 35 | it { is_expected.to contain_package('php7.3-fpm').with_ensure('present') } 36 | it { is_expected.to contain_service('php7.3-fpm').with_ensure('running') } 37 | end 38 | when 'Suse' 39 | it { is_expected.to contain_package('php5-fpm').with_ensure('present') } 40 | it { is_expected.to contain_service('php-fpm').with_ensure('running') } 41 | when 'FreeBSD' 42 | it { is_expected.not_to contain_package('php56-') } 43 | it { is_expected.not_to contain_package('php5-fpm') } 44 | it { is_expected.not_to contain_package('php-fpm') } 45 | it { is_expected.to contain_service('php_fpm').with_ensure('running') } 46 | else 47 | it { is_expected.to contain_package('php-fpm').with_ensure('present') } 48 | it { is_expected.to contain_service('php-fpm').with_ensure('running') } 49 | end 50 | # rubocop:enable RSpec/RepeatedExample 51 | it { is_expected.to contain_class('php::fpm::config').that_notifies('Class[php::fpm::service]') } 52 | it { is_expected.to contain_class('php::fpm::service') } 53 | end 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /spec/classes/php_repo_debian_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::repo::debian', type: :class do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | 12 | before do 13 | Puppet::Parser::Functions.newfunction(:my_assert_private, type: :rvalue) do |args| 14 | # Fake assert_private function from stdlib to not fail within this test 15 | end 16 | end 17 | 18 | describe 'works without params' do 19 | let(:pre_condition) do 20 | 'function assert_private() { return my_assert_private() }' 21 | end 22 | 23 | if facts[:os]['name'] == 'Debian' 24 | it { is_expected.to compile.with_all_deps } 25 | 26 | if facts[:os]['release']['major'].to_i < 9 27 | it { is_expected.to contain_apt__source('source_php_dotdeb') } 28 | it { is_expected.not_to contain_apt__source('source_php_sury') } 29 | elsif facts[:os]['release']['major'].to_i >= 9 30 | it { is_expected.not_to contain_apt__source('source_php_dotdeb') } 31 | it { is_expected.to contain_apt__source('source_php_sury') } 32 | end 33 | else 34 | it { is_expected.to compile.and_raise_error(%r{class php::repo::debian does not work on OS}) } 35 | end 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /spec/classes/php_repo_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::repo', type: :class do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | 12 | let :pre_condition do 13 | 'include php' 14 | end 15 | 16 | describe 'works without params' do 17 | if facts[:os]['name'] == 'Archlinux' 18 | it { is_expected.to compile.and_raise_error(%r{No repo available for}) } 19 | else 20 | it { is_expected.to compile.with_all_deps } 21 | end 22 | end 23 | 24 | describe 'when configuring a package repo' do 25 | case facts[:os]['family'] 26 | when 'Debian' 27 | case facts[:os]['name'] 28 | when 'Debian' 29 | it { is_expected.to contain_class('php::repo::debian') } 30 | when 'Ubuntu' 31 | it { is_expected.to contain_class('php::repo::ubuntu') } 32 | end 33 | when 'Suse' 34 | it { is_expected.to contain_class('php::repo::suse') } 35 | when 'RedHat' 36 | it { is_expected.to contain_class('php::repo::redhat') } 37 | end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /spec/classes/php_repo_ubuntu_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::repo::ubuntu', type: :class do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | 12 | describe 'works without params' do 13 | if facts[:os]['name'] == 'Ubuntu' 14 | it { is_expected.to compile.with_all_deps } 15 | it { is_expected.to contain_apt__ppa('ppa:ondrej/php') } 16 | else 17 | it { is_expected.to compile.and_raise_error(%r{class php::repo::ubuntu does not work on OS}) } 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/defines/config_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::config' do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | 12 | case facts[:operatingsystem] 13 | when 'Ubuntu' 14 | context 'default config' do 15 | let(:title) { 'unique-name' } 16 | let(:params) do 17 | { 18 | file: '/etc/php/5.6/conf.d/unique-name.ini', 19 | config: {} 20 | } 21 | end 22 | 23 | it { is_expected.to compile } 24 | end 25 | 26 | context 'simple example' do 27 | let(:title) { 'unique-name' } 28 | let(:params) do 29 | { 30 | file: '/etc/php/5.6/conf.d/unique-name.ini', 31 | config: { 32 | 'apc.enabled' => 1 33 | } 34 | } 35 | end 36 | 37 | it { is_expected.to contain_php__config('unique-name').with_file('/etc/php/5.6/conf.d/unique-name.ini') } 38 | end 39 | 40 | context 'empty array' do 41 | let(:title) { 'unique-name' } 42 | let(:params) do 43 | { 44 | file: '/etc/php/5.6/conf.d/unique-name.ini', 45 | config: {} 46 | } 47 | end 48 | 49 | it { is_expected.to contain_php__config('unique-name').with_file('/etc/php/5.6/conf.d/unique-name.ini') } 50 | end 51 | 52 | context 'invalid config (string)' do 53 | let(:title) { 'unique-name' } 54 | let(:params) do 55 | { 56 | file: '/etc/php/5.6/conf.d/unique-name.ini', 57 | config: 'hello world' 58 | } 59 | end 60 | 61 | it { is_expected.to raise_error(Puppet::Error) } 62 | end 63 | else 64 | context 'default config' do 65 | let(:title) { 'unique-name' } 66 | let(:params) do 67 | { 68 | file: '/etc/php5/conf.d/unique-name.ini', 69 | config: {} 70 | } 71 | end 72 | 73 | it { is_expected.to compile } 74 | end 75 | 76 | context 'simple example' do 77 | let(:title) { 'unique-name' } 78 | let(:params) do 79 | { 80 | file: '/etc/php5/conf.d/unique-name.ini', 81 | config: { 82 | 'apc.enabled' => 1 83 | } 84 | } 85 | end 86 | 87 | it { is_expected.to contain_php__config('unique-name').with_file('/etc/php5/conf.d/unique-name.ini') } 88 | end 89 | 90 | context 'empty array' do 91 | let(:title) { 'unique-name' } 92 | let(:params) do 93 | { 94 | file: '/etc/php5/conf.d/unique-name.ini', 95 | config: {} 96 | } 97 | end 98 | 99 | it { is_expected.to contain_php__config('unique-name').with_file('/etc/php5/conf.d/unique-name.ini') } 100 | end 101 | 102 | context 'invalid config (string)' do 103 | let(:title) { 'unique-name' } 104 | let(:params) do 105 | { 106 | file: '/etc/php5/conf.d/unique-name.ini', 107 | config: 'hello world' 108 | } 109 | end 110 | 111 | it { is_expected.to raise_error(Puppet::Error) } 112 | end 113 | end 114 | end 115 | end 116 | end 117 | -------------------------------------------------------------------------------- /spec/defines/extension_rhscl_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::extension' do 6 | on_supported_os.each do |os, facts| 7 | next unless facts[:os]['family'] == 'RedHat' || facts[:os]['family'] == 'CentOS' 8 | 9 | context "on #{os}" do 10 | let :facts do 11 | facts 12 | end 13 | 14 | describe 'with rhscl_mode "remi" enabled: install one extension' do 15 | scl_php_version = 'php56' 16 | rhscl_mode = 'remi' 17 | configs_root = "/etc/opt/#{rhscl_mode}/#{scl_php_version}" 18 | 19 | let(:pre_condition) do 20 | "class {'php::globals': 21 | php_version => '#{scl_php_version}', 22 | rhscl_mode => '#{rhscl_mode}' 23 | }-> 24 | class {'php': 25 | ensure => installed, 26 | manage_repos => false, 27 | fpm => false, 28 | dev => true, # must be true since we are using the provider => pecl (option installs header files) 29 | composer => false, 30 | pear => true, 31 | phpunit => false, 32 | }" 33 | end 34 | 35 | let(:title) { 'soap' } 36 | let(:params) do 37 | { 38 | ini_prefix: '20-', 39 | settings: { 40 | 'bz2' => { 41 | 'Date/date.timezone' => 'Europe/Berlin' 42 | } 43 | }, 44 | multifile_settings: true 45 | } 46 | end 47 | 48 | it { is_expected.to contain_class('php::global') } 49 | it { is_expected.to contain_class('php') } 50 | it { is_expected.to contain_php__config('bz2').with(file: "#{configs_root}/php.d/20-bz2.ini") } 51 | it { is_expected.to contain_php__config__setting("#{configs_root}/php.d/20-bz2.ini: Date/date.timezone").with_value('Europe/Berlin') } 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /spec/defines/extension_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::extension' do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | let(:pre_condition) { 'include php' } 12 | 13 | unless facts[:os]['family'] == 'Suse' || facts[:os]['family'] == 'FreeBSD' # FIXME: something is wrong on these 14 | etcdir = case facts[:os]['name'] 15 | when 'Debian' 16 | case facts[:os]['release']['major'] 17 | when '12' 18 | '/etc/php/8.2/mods-available' 19 | when '11' 20 | '/etc/php/7.4/mods-available' 21 | when '10' 22 | '/etc/php/7.3/mods-available' 23 | else 24 | '/etc/php5/mods-available' 25 | end 26 | when 'Ubuntu' 27 | case facts[:os]['release']['major'] 28 | when '24.04' 29 | '/etc/php/8.3/mods-available' 30 | when '22.04' 31 | '/etc/php/8.1/mods-available' 32 | when '20.04' 33 | '/etc/php/7.4/mods-available' 34 | when '18.04' 35 | '/etc/php/7.2/mods-available' 36 | else 37 | '/etc/php5/mods-available' 38 | end 39 | when 'Archlinux' 40 | '/etc/php/conf.d' 41 | else 42 | '/etc/php.d' 43 | end 44 | 45 | context 'installation from repository' do 46 | let(:title) { 'json' } 47 | let(:params) do 48 | { 49 | package_prefix: 'php5-', 50 | settings: { 51 | 'test' => 'foo' 52 | } 53 | } 54 | end 55 | 56 | it { is_expected.to contain_package('php5-json') } 57 | 58 | it do 59 | is_expected.to contain_php__config('json').with( 60 | file: "#{etcdir}/json.ini", 61 | config: { 62 | 'extension' => 'json.so', 63 | 'test' => 'foo' 64 | } 65 | ) 66 | end 67 | end 68 | 69 | context 'configure extension without installing a package' do 70 | let(:title) { 'json' } 71 | let(:params) do 72 | { 73 | provider: 'none', 74 | settings: { 75 | 'test' => 'foo' 76 | } 77 | } 78 | end 79 | 80 | it do 81 | is_expected.to contain_php__config('json').with( 82 | file: "#{etcdir}/json.ini", 83 | require: nil, 84 | config: { 85 | 'extension' => 'json.so', 86 | 'test' => 'foo' 87 | } 88 | ) 89 | end 90 | end 91 | 92 | context 'add settings prefix if requested' do 93 | let(:title) { 'json' } 94 | let(:params) do 95 | { 96 | name: 'json', 97 | settings_prefix: true, 98 | settings: { 99 | 'test' => 'foo' 100 | } 101 | } 102 | end 103 | 104 | it do 105 | is_expected.to contain_php__config('json').with( 106 | config: { 107 | 'extension' => 'json.so', 108 | 'json.test' => 'foo' 109 | } 110 | ) 111 | end 112 | end 113 | 114 | context 'use specific settings prefix if requested' do 115 | let(:title) { 'json' } 116 | let(:params) do 117 | { 118 | name: 'json', 119 | settings_prefix: 'bar', 120 | settings: { 121 | 'test' => 'foo' 122 | } 123 | } 124 | end 125 | 126 | it do 127 | is_expected.to contain_php__config('json').with( 128 | config: { 129 | 'extension' => 'json.so', 130 | 'bar.test' => 'foo' 131 | } 132 | ) 133 | end 134 | end 135 | 136 | context 'extensions can be configured as zend' do 137 | let(:title) { 'xdebug' } 138 | let(:params) do 139 | { 140 | zend: true 141 | } 142 | end 143 | 144 | it { is_expected.to contain_php__config('xdebug').with_config('zend_extension' => 'xdebug.so') } 145 | end 146 | 147 | if facts[:os]['family'] != 'Archlinux' 148 | context 'pecl extensions support so_name' do 149 | let(:title) { 'zendopcache' } 150 | let(:params) do 151 | { 152 | provider: 'pecl', 153 | zend: true, 154 | so_name: 'opcache' 155 | } 156 | end 157 | 158 | it do 159 | is_expected.to contain_php__config('zendopcache').with( 160 | file: "#{etcdir}/opcache.ini", 161 | config: { 162 | 'zend_extension' => 'opcache.so' 163 | } 164 | ) 165 | end 166 | end 167 | end 168 | 169 | if facts[:os]['family'] != 'Archlinux' 170 | context 'add ini file prefix if requested' do 171 | let(:title) { 'zendopcache' } 172 | let(:params) do 173 | { 174 | provider: 'pecl', 175 | zend: true, 176 | ini_prefix: '10-', 177 | so_name: 'opcache' 178 | } 179 | end 180 | 181 | it do 182 | is_expected.to contain_php__config('zendopcache').with( 183 | file: "#{etcdir}/10-opcache.ini", 184 | config: { 185 | 'zend_extension' => 'opcache.so' 186 | } 187 | ) 188 | end 189 | end 190 | end 191 | 192 | if facts[:os]['family'] != 'Archlinux' 193 | context 'pecl extensions support php_api_version' do 194 | let(:title) { 'xdebug' } 195 | let(:params) do 196 | { 197 | provider: 'pecl', 198 | zend: true, 199 | php_api_version: '20100525' 200 | } 201 | end 202 | 203 | it { is_expected.to contain_php__config('xdebug').with_config('zend_extension' => '/usr/lib/php5/20100525/xdebug.so') } 204 | end 205 | end 206 | 207 | if facts[:os]['family'] == 'Debian' 208 | context 'on Debian family' do 209 | context 'zend extensions call ext_tool_enable' do 210 | let(:title) { 'xdebug' } 211 | let(:params) do 212 | { 213 | zend: true 214 | } 215 | end 216 | 217 | it { is_expected.to contain_exec('ext_tool_enable_xdebug') } 218 | end 219 | end 220 | end 221 | 222 | case facts[:os]['name'] 223 | when 'Debian' 224 | context 'on Debian' do 225 | let(:title) { 'xdebug' } 226 | 227 | it { is_expected.to contain_php__config('xdebug').with_file("#{etcdir}/xdebug.ini") } 228 | 229 | # NOTE: to consider: As of PHP 5.2.0, the JSON extension is bundled and compiled into PHP by default 230 | # http://php.net/manual/en/json.installation.php 231 | context 'pecl installation' do 232 | let(:title) { 'json' } 233 | let(:params) do 234 | { 235 | provider: 'pecl', 236 | header_packages: ['libmemcached-dev'], 237 | name: 'nice_name', 238 | settings: { 239 | 'test' => 'foo' 240 | } 241 | } 242 | end 243 | 244 | it { is_expected.to contain_package('json') } 245 | it { is_expected.to contain_package('libmemcached-dev') } 246 | it { is_expected.to contain_package('build-essential') } 247 | 248 | it do 249 | is_expected.to contain_php__config('json').with( 250 | file: "#{etcdir}/nice_name.ini", 251 | config: { 252 | 'extension' => 'nice_name.so', 253 | 'test' => 'foo' 254 | } 255 | ) 256 | end 257 | end 258 | end 259 | when 'Ubuntu' 260 | context 'on Ubuntu' do 261 | context 'do not setup mysql.ini' do 262 | let(:title) { 'mysql' } 263 | let(:params) do 264 | { 265 | name: 'mysql' 266 | } 267 | end 268 | 269 | it do 270 | is_expected.to contain_file("#{etcdir}/mysql.ini").with(ensure: 'absent') 271 | end 272 | end 273 | end 274 | end 275 | end 276 | end 277 | end 278 | end 279 | -------------------------------------------------------------------------------- /spec/defines/fpm_pool_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::fpm::pool' do 6 | on_supported_os.each do |os, facts| 7 | context "on #{os}" do 8 | let :facts do 9 | facts 10 | end 11 | let(:pre_condition) { 'include php' } 12 | 13 | case facts[:os]['name'] 14 | when 'Debian' 15 | context 'plain config' do 16 | let(:title) { 'unique-name' } 17 | let(:params) { {} } 18 | 19 | case facts[:os]['release']['major'] 20 | when '12' 21 | it { is_expected.to contain_file('/etc/php/8.2/fpm/pool.d/unique-name.conf') } 22 | when '11' 23 | it { is_expected.to contain_file('/etc/php/7.4/fpm/pool.d/unique-name.conf') } 24 | when '10' 25 | it { is_expected.to contain_file('/etc/php/7.3/fpm/pool.d/unique-name.conf') } 26 | else 27 | it { is_expected.to contain_file('/etc/php5/fpm/pool.d/unique-name.conf') } 28 | end 29 | end 30 | when 'Ubuntu' 31 | context 'plain config' do 32 | let(:title) { 'unique-name' } 33 | let(:params) { {} } 34 | 35 | case facts[:os]['release']['major'] 36 | when '24.04' 37 | it { is_expected.to contain_file('/etc/php/8.3/fpm/pool.d/unique-name.conf') } 38 | when '22.04' 39 | it { is_expected.to contain_file('/etc/php/8.1/fpm/pool.d/unique-name.conf') } 40 | when '20.04' 41 | it { is_expected.to contain_file('/etc/php/7.4/fpm/pool.d/unique-name.conf') } 42 | when '18.04' 43 | it { is_expected.to contain_file('/etc/php/7.2/fpm/pool.d/unique-name.conf') } 44 | else 45 | it { is_expected.to contain_file('/etc/php5/fpm/pool.d/unique-name.conf') } 46 | end 47 | end 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /spec/fixtures/unit/provider/package/pear/list_a: -------------------------------------------------------------------------------- 1 | INSTALLED PACKAGES, CHANNEL __URI: 2 | ================================== 3 | (no packages installed) 4 | 5 | INSTALLED PACKAGES, CHANNEL DOC.PHP.NET: 6 | ======================================== 7 | (no packages installed) 8 | 9 | INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET: 10 | ========================================= 11 | PACKAGE VERSION STATE 12 | Archive_Tar 1.4.0 stable 13 | Console_Getopt 1.4.1 stable 14 | PEAR 1.10.1 stable 15 | Structures_Graph 1.1.1 stable 16 | XML_Util 1.3.0 stable 17 | 18 | INSTALLED PACKAGES, CHANNEL PECL.PHP.NET: 19 | ========================================= 20 | PACKAGE VERSION STATE 21 | zip 1.13.5 stable 22 | 23 | -------------------------------------------------------------------------------- /spec/fixtures/unit/provider/package/pear/remote-info_benchmark: -------------------------------------------------------------------------------- 1 | PACKAGE DETAILS: 2 | ================ 3 | Latest 1.2.9 4 | Installed - no - 5 | Package Benchmark 6 | License New BSD 7 | Category Benchmarking 8 | Summary Framework to benchmark PHP scripts or function 9 | calls. 10 | Description Framework to benchmark PHP scripts or function 11 | calls. 12 | -------------------------------------------------------------------------------- /spec/fixtures/unit/provider/package/pear/remote-info_zip: -------------------------------------------------------------------------------- 1 | PACKAGE DETAILS: 2 | ================ 3 | Latest 1.13.5 4 | Installed 1.13.5 5 | Package zip 6 | License PHP 3.01 7 | Category File Formats 8 | Summary A zip management extension 9 | Description Zip is an extension to create, modify and read 10 | zip files. 11 | -------------------------------------------------------------------------------- /spec/functions/ensure_prefix.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'php::ensure_prefix' do 6 | let(:prefix) { 'p.' } 7 | 8 | context 'when first parameter is a hash' do 9 | let(:input) { { 'a' => 1, 'b' => 2, 'p.c' => 3 } } 10 | let(:expected) do 11 | { 12 | 'p.a' => 1, 13 | 'p.b' => 2, 14 | 'p.c' => 3, 15 | } 16 | end 17 | 18 | it { is_expected.to run.with_params(input, prefix).and_return(expected) } 19 | 20 | context 'when prefix is `undef`' do 21 | let(:prefix) { nil } 22 | 23 | it { is_expected.to run.with_params(input, prefix).and_return(input) } 24 | end 25 | 26 | context 'when prefix is empty string' do 27 | let(:prefix) { '' } 28 | 29 | it { is_expected.to run.with_params(input, prefix).and_return(input) } 30 | end 31 | end 32 | 33 | context 'when first parameter is an array' do 34 | let(:input) { ['a', 'p.b', 'c'] } 35 | let(:expected) do 36 | ['p.a', 'p.b', 'p.c'] 37 | end 38 | 39 | it { is_expected.to run.with_params(input, prefix).and_return(expected) } 40 | 41 | context 'when prefix is `undef`' do 42 | let(:prefix) { nil } 43 | 44 | it { is_expected.to run.with_params(input, prefix).and_return(input) } 45 | end 46 | 47 | context 'when prefix is empty string' do 48 | let(:prefix) { '' } 49 | 50 | it { is_expected.to run.with_params(input, prefix).and_return(input) } 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /spec/functions/to_hash_settings_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'to_hash_settings' do 6 | input = { 'a' => 1, 'b' => 2 } 7 | results = [ 8 | { 9 | 'a' => { 'key' => 'a', 'value' => 1 }, 10 | 'b' => { 'key' => 'b', 'value' => 2 } 11 | }, 12 | { 13 | 'foo: a' => { 'key' => 'a', 'value' => 1 }, 14 | 'foo: b' => { 'key' => 'b', 'value' => 2 } 15 | } 16 | ] 17 | 18 | describe 'when first parameter is not a hash' do 19 | it { is_expected.to run.with_params('baz', input).and_raise_error(Puppet::ParseError) } 20 | end 21 | 22 | describe 'when used with proper parameters' do 23 | it { is_expected.to run.with_params(input).and_return(results[0]) } 24 | it { is_expected.to run.with_params(input, 'foo').and_return(results[1]) } 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Managed by modulesync - DO NOT EDIT 4 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 5 | 6 | # puppetlabs_spec_helper will set up coverage if the env variable is set. 7 | # We want to do this if lib exists and it hasn't been explicitly set. 8 | ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) 9 | 10 | require 'voxpupuli/test/spec_helper' 11 | 12 | RSpec.configure do |c| 13 | c.facterdb_string_keys = false 14 | end 15 | 16 | add_mocked_facts! 17 | 18 | if File.exist?(File.join(__dir__, 'default_module_facts.yml')) 19 | facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) 20 | facts&.each do |name, value| 21 | add_custom_fact name.to_sym, value 22 | end 23 | end 24 | Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } 25 | -------------------------------------------------------------------------------- /spec/spec_helper_acceptance.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Managed by modulesync - DO NOT EDIT 4 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 5 | 6 | require 'voxpupuli/acceptance/spec_helper_acceptance' 7 | 8 | configure_beaker(modules: :metadata) 9 | 10 | Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } 11 | -------------------------------------------------------------------------------- /spec/unit/provider/package/pear_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe Puppet::Type.type(:package).provider(:pear) do 6 | let(:resource) do 7 | Puppet::Type.type(:package).new name: 'dummy', ensure: :installed 8 | end 9 | 10 | let(:provider) do 11 | provider = described_class.new(resource) 12 | provider.resource = resource 13 | provider 14 | end 15 | 16 | before do 17 | allow(described_class).to receive(:command).with(:pear).and_return '/fake/pear' 18 | resource.provider = provider 19 | end 20 | 21 | describe '.instances' do 22 | it 'returns an array of installed packages' do 23 | allow(described_class).to receive(:pear). 24 | with('list', '-a'). 25 | and_return File.read(my_fixture('list_a')) 26 | 27 | expect(described_class.instances.map(&:properties)).to eq [ 28 | { name: 'Archive_Tar', vendor: 'pear.php.net', ensure: '1.4.0', provider: :pear }, 29 | { name: 'Console_Getopt', vendor: 'pear.php.net', ensure: '1.4.1', provider: :pear }, 30 | { name: 'PEAR', vendor: 'pear.php.net', ensure: '1.10.1', provider: :pear }, 31 | { name: 'Structures_Graph', vendor: 'pear.php.net', ensure: '1.1.1', provider: :pear }, 32 | { name: 'XML_Util', vendor: 'pear.php.net', ensure: '1.3.0', provider: :pear }, 33 | { name: 'zip', vendor: 'pecl.php.net', ensure: '1.13.5', provider: :pear } 34 | ] 35 | end 36 | 37 | it 'ignores malformed lines' do 38 | allow(described_class).to receive(:pear). 39 | with('list', '-a'). 40 | and_return 'aaa2.1' 41 | allow(Puppet).to receive(:warning).with('Could not match aaa2.1') 42 | expect(described_class.instances).to eq [] 43 | end 44 | end 45 | 46 | describe '#install' do 47 | it 'installs a package' do 48 | allow(described_class).to receive(:pear). 49 | with('-D', 'auto_discover=1', 'upgrade', '--alldeps', 'dummy') 50 | provider.install 51 | end 52 | 53 | it 'installs a specific version' do 54 | resource[:ensure] = '0.2' 55 | allow(described_class).to receive(:pear). 56 | with('-D', 'auto_discover=1', 'upgrade', '--alldeps', '-f', 'dummy-0.2') 57 | provider.install 58 | end 59 | 60 | it 'installs from a specific source' do 61 | resource[:source] = 'pear.php.net/dummy' 62 | allow(described_class).to receive(:pear). 63 | with('-D', 'auto_discover=1', 'upgrade', '--alldeps', 'pear.php.net/dummy') 64 | provider.install 65 | end 66 | 67 | it 'installs a specific version from a specific source' do 68 | resource[:ensure] = '0.2' 69 | resource[:source] = 'pear.php.net/dummy' 70 | allow(described_class).to receive(:pear). 71 | with('-D', 'auto_discover=1', 'upgrade', '--alldeps', '-f', 'pear.php.net/dummy-0.2') 72 | provider.install 73 | end 74 | 75 | it 'uses the specified responsefile' do 76 | resource[:responsefile] = '/fake/pearresponse' 77 | allow(Puppet::Util::Execution).to receive(:execute). 78 | with( 79 | ['/fake/pear', '-D', 'auto_discover=1', 'upgrade', '--alldeps', 'dummy'], 80 | stdinfile: resource[:responsefile] 81 | ) 82 | provider.install 83 | end 84 | 85 | it 'accepts install_options' do 86 | resource[:install_options] = ['--onlyreqdeps'] 87 | allow(described_class).to receive(:pear). 88 | with('-D', 'auto_discover=1', 'upgrade', '--onlyreqdeps', 'dummy') 89 | provider.install 90 | end 91 | end 92 | 93 | describe '#query' do 94 | it 'queries information about one package' do 95 | allow(described_class).to receive(:pear). 96 | with('list', '-a'). 97 | and_return File.read(my_fixture('list_a')) 98 | 99 | resource[:name] = 'pear' 100 | expect(provider.query).to eq( 101 | name: 'PEAR', vendor: 'pear.php.net', ensure: '1.10.1', provider: :pear 102 | ) 103 | end 104 | end 105 | 106 | describe '#latest' do 107 | it 'fetches the latest version available' do 108 | allow(described_class).to receive(:pear). 109 | with('remote-info', 'Benchmark'). 110 | and_return File.read(my_fixture('remote-info_benchmark')) 111 | 112 | resource[:name] = 'Benchmark' 113 | expect(provider.latest).to eq '1.2.9' 114 | end 115 | end 116 | 117 | describe '#uninstall' do 118 | it 'uninstalls a package' do 119 | allow(described_class).to receive(:pear). 120 | with('uninstall', resource[:name]). 121 | and_return('uninstall ok') 122 | provider.uninstall 123 | end 124 | 125 | it 'raises an error otherwise' do 126 | allow(described_class).to receive(:pear). 127 | with('uninstall', resource[:name]). 128 | and_return('unexpected output') 129 | expect { provider.uninstall }.to raise_error(Puppet::Error) 130 | end 131 | end 132 | 133 | describe '#update' do 134 | it 'ignores the resource version' do 135 | resource[:ensure] = '2.0' 136 | 137 | allow(described_class).to receive(:pear). 138 | with('-D', 'auto_discover=1', 'upgrade', '--alldeps', 'dummy') 139 | provider.update 140 | end 141 | end 142 | end 143 | -------------------------------------------------------------------------------- /spec/unit/provider/package/pecl_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe Puppet::Type.type(:package).provider(:pecl) do 6 | let(:resource) do 7 | Puppet::Type.type(:package).new name: 'dummy', ensure: :installed 8 | end 9 | 10 | let(:provider) do 11 | described_class.new(resource) 12 | end 13 | 14 | let(:parent_class) do 15 | Puppet::Type::Package::ProviderPear 16 | end 17 | 18 | before do 19 | allow(parent_class).to receive(:command).with(:pear).and_return '/fake/pear' 20 | end 21 | 22 | describe '.instances' do 23 | it 'returns pecl installed packages via pear' do 24 | allow(parent_class).to receive(:pear). 25 | with('list', '-a'). 26 | and_return File.read(fixtures('unit/provider/package/pear/list_a')) 27 | 28 | expect(described_class.instances.map(&:properties)).to eq [ 29 | { ensure: '1.13.5', name: 'zip', vendor: 'pecl.php.net', provider: :pecl } 30 | ] 31 | end 32 | end 33 | 34 | describe '#install' do 35 | it 'installs with pear' do 36 | allow(parent_class).to receive(:pear) 37 | provider.install 38 | end 39 | end 40 | 41 | describe '#query' do 42 | it 'queries pecl package info via pear' do 43 | allow(parent_class).to receive(:pear). 44 | with('list', '-a'). 45 | and_return File.read(fixtures('unit/provider/package/pear/list_a')) 46 | 47 | resource[:name] = 'zip' 48 | expect(provider.query).to eq(ensure: '1.13.5', name: 'zip', vendor: 'pecl.php.net', provider: :pecl) 49 | end 50 | end 51 | 52 | describe '#latest' do 53 | it 'fetches the latest version available via pear' do 54 | allow(parent_class).to receive(:pear). 55 | with('remote-info', 'pecl.php.net/zip'). 56 | and_return File.read(fixtures('unit/provider/package/pear/remote-info_zip')) 57 | 58 | resource[:name] = 'zip' 59 | expect(provider.latest).to eq '1.13.5' 60 | end 61 | end 62 | 63 | describe '#uninstall' do 64 | it 'uninstalls a package via pear' do 65 | allow(parent_class).to receive(:pear). 66 | and_return('uninstall ok') 67 | provider.uninstall 68 | end 69 | end 70 | 71 | describe '#update' do 72 | it 'updates to latest version via pear' do 73 | resource[:ensure] = '2.0' 74 | 75 | allow(parent_class).to receive(:pear) 76 | provider.update 77 | end 78 | end 79 | end 80 | -------------------------------------------------------------------------------- /templates/fpm/php-fpm.conf.erb: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;; 2 | ; FPM Configuration ; 3 | ;;;;;;;;;;;;;;;;;;;;; 4 | 5 | ; All relative paths in this configuration file are relative to PHP's install 6 | ; prefix (/usr). This prefix can be dynamically changed by using the 7 | ; '-p' argument from the command line. 8 | 9 | ; Include one or more files. If glob(3) exists, it is used to include a bunch of 10 | ; files from a glob(3) pattern. This directive can be used everywhere in the 11 | ; file. 12 | ; Relative path can also be used. They will be prefixed by: 13 | ; - the global prefix if it's been set (-p argument) 14 | ; - /usr otherwise 15 | ;include=/etc/php5/fpm/*.conf 16 | 17 | ;;;;;;;;;;;;;;;;;; 18 | ; Global Options ; 19 | ;;;;;;;;;;;;;;;;;; 20 | 21 | [global] 22 | ; Pid file 23 | ; Note: the default prefix is /var 24 | ; Default Value: none 25 | pid = <%= @pid_file %> 26 | 27 | ; Error log file 28 | ; If it's set to "syslog", log is sent to syslogd instead of being written 29 | ; in a local file. 30 | ; Note: the default prefix is /var 31 | ; Default Value: log/php-fpm.log 32 | error_log = <%= @error_log %> 33 | 34 | ; syslog_facility is used to specify what type of program is logging the 35 | ; message. This lets syslogd specify that messages from different facilities 36 | ; will be handled differently. 37 | ; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON) 38 | ; Default Value: daemon 39 | syslog.facility = <%= @syslog_facility %> 40 | 41 | ; syslog_ident is prepended to every message. If you have multiple FPM 42 | ; instances running on the same server, you can change the default value 43 | ; which must suit common needs. 44 | ; Default Value: php-fpm 45 | syslog.ident = <%= @syslog_ident %> 46 | 47 | ; Log level 48 | ; Possible Values: alert, error, warning, notice, debug 49 | ; Default Value: notice 50 | log_level = <%= @log_level %> 51 | 52 | ; If this number of child processes exit with SIGSEGV or SIGBUS within the time 53 | ; interval set by emergency_restart_interval then FPM will restart. A value 54 | ; of '0' means 'Off'. 55 | ; Default Value: 0 56 | emergency_restart_threshold = <%= @emergency_restart_threshold %> 57 | 58 | ; Interval of time used by emergency_restart_interval to determine when 59 | ; a graceful restart will be initiated. This can be useful to work around 60 | ; accidental corruptions in an accelerator's shared memory. 61 | ; Available Units: s(econds), m(inutes), h(ours), or d(ays) 62 | ; Default Unit: seconds 63 | ; Default Value: 0 64 | emergency_restart_interval = <%= @emergency_restart_interval %> 65 | 66 | ; Time limit for child processes to wait for a reaction on signals from master. 67 | ; Available units: s(econds), m(inutes), h(ours), or d(ays) 68 | ; Default Unit: seconds 69 | ; Default Value: 0 70 | process_control_timeout = <%= @process_control_timeout %> 71 | 72 | ; The maximum number of processes FPM will fork. This has been design to control 73 | ; the global number of processes when using dynamic PM within a lot of pools. 74 | ; Use it with caution. 75 | ; Note: A value of 0 indicates no limit 76 | ; Default Value: 0 77 | process.max = <%= @process_max %> 78 | 79 | ; Specify the nice(2) priority to apply to the master process (only if set) 80 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 81 | ; Note: - It will only work if the FPM master process is launched as root 82 | ; - The pool process will inherit the master process priority 83 | ; unless it specified otherwise 84 | ; Default Value: no set 85 | ; process.priority = -19 86 | 87 | ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. 88 | ; Default Value: yes 89 | ;daemonize = yes 90 | 91 | ; Set open file descriptor rlimit for the master process. 92 | ; Default Value: system defined value 93 | <% if @rlimit_files -%> 94 | rlimit_files = <%= @rlimit_files %> 95 | <% else -%> 96 | ;rlimit_files = 1024 97 | <% end -%> 98 | 99 | ; Set max core size rlimit for the master process. 100 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 101 | ; Default Value: system defined value 102 | ;rlimit_core = 0 103 | 104 | ; Specify the event mechanism FPM will use. The following is available: 105 | ; - select (any POSIX os) 106 | ; - poll (any POSIX os) 107 | ; - epoll (linux >= 2.5.44) 108 | ; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0) 109 | ; - /dev/poll (Solaris >= 7) 110 | ; - port (Solaris >= 10) 111 | ; Default Value: not set (auto detection) 112 | ;events.mechanism = epoll 113 | 114 | ; When FPM is build with systemd integration, specify the interval, 115 | ; in second, between health report notification to systemd. 116 | ; Set to 0 to disable. 117 | ; Available Units: s(econds), m(inutes), h(ours) 118 | ; Default Unit: seconds 119 | ; Default value: 10 120 | <% if @systemd_interval -%> 121 | systemd_interval = <%= @systemd_interval %> 122 | <% else -%> 123 | ;systemd_interval = 10 124 | <% end -%> 125 | 126 | ;;;;;;;;;;;;;;;;;;;; 127 | ; Pool Definitions ; 128 | ;;;;;;;;;;;;;;;;;;;; 129 | 130 | ; Multiple pools of child processes may be started with different listening 131 | ; ports and different management options. The name of the pool will be 132 | ; used in logs and stats. There is no limitation on the number of pools which 133 | ; FPM can handle. Your system will tell you anyway :) 134 | 135 | ; To configure the pools it is recommended to have one .conf file per 136 | ; pool in the following directory: 137 | include=<%= @pool_base_dir %>/*.conf 138 | -------------------------------------------------------------------------------- /templates/fpm/pool.conf.erb: -------------------------------------------------------------------------------- 1 | [<%= @pool %>] 2 | 3 | ; The address on which to accept FastCGI requests. 4 | listen = <%= @listen %> 5 | 6 | ; Set listen(2) backlog. A value of '-1' means unlimited. 7 | listen.backlog = <%= @listen_backlog %> 8 | 9 | ; List of ipv4 addresses of FastCGI clients which are allowed to connect. 10 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 11 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 12 | ; must be separated by a comma. If this value is left blank, connections will be 13 | ; accepted from any ip address. 14 | ; Default Value: any 15 | <% if @listen_allowed_clients -%> 16 | listen.allowed_clients = <%= @listen_allowed_clients %> 17 | <% else -%> 18 | ;listen.allowed_clients = 127.0.0.1 19 | <% end -%> 20 | 21 | ; Set permissions for unix socket, if one is used. In Linux, read/write 22 | ; permissions must be set in order to allow connections from a web server. Many 23 | ; BSD-derived systems allow connections regardless of permissions. 24 | ; Default Values: user and group are set as the running user 25 | ; mode is set to 0666 26 | <% if @listen_owner -%> 27 | listen.owner = <%= @listen_owner %> 28 | <% else -%> 29 | ;listen.owner = nobody 30 | <% end -%> 31 | <% if @listen_group -%> 32 | listen.group = <%= @listen_group %> 33 | <% else -%> 34 | ;listen.group = nobody 35 | <% end -%> 36 | <% if @listen_mode -%> 37 | listen.mode = <%= @listen_mode %> 38 | <% else -%> 39 | ;listen.mode = 0660 40 | <% end -%> 41 | 42 | ; Unix user/group of processes 43 | ; Note: The user is mandatory. If the group is not set, the default user's group 44 | ; will be used. 45 | ; RPM: apache Choosed to be able to access some dir as httpd 46 | user = <%= @user %> 47 | ; RPM: Keep a group allowed to write in log dir. 48 | group = <%= @group_final %> 49 | <% if @apparmor_hat -%> 50 | ; Apparmor hat to change to 51 | apparmor_hat = <%= @apparmor_hat %> 52 | <% end -%> 53 | 54 | ; Choose how the process manager will control the number of child processes. 55 | ; Possible Values: 56 | ; static - a fixed number (pm.max_children) of child processes; 57 | ; dynamic - the number of child processes are set dynamically based on the 58 | ; following directives: 59 | ; pm.max_children - the maximum number of children that can 60 | ; be alive at the same time. 61 | ; pm.start_servers - the number of children created on startup. 62 | ; pm.min_spare_servers - the minimum number of children in 'idle' 63 | ; state (waiting to process). If the number 64 | ; of 'idle' processes is less than this 65 | ; number then some children will be created. 66 | ; pm.max_spare_servers - the maximum number of children in 'idle' 67 | ; state (waiting to process). If the number 68 | ; of 'idle' processes is greater than this 69 | ; number then some children will be killed. 70 | ; ondemand - no children are created at startup. Children will be forked when 71 | ; new requests will connect. The following parameter are used: 72 | ; pm.max_children - the maximum number of children that 73 | ; can be alive at the same time. 74 | ; pm.process_idle_timeout - The number of seconds after which 75 | ; an idle process will be killed. 76 | ; Note: This value is mandatory. 77 | pm = <%= @pm %> 78 | 79 | ; The number of child processes to be created when pm is set to 'static' and the 80 | ; maximum number of child processes to be created when pm is set to 'dynamic'. 81 | ; This value sets the limit on the number of simultaneous requests that will be 82 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 83 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 84 | ; CGI. 85 | ; Note: Used when pm is set to either 'static' or 'dynamic' 86 | ; Note: This value is mandatory. 87 | pm.max_children = <%= @pm_max_children %> 88 | 89 | ; The number of child processes created on startup. 90 | ; Note: Used only when pm is set to 'dynamic' 91 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 92 | pm.start_servers = <%= @pm_start_servers %> 93 | 94 | ; The desired minimum number of idle server processes. 95 | ; Note: Used only when pm is set to 'dynamic' 96 | ; Note: Mandatory when pm is set to 'dynamic' 97 | pm.min_spare_servers = <%= @pm_min_spare_servers %> 98 | 99 | ; The desired maximum number of idle server processes. 100 | ; Note: Used only when pm is set to 'dynamic' 101 | ; Note: Mandatory when pm is set to 'dynamic' 102 | pm.max_spare_servers = <%= @pm_max_spare_servers %> 103 | 104 | ; The number of seconds after which an idle process will be killed. 105 | ; Note: Used only when pm is set to 'ondemand' 106 | ; Default Value: 10s 107 | pm.process_idle_timeout = <%= @pm_process_idle_timeout %> 108 | 109 | ; The number of requests each child process should execute before respawning. 110 | ; This can be useful to work around memory leaks in 3rd party libraries. For 111 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 112 | ; Default Value: 0 113 | pm.max_requests = <%= @pm_max_requests %> 114 | 115 | ; The URI to view the FPM status page. If this value is not set, no URI will be 116 | ; recognized as a status page. By default, the status page shows the following 117 | ; information: 118 | ; accepted conn - the number of request accepted by the pool; 119 | ; pool - the name of the pool; 120 | ; process manager - static or dynamic; 121 | ; idle processes - the number of idle processes; 122 | ; active processes - the number of active processes; 123 | ; total processes - the number of idle + active processes. 124 | ; The values of 'idle processes', 'active processes' and 'total processes' are 125 | ; updated each second. The value of 'accepted conn' is updated in real time. 126 | ; Example output: 127 | ; accepted conn: 12073 128 | ; pool: www 129 | ; process manager: static 130 | ; idle processes: 35 131 | ; active processes: 65 132 | ; total processes: 100 133 | ; By default the status page output is formatted as text/plain. Passing either 134 | ; 'html' or 'json' as a query string will return the corresponding output 135 | ; syntax. Example: 136 | ; http://www.foo.bar/status 137 | ; http://www.foo.bar/status?json 138 | ; http://www.foo.bar/status?html 139 | ; Note: The value must start with a leading slash (/). The value can be 140 | ; anything, but it may not be a good idea to use the .php extension or it 141 | ; may conflict with a real PHP file. 142 | ; Default Value: not set 143 | <% if @pm_status_path -%> 144 | pm.status_path = <%= @pm_status_path %> 145 | <% else -%> 146 | ;pm.status_path = /status 147 | <% end -%> 148 | 149 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 150 | ; URI will be recognized as a ping page. This could be used to test from outside 151 | ; that FPM is alive and responding, or to 152 | ; - create a graph of FPM availability (rrd or such); 153 | ; - remove a server from a group if it is not responding (load balancing); 154 | ; - trigger alerts for the operating team (24/7). 155 | ; Note: The value must start with a leading slash (/). The value can be 156 | ; anything, but it may not be a good idea to use the .php extension or it 157 | ; may conflict with a real PHP file. 158 | ; Default Value: not set 159 | <% if @ping_path -%> 160 | ping.path = <%= @ping_path %> 161 | <% else -%> 162 | ;ping.path = /ping 163 | <% end -%> 164 | 165 | ; This directive may be used to customize the response of a ping request. The 166 | ; response is formatted as text/plain with a 200 response code. 167 | ; Default Value: pong 168 | ping.response = <%= @ping_response %> 169 | 170 | ; The access log file 171 | ; Default: not set 172 | <% if @access_log -%> 173 | access.log = <%= @access_log %> 174 | <% end -%> 175 | 176 | ; The access log format. 177 | ; The following syntax is allowed 178 | ; %%: the '%' character 179 | ; %C: %CPU used by the request 180 | ; it can accept the following format: 181 | ; - %{user}C for user CPU only 182 | ; - %{system}C for system CPU only 183 | ; - %{total}C for user + system CPU (default) 184 | ; %d: time taken to serve the request 185 | ; it can accept the following format: 186 | ; - %{seconds}d (default) 187 | ; - %{miliseconds}d 188 | ; - %{mili}d 189 | ; - %{microseconds}d 190 | ; - %{micro}d 191 | ; %e: an environment variable (same as $_ENV or $_SERVER) 192 | ; it must be associated with embraces to specify the name of the env 193 | ; variable. Some exemples: 194 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e 195 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e 196 | ; %f: script filename 197 | ; %l: content-length of the request (for POST request only) 198 | ; %m: request method 199 | ; %M: peak of memory allocated by PHP 200 | ; it can accept the following format: 201 | ; - %{bytes}M (default) 202 | ; - %{kilobytes}M 203 | ; - %{kilo}M 204 | ; - %{megabytes}M 205 | ; - %{mega}M 206 | ; %n: pool name 207 | ; %o: ouput header 208 | ; it must be associated with embraces to specify the name of the header: 209 | ; - %{Content-Type}o 210 | ; - %{X-Powered-By}o 211 | ; - %{Transfert-Encoding}o 212 | ; - .... 213 | ; %p: PID of the child that serviced the request 214 | ; %P: PID of the parent of the child that serviced the request 215 | ; %q: the query string 216 | ; %Q: the '?' character if query string exists 217 | ; %r: the request URI (without the query string, see %q and %Q) 218 | ; %R: remote IP address 219 | ; %s: status (response code) 220 | ; %t: server time the request was received 221 | ; it can accept a strftime(3) format: 222 | ; %d/%b/%Y:%H:%M:%S %z (default) 223 | ; %T: time the log has been written (the request has finished) 224 | ; it can accept a strftime(3) format: 225 | ; %d/%b/%Y:%H:%M:%S %z (default) 226 | ; %u: remote user 227 | ; 228 | ; Default: "%R - %u %t \"%m %r\" %s" 229 | access.format = <%= @access_log_format %> 230 | 231 | ; The timeout for serving a single request after which the worker process will 232 | ; be killed. This option should be used when the 'max_execution_time' ini option 233 | ; does not stop script execution for some reason. A value of '0' means 'off'. 234 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 235 | ; Default Value: 0 236 | request_terminate_timeout = <%= @request_terminate_timeout %> 237 | 238 | ; The timeout for serving a single request after which a PHP backtrace will be 239 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 240 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 241 | ; Default Value: 0 242 | request_slowlog_timeout = <%= @request_slowlog_timeout %> 243 | 244 | ; The log file for slow requests 245 | ; Default Value: not set 246 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 247 | slowlog = <%= @slowlog %> 248 | 249 | ; Set open file descriptor rlimit. 250 | ; Default Value: system defined value 251 | <% if @rlimit_files -%> 252 | rlimit_files = <%= @rlimit_files %> 253 | <% else -%> 254 | ;rlimit_files = 1024 255 | <% end -%> 256 | 257 | ; Set max core size rlimit. 258 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 259 | ; Default Value: system defined value 260 | <% if @rlimit_core -%> 261 | rlimit_core = <%= @rlimit_core %> 262 | <% else -%> 263 | ;rlimit_core = 0 264 | <% end -%> 265 | 266 | ; Chroot to this directory at the start. This value must be defined as an 267 | ; absolute path. When this value is not set, chroot is not used. 268 | ; Note: chrooting is a great security feature and should be used whenever 269 | ; possible. However, all PHP paths will be relative to the chroot 270 | ; (error_log, sessions.save_path, ...). 271 | ; Default Value: not set 272 | <% if @chroot -%> 273 | chroot = <%= @chroot %> 274 | <% else -%> 275 | ;chroot = 276 | <% end -%> 277 | 278 | ; Chdir to this directory at the start. This value must be an absolute path. 279 | ; Default Value: current directory or / when chroot 280 | <% if @chdir -%> 281 | chdir = <%= @chdir %> 282 | <% else -%> 283 | ;chdir = /var/www 284 | <% end -%> 285 | 286 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 287 | ; stderr will be redirected to /dev/null according to FastCGI specs. 288 | ; Default Value: no 289 | catch_workers_output = <%= @catch_workers_output %> 290 | 291 | ; Include one or more files. If glob(3) exists, it is used to include a bunch of 292 | ; files from a glob(3) pattern. This directive can be used everywhere in the 293 | ; file. 294 | ; Relative path can also be used. They will be prefixed by: 295 | ; - the global prefix if it's been set (-p arguement) 296 | ; - /usr otherwise 297 | <% if @include -%> 298 | include=<%= @include %> 299 | <% else -%> 300 | ;include=/etc/php5/fpm/*.conf 301 | <% end -%> 302 | 303 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 304 | ; the current environment. 305 | ; Default Value: clean env 306 | ;env[HOSTNAME] = $HOSTNAME 307 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 308 | ;env[TMP] = /tmp 309 | ;env[TMPDIR] = /tmp 310 | ;env[TEMP] = /tmp 311 | <% if @clear_env -%> 312 | <% @env.each do |var| -%> 313 | env[<%= var %>] = $<%= var %> 314 | <% end -%> 315 | <% @env_value.sort_by {|key,value| key}.each do |key,value| -%> 316 | <% if !value.empty? -%> 317 | env[<%= key %>] = '<%= value %>' 318 | <% end -%> 319 | <% end -%> 320 | <% else -%> 321 | clear_env = no 322 | <% end -%> 323 | 324 | ; Additional php.ini defines, specific to this pool of workers. These settings 325 | ; overwrite the values previously defined in the php.ini. The directives are the 326 | ; same as the PHP SAPI: 327 | ; php_value/php_flag - you can set classic ini defines which can 328 | ; be overwritten from PHP call 'ini_set'. 329 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 330 | ; PHP call 'ini_set' 331 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 332 | 333 | ; Defining 'extension' will load the corresponding shared extension from 334 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 335 | ; overwrite previously defined php.ini values, but will append the new value 336 | ; instead. 337 | 338 | ; Default Value: nothing is defined by default except the values in php.ini and 339 | ; specified at startup with the -d argument 340 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 341 | ;php_flag[display_errors] = off 342 | ;php_admin_value[error_log] = /var/log/php-fpm/www-error.log 343 | ;php_admin_flag[log_errors] = on 344 | ;php_admin_value[memory_limit] = 32M 345 | 346 | ; 347 | ; Custom PHP values 348 | ; 349 | <% @php_value.sort_by {|key,value| key}.each do |key,value| -%> 350 | php_value[<%= key %>] = <%= value %> 351 | <% end -%> 352 | 353 | ; 354 | ; Custom PHP flags 355 | ; 356 | <% @php_flag.sort_by {|key,flag| key}.each do |key,flag| -%> 357 | php_flag[<%= key %>] = <%= flag %> 358 | <% end -%> 359 | 360 | ; 361 | ; Custom PHP admin values 362 | ; 363 | <% @php_admin_value.sort_by {|key,value| key}.each do |key,value| -%> 364 | php_admin_value[<%= key %>] = <%= value %> 365 | <% end -%> 366 | 367 | ; 368 | ; Custom PHP admin flags 369 | ; 370 | <% @php_admin_flag.sort_by {|key,flag| key}.each do |key,flag| -%> 371 | php_admin_flag[<%= key %>] = <%= flag %> 372 | <% end -%> 373 | 374 | ; 375 | ; Custom PHP directives 376 | ; 377 | <% @php_directives.each do |line| -%> 378 | <%= line.gsub "{", "%{" %> 379 | <% end -%> 380 | 381 | <% unless @security_limit_extensions.empty? -%> 382 | security.limit_extensions = <%= @security_limit_extensions.join(" ") %> 383 | <% end -%> 384 | -------------------------------------------------------------------------------- /types/composerchannel.pp: -------------------------------------------------------------------------------- 1 | type Php::ComposerChannel = Enum[ 2 | 'stable', 3 | 'preview', 4 | 'snapshot', 5 | '1', 6 | '2' # lint:ignore:trailing_comma 7 | ] 8 | -------------------------------------------------------------------------------- /types/duration.pp: -------------------------------------------------------------------------------- 1 | # A duration in seconds are with an unit 2 | type Php::Duration = Variant[ 3 | Integer[0], 4 | Pattern[/^\d+[smhd]?$/] 5 | ] 6 | 7 | -------------------------------------------------------------------------------- /types/installoptions.pp: -------------------------------------------------------------------------------- 1 | type Php::InstallOptions = Optional[ 2 | Array[ 3 | Variant[ 4 | String, 5 | Hash[String, String] 6 | ] 7 | ] 8 | ] 9 | -------------------------------------------------------------------------------- /types/provider.pp: -------------------------------------------------------------------------------- 1 | type Php::Provider = Enum[ 2 | # do nothing 3 | 'none', 4 | 5 | # php 6 | 'pecl', 7 | 'pear', 8 | 9 | # Debuntu 10 | 'dpkg', 11 | 'apt', 12 | 13 | # RHEL 14 | 'yum', 15 | 'rpm', 16 | 'dnf', 17 | 'up2date', 18 | 19 | # Suse 20 | 'zypper', 21 | 'rug', 22 | 23 | # FreeBSD 24 | 'freebsd', 25 | 'pkgng', 26 | 'ports', 27 | 'portupgrade' # lint:ignore:trailing_comma 28 | ] 29 | -------------------------------------------------------------------------------- /types/sapi.pp: -------------------------------------------------------------------------------- 1 | type Php::Sapi = Enum[ 2 | 'ALL', 3 | 'cli', 4 | 'fpm', 5 | 'apache2' # lint:ignore:trailing_comma 6 | ] 7 | --------------------------------------------------------------------------------