├── .fixtures.yml
├── .gitignore
├── .travis.yml
├── Gemfile
├── LICENSE
├── README.md
├── Rakefile
├── docs
├── .vuepress
│ └── config.js
├── README.md
├── classes
│ ├── README.md
│ ├── cap.md
│ ├── cli.md
│ ├── command.md
│ ├── comment.md
│ ├── config.md
│ ├── core.md
│ ├── option.md
│ ├── params.md
│ ├── plugin.md
│ ├── rewrite.md
│ ├── role.md
│ ├── theme.md
│ └── user.md
├── docs
│ ├── README.md
│ └── puppet-forge.md
├── installation
│ └── README.md
└── licence
│ └── README.md
├── manifests
├── cap.pp
├── cli.pp
├── command.pp
├── comment.pp
├── config.pp
├── core.pp
├── create_subsite.pp
├── init.pp
├── option.pp
├── option
│ └── patch.pp
├── params.pp
├── plugin.pp
├── rewrite.pp
├── role.pp
├── site.pp
├── theme.pp
└── user.pp
├── metadata.json
├── package-lock.json
├── package.json
├── spec
├── defines
│ ├── cap_spec.rb
│ └── command_spec.rb
├── fixtures
│ └── manifests
│ │ └── site.pp
└── spec_helper.rb
├── templates
├── wp.bat.erb
└── wp.sh.erb
└── yarn.lock
/.fixtures.yml:
--------------------------------------------------------------------------------
1 | fixtures:
2 | repositories:
3 | archive: "git://github.com/voxpupuli/puppet-archive"
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /puppet_wp/
3 | /pkg/
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | env:
2 | - PUPPET_VERSION=3.8.5
3 | matrix:
4 | include:
5 | - language: ruby
6 | rvm: 2.1.10
7 | install:
8 | - bundle install
9 | - bundle exec rake spec
10 | script:
11 | - puppet-lint --fail-on-warnings --no-140chars-check --no-2sp_soft_tabs-check --no-hard_tabs-check --no-names_containing_dash-check --no-autoloader_layout-check --no-nested_classes_or_defines-check manifests
12 | - language: node_js
13 | node_js:
14 | - lts/*
15 | install:
16 | - npm ci
17 | script:
18 | - npm run docs:build
19 | deploy:
20 | provider: pages
21 | skip-cleanup: true
22 | local_dir: docs/.vuepress/dist
23 | github-token: $GITHUB_TOKEN
24 | keep-history: true
25 | target_branch: gh-pages
26 | on:
27 | branch: master
28 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source :rubygems
2 |
3 | if ENV.key?('PUPPET_VERSION')
4 | puppetversion = "= #{ENV['PUPPET_VERSION']}"
5 | else
6 | puppetversion = ['>= 2.7']
7 | end
8 |
9 | gem 'rake'
10 | gem 'puppet-lint'
11 | gem 'rspec-puppet'
12 | gem 'syck'
13 | gem 'puppet', puppetversion
14 | gem "puppetlabs_spec_helper", "2.10.0"
15 |
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Puppet WP-CLI
2 | This module enables the easy use of WP CLI to control your WordPress site
3 | through Puppet manifests. It provides an easy abstraction for common WP CLI
4 | commands as well as installing the WP CLI binaries as needed.
5 |
6 | ## Documentation
7 |
8 | Detailed documentation is available on [Github Pages](https://chassis.github.io/puppet-wp/).
9 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'puppetlabs_spec_helper/rake_tasks'
2 |
3 |
--------------------------------------------------------------------------------
/docs/.vuepress/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | title: 'Puppet WP',
3 | description: 'This module enables the easy use of WP CLI to control your WordPress site through Puppet manifests. It provides an easy abstraction for common WP CLI commands as well as installing the WP CLI binaries as needed.',
4 | base: '/puppet-wp/',
5 | themeConfig: {
6 | repo: 'chassis/puppet-wp',
7 | editLinks: true,
8 | docsBranch: 'master',
9 | lastUpdated: 'Last Updated',
10 | editLinkText: 'Suggest an edit!',
11 | nav: [
12 | {text: 'Home', link: '/' },
13 | {text: 'Installation', link: '/installation/' },
14 | {text: 'Classes', link: '/classes/' },
15 | ],
16 | sidebar: [
17 | {
18 | title: 'Installation',
19 | collapsable: false,
20 | children: [
21 | [ '/installation/', 'Installation' ]
22 | ]
23 | },
24 | {
25 | title: 'Classes',
26 | collapsable: false,
27 | children: [
28 | ['/classes/cap', 'Cap'],
29 | ['/classes/cli', 'CLI'],
30 | ['/classes/command', 'Command'],
31 | ['/classes/comment', 'Comment'],
32 | ['/classes/config', 'Config'],
33 | ['/classes/core', 'Core'],
34 | ['/classes/option', 'Option'],
35 | ['/classes/params', 'Params'],
36 | ['/classes/plugin', 'Plugin'],
37 | ['/classes/rewrite', 'Rewrite'],
38 | ['/classes/role', 'Role'],
39 | ['/classes/theme', 'Theme'],
40 | ['/classes/user', 'User'],
41 | ],
42 | },
43 | {
44 | title: 'Docs',
45 | collapsable: false,
46 | children: [
47 | [ '/docs/', 'Documentation' ],
48 | [ '/docs/puppet-forge', 'Puppet Forge' ],
49 | ],
50 | },
51 | {
52 | title: 'Licence',
53 | collapsable: false,
54 | children: [
55 | [ '/licence/', 'Licence' ]
56 | ],
57 | },
58 | ]
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Puppet WP
2 |
3 | This module enables the easy use of WP CLI to control your WordPress site through Puppet manifests. It provides an easy
4 | abstraction for common WP CLI commands as well as installing the WP CLI binaries as needed.
5 |
6 | ## Contribute
7 |
8 | Please report any bugs, issues or feature requests on Github: [https://github.com/Chassis/puppet-wp/](https://github.com/Chassis/puppet-wp/)
9 |
--------------------------------------------------------------------------------
/docs/classes/README.md:
--------------------------------------------------------------------------------
1 | # Classes
2 |
--------------------------------------------------------------------------------
/docs/classes/cap.md:
--------------------------------------------------------------------------------
1 | # Cap
2 |
3 | * [Description](/classes/cap.html#description)
4 | * [Attributes](/classes/cap.html#attributes)
5 |
6 | ## Description
7 |
8 | Adds or removes capabilities of a user role.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::cap { 'resource title':
13 | location => # The location to run the command.
14 | ensure => # What state the cap should be in.
15 | role => # The role name.
16 | cap => # The type of capablity.
17 | grant => # A boolean value.
18 | user => # The user to run the command as.
19 | onlyif => # A test command that checks the state of the target system and restricts when the exec can run.
20 | }
21 | ```
22 |
23 | ### location
24 |
25 | The directory from which to run the command. If this directory does not exist, the command will fail.
26 |
27 | ### ensure
28 |
29 | (*If omitted, this attribute’s value defaults to `present`.*)
30 |
31 | The state the capability should be in.
32 |
33 | Values: `present` or `absent`.
34 |
35 | ### role
36 |
37 | The description for the role. e.g. `Approver`.
38 |
39 | ### cap
40 |
41 | The name of the capability. e.g. `approver`.
42 |
43 | ### grant
44 |
45 | (*If omitted, this attribute’s value defaults to `true`.*)
46 |
47 | A boolean value of whether or not the role has the capability.
48 |
49 | Values: `true` or `false`.
50 |
51 | ### user
52 |
53 | (*If omitted, this attribute’s value defaults to `www-data`.*)
54 |
55 | ### onlyif
56 |
57 | (*If omitted, this attribute’s value defaults to `/usr/local/bin/wp core is-installed`.*)
58 |
59 | You can pass one or more checks into Puppet for this.
60 |
61 |
--------------------------------------------------------------------------------
/docs/classes/cli.md:
--------------------------------------------------------------------------------
1 | # CLI
2 |
3 | To use [WP-CLI](https://wp-cli.org/) in Puppet, follow the [installation](/installation/) instructions and then declare this class in your
4 | manifest with `include wp::cli`.
5 |
--------------------------------------------------------------------------------
/docs/classes/command.md:
--------------------------------------------------------------------------------
1 | # Command
2 |
3 | * [Description](/classes/command.html#description)
4 | * [Attributes](/classes/command.html#attributes)
5 |
6 | ## Description
7 |
8 | Executes WP-CLI commands.
9 |
10 | ## Attributes
11 | ``` puppet
12 | wp::command { 'resource title':
13 | location => # The location to run the command
14 | command => # The WP-CLI command to run
15 | user => # The user to run the command as.
16 | unless => # A test command that checks the state of the target system and restricts when the command can run
17 | onlyif => # A test command that checks the state of the target system and restricts when the exec can run.
18 | }
19 | ```
20 |
21 | ### location
22 |
23 | The directory from which to run the command. If this directory does not exist, the command will fail.
24 |
25 | ### command
26 |
27 | The actual command to execute. For example of you wanted to run `wp --info` you would to the following:
28 | ```puppet
29 | wp::command { 'WP-CLI Info':
30 | location => '/vagrant',
31 | command => '--info',
32 | }
33 | ```
34 |
35 | ### user
36 |
37 | (*If omitted, this attribute’s value defaults to `www-data`.*)
38 |
39 | ### unless
40 |
41 | (*If omitted, this attribute’s value defaults to `undef` which Puppet treats as `false`.*)
42 |
43 | A test command that checks the state of the target system and restricts when the exec can run.
44 |
45 | ### onlyif
46 |
47 | (*If omitted, this attribute’s value defaults to `/usr/local/bin/wp core is-installed`.*)
48 |
49 | You can pass one or more checks into Puppet for this. e.g.
50 |
51 | ```puppet
52 | wp::command { 'WP-CLI Info':
53 | location => '/vagrant'
54 | command => '--info',
55 | onlyif => [
56 | '/usr/local/bin/wp core is-installed',
57 | '/usr/local/bin/wp theme is-active twentynineteen',
58 | ]
59 | }
60 | ```
61 |
--------------------------------------------------------------------------------
/docs/classes/comment.md:
--------------------------------------------------------------------------------
1 | # Comment
2 |
3 | * [Description](/classes/comment.html#description)
4 | * [Attributes](/classes/comment.html#attributes)
5 |
6 | ## Description
7 |
8 | Creates, updates and deletes comments.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::comment { 'resource title':
13 | location => # The location to run the command.
14 | ensure => # What state the cap should be in.
15 | metacommand => # Is the comment's meta being altered.
16 | user => # The user to run the command as.
17 | args => # The string of arguments to pass to the comment command.
18 | onlyif => # A test command that checks the state of the target system and restricts when the exec can run.
19 | }
20 | ```
21 |
22 | ### location
23 |
24 | The directory from which to run the command. If this directory does not exist, the command will fail.
25 |
26 | ### ensure
27 |
28 | (*If omitted, this attribute’s value defaults to `present`.*)
29 |
30 | The state the comment should be in.
31 |
32 | Values: `present`, `absent`, `generate` or `meta`.
33 |
34 | ### metacommand
35 |
36 | (*If omitted, this attribute’s value defaults to `false`.*)
37 |
38 | The type of meta command to run.
39 |
40 | Values: `add`, `delete`, `patch` or `update`.
41 |
42 | ### user
43 |
44 | (*If omitted, this attribute’s value defaults to `www-data`.*)
45 |
46 | ### args
47 |
48 | A string of arguments to pass to the command. e.g.
49 | * If `ensure => generate` then `args => '--count=100'` would generate 100 comments.
50 | * If `ensure => present` then `args => '--comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"'` would add one comment.
51 | * IF `ensure => absent` then `args => '1337 2341 --force'` would delete two comments and not trash them.
52 |
53 | ### onlyif
54 |
55 | (*If omitted, this attribute’s value defaults to `/usr/local/bin/wp core is-installed`.*)
56 |
57 | You can pass one or more checks into Puppet for this.
58 |
--------------------------------------------------------------------------------
/docs/classes/config.md:
--------------------------------------------------------------------------------
1 | # Config
2 |
3 | * [Description](/classes/config.html#description)
4 | * [Attributes](/classes/config.html#attributes)
5 |
6 | ## Description
7 |
8 | Generates and edits the wp-config.php file.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::config { 'resource title':
13 | location => # The location to run the command.
14 | ensure => # What state the option should be in.
15 | dbname => # The database name.
16 | dbuser => # The database user.
17 | dbpass => # The database password.
18 | dbhost => # The database host name.
19 | dbprefix => # The database prefix.
20 | dbcharset => # The database character set.
21 | dbcollate => # The database collation.
22 | locale => # The langage that you want WordPress to use.
23 | value => # The value to send to the command.
24 | unless => # A test command that checks the state of the target system and restricts when the command can run.
25 | user => # The user to run the command as.
26 | onlyif => # A test command that checks the state of the target system and restricts when the command can run.
27 | }
28 | ```
29 |
30 | ### location
31 |
32 | The directory from which to run the command. If this directory does not exist, the command will fail.
33 |
34 | ### ensure
35 |
36 | (*If omitted, this attribute’s value defaults to `present`.*)
37 |
38 | Values: `present`, `absent` or `equal`.
39 |
40 | ### dbname
41 |
42 | Set the database name.
43 |
44 | ### dbuser
45 |
46 | Set the database user password.
47 |
48 | ### dbpass
49 |
50 | Set the database host.
51 |
52 | ### dbhost
53 |
54 | (*If omitted, this attribute’s value defaults to `localhost`.*)
55 |
56 | ### dbprefix
57 |
58 | (*If omitted, this attribute’s value defaults to `wp_`.*)
59 |
60 | Set the database table prefix.
61 |
62 | ### dbcharset
63 |
64 | (*If omitted, this attribute’s value defaults to `utf8`.*)
65 |
66 | Set the database charset.
67 |
68 | ### dbcollate
69 |
70 | (*If omitted, this attribute’s value defaults to `''`.*)
71 |
72 | Set the database collation.
73 |
74 | ### locale
75 |
76 | (*If omitted, this attribute’s value defaults to `en_AU`.*)
77 |
78 | Set this to the language you'd like WordPress to use. e.g. `en_US`.
79 |
80 | ### value
81 |
82 | (*If omitted, this attribute’s value defaults to `''`.*)
83 |
84 | ### unless
85 |
86 | (*If omitted, this attribute’s value defaults to `undef` which Puppet treats as `false`.*)
87 |
88 | A test command that checks the state of the target system and restricts when the command can run.
89 |
90 | ### user
91 |
92 | (*If omitted, this attribute’s value defaults to `www-data`.*)
93 |
94 | ### onlyif
95 |
96 | (*If omitted, this attribute’s value defaults to `/usr/local/bin/wp core is-installed`.*)
97 |
98 | ### Example
99 |
100 | ```puppet
101 | wp::config { 'Create config':
102 | location => '/vagrant'
103 | dbname => 'wordpress'
104 | dbuser => 'wordpress'
105 | dbpass => 'vagrantpassword'
106 | }
107 | ```
108 |
109 |
110 |
--------------------------------------------------------------------------------
/docs/classes/core.md:
--------------------------------------------------------------------------------
1 | # Core
2 |
3 | * [Description](/classes/site.html#description)
4 | * [Attributes](/classes/site.html#attributes)
5 |
6 | ## Description
7 |
8 | Downloads, installs, and manages a WordPress installation.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::core { 'resource title':
13 | url => # The URL of the WordPress site.
14 | location => # The location to run the command.
15 | siteurl => # The URL of the WordPress site.
16 | sitename => # The name of the site.
17 | admin_user => # The site administrators username.
18 | admin_email => # The site administrators email address.
19 | admin_password => # The site administrators password.
20 | network => # If the site is a multisite.
21 | subdomains => # Whether the multisite installation is in subfolders or subdomains.
22 | user => # The user to run the installation as.
23 | }
24 | ```
25 |
26 | ### url
27 |
28 | The URL of the site. e.g. `http://vagrant.local/`.
29 |
30 | ### location
31 |
32 | The location to run the command. e.g. `/vagrant`.
33 |
34 | ### siteurl
35 |
36 | The URL of the site including the protocol. e.g. `http://vagrant.local/`.
37 |
38 | ### sitename
39 |
40 | (*If omitted, this attribute’s value defaults to `WordPress Site`.*)
41 |
42 | The name of your site. e.g. `My Amazing Site`
43 |
44 | ### admin_user
45 |
46 | (*If omitted, this attribute’s value defaults to `admin`.*)
47 |
48 | The site administrator user name. e.g. `bronson`
49 |
50 | ### admin_email
51 |
52 | (*If omitted, this attribute’s value defaults to `admin@example.com`.*)
53 |
54 | The site administrators email address.
55 |
56 | ### admin_password
57 |
58 | (*If omitted, this attribute’s value defaults to `password`.*)
59 |
60 | The site administrators password: e.g. `aLbRY!Q9Qfh7YZ.h9jd!`
61 |
62 | ### network
63 |
64 | (*If omitted, this attribute’s value defaults to `false`.*)
65 |
66 | Whether or note the site is a multisite.
67 |
68 | Values: `true`, `false`.
69 |
70 | ### subdomains
71 |
72 | (*If omitted, this attribute’s value defaults to `false`.*)
73 |
74 | Whether or not the multiste is setup as a subdomain. If this is set to `false` then WordPress multisite will be setup for subfolders.
75 |
76 | Values: `true`, `false`.
77 |
78 | ### user
79 |
80 | (*If omitted, this attribute’s value defaults to `www-data`.*)
81 |
82 | The user to use to run the command.
83 |
84 | #### Examples
85 | Setup a normal WordPress installation.
86 | ```puppet
87 | wp::core { 'Setup a WordPress Site':
88 | url => "http://vagrant.local/",
89 | location => '/vagrant'
90 | sitename => 'My Amazing Site',
91 | admin_user => 'bronson',
92 | admin_email => 'bronson@here.com',
93 | admin_password => 'aLbRY!Q9Qfh7YZ.h9jd!',
94 | }
95 | ```
96 |
97 | Setup a WordPress multisite installation in subfolders.
98 | ```puppet
99 | wp::core { 'Setup a WordPress Site':
100 | url => "http://vagrant.local/",
101 | location => '/vagrant'
102 | sitename => 'My Amazing Site',
103 | admin_user => 'bronson',
104 | admin_email => 'bronson@here.com',
105 | admin_password => 'aLbRY!Q9Qfh7YZ.h9jd!',
106 | network => true,
107 | }
108 | ```
109 |
110 | Setup a WordPress multisite installation with subdomains.
111 | ```puppet
112 | wp::core { 'Setup a WordPress Site':
113 | url => "http://vagrant.local/",
114 | location => '/vagrant'
115 | sitename => 'My Amazing Site',
116 | admin_user => 'bronson',
117 | admin_email => 'bronson@here.com',
118 | admin_password => 'aLbRY!Q9Qfh7YZ.h9jd!',
119 | network => true,
120 | subdomains => true,
121 | }
122 | ```
123 |
--------------------------------------------------------------------------------
/docs/classes/option.md:
--------------------------------------------------------------------------------
1 | # Option
2 |
3 | * [Description](/classes/option.html#description)
4 | * [Attributes](/classes/option.html#attributes)
5 |
6 | ## Description
7 |
8 | Retrieves and sets site options, including plugin and WordPress settings.
9 |
10 | ## Attributes
11 | ``` puppet
12 | wp::option { 'resource title':
13 | location => # The location to run the command.
14 | key => # The name of the option to add.
15 | value => # The value of the option to add.
16 | ensure => # What state the option should be in.
17 | format => # The serialization format for the value.
18 | autoload => # Should this option be automatically loaded.
19 | user => # The user to run the command as.
20 | }
21 | ```
22 |
23 | ### location
24 |
25 | The directory from which to run the command. If this directory does not exist, the command will fail.
26 |
27 | ### key
28 |
29 | (*If omitted, this attribute’s value defaults to the resource’s title.*)
30 |
31 | The name of the option to add.
32 |
33 | ### value
34 |
35 | (*If omitted, this attribute’s value defaults `undef`.*)
36 |
37 | The value of the option to add.
38 |
39 | ### ensure
40 |
41 | (*If omitted, this attribute’s value defaults to `present`*)
42 |
43 | Values: `present`, `equal`, `absent`.
44 |
45 | ### format
46 |
47 | (*If omitted, this attribute’s value defaults to `plaintext`*)
48 |
49 | Values: `plaintext` or `json`.
50 |
51 | ### autoload
52 |
53 | (*If omitted, this attribute’s value defaults to `true`*).
54 |
55 | Values: `true` or `false`.
56 |
57 | ### user
58 |
59 | (*If omitted, this attribute’s value defaults to `www-data`.*)
60 |
61 | #### Examples
62 |
63 | ``` puppet
64 | wp::option 'Add and set Foo to Bar' {
65 | location => '/vagrant',
66 | key => 'Foo',
67 | value => 'Bar' ,
68 | }
69 | ```
70 |
71 | ``` puppet
72 | wp::option 'Update Foo to Fighters' {
73 | location => '/vagrant',
74 | key => 'Foo',
75 | value => 'Fighters',
76 | ensure => equal
77 | }
78 | ```
79 |
80 | ``` puppet
81 | wp::option 'Delete Foo' {
82 | location => '/vagrant',
83 | key => 'Foo',
84 | ensure => abest
85 | }
86 | ```
87 |
--------------------------------------------------------------------------------
/docs/classes/params.md:
--------------------------------------------------------------------------------
1 | # Params
2 |
3 | * [Description](/classes/params.html#description)
4 | * [Attributes](/classes/params.html#attributes)
5 |
6 | ## Description
7 |
8 | A class to define parameters we use throughout Puppet WP.
9 |
10 | ## Attributes
11 |
12 | ### user
13 |
14 | (*If omitted this attribute’s value defaults to www-data*)
15 |
16 | ### php_package
17 |
18 | (*If omitted this attribute’s value defaults to php-cli*)
19 |
20 | If the operating system is Debian or Ubuntu then the value is `php5-cli`.
21 |
--------------------------------------------------------------------------------
/docs/classes/plugin.md:
--------------------------------------------------------------------------------
1 | # Plugin
2 |
3 | * [Description](/classes/plugin.html#description)
4 | * [Attributes](/classes/plugin.html#attributes)
5 |
6 | ## Description
7 |
8 | Manages plugins, including installs, activations, and updates.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::plugin { 'resource title':
13 | location => # The location to run the command.
14 | slug => # The slug of the plugin in the WordPress repository.
15 | ensure => # What state the option should be in.
16 | networkwide => # Whether the state should be applied network wide.
17 | version => # The version of the plugin to install.
18 | all => # Set this to delete all plugins.
19 | skipdelete => # Only run the uninstall procedure.
20 | unless => # A test command that checks the state of the target system and restricts when the command can run.
21 | user => # The user to run the command as.
22 | onlyif => # A test command that checks the state of the target system and restricts when the command can run.
23 | }
24 | ```
25 |
26 | ### location
27 |
28 | The directory from which to run the command. If this directory does not exist, the command will fail.
29 |
30 | ### slug
31 |
32 | (*If omitted, this attribute’s value defaults to the resource’s title.*)
33 |
34 | ### ensure
35 |
36 | (*If omitted, this attribute’s value defaults to `enabled`.*)
37 |
38 | Values: `activate`, `enabled`, `disabled`, `installed`, `deleted`, `uninstalled`.
39 |
40 | ### networkwide
41 |
42 | (*If omitted, this attribute’s value defaults to `false`*)
43 |
44 | Values: `true`, `false`
45 |
46 | ### version
47 |
48 | (*If omitted, this attribute’s value defaults to the latest version in the WordPress repository*)
49 |
50 | Values: `latest` or a version number e.g. `1.0.1`.
51 |
52 | ### all
53 |
54 | (*If omitted, this attribute’s value defaults to `''`*)
55 |
56 | Values: `''` or `true`.
57 |
58 | ### skipdelete
59 |
60 | (*If omitted, this attribute’s value defaults to `''`*)
61 |
62 | Values: `''` or `true`.
63 |
64 | ### unless
65 |
66 | (*If omitted, this attribute’s value defaults to `undef` which Puppet treats as `false`.*)
67 |
68 | A test command that checks the state of the target system and restricts when the command can run.
69 |
70 | ### user
71 |
72 | (*If omitted, this attribute’s value defaults to `www-data`.*)
73 |
74 | ### onlyif
75 |
76 | (*If omitted, this attribute’s value defaults to `/usr/local/bin/wp core is-installed`.*)
77 |
78 | You can pass one or more checks into Puppet for this. e.g.
79 |
80 | ```puppet
81 | wp::command { 'WP-CLI Info':
82 | location => '/vagrant'
83 | command => '--info',
84 | onlyif => [
85 | '/usr/local/bin/wp core is-installed',
86 | '/usr/local/bin/wp theme is-active twentynineteen',
87 | ]
88 | }
89 | ```
90 |
91 | #### Examples
92 | Install and activate Yoast SEO.
93 | ```puppet
94 | wp::plugin { 'Install and activate Yoast SEO':
95 | location => '/vagrant',
96 | slug => 'wordpress-seo',
97 | ensure => 'enabled',
98 | }
99 | ```
100 |
101 | Install and activate Yoast SEO Network Wide.
102 | ```puppet
103 | wp::plugin { 'Install and activate Yoast SEO':
104 | location => '/vagrant',
105 | slug => 'wordpress-seo',
106 | ensure => 'enabled',
107 | networkwide => 'true',
108 | }
109 | ```
110 |
111 | Install Yoast SEO.
112 | ```puppet
113 | wp::plugin { 'Install Yoast SEO':
114 | location => '/vagrant',
115 | slug => 'wordpress-seo',
116 | ensure => 'installed',
117 | }
118 | ```
119 |
120 | Activate Yoast SEO.
121 | ```puppet
122 | wp::plugin { 'Activate Yoast SEO':
123 | location => '/vagrant',
124 | slug => 'wordpress-seo',
125 | ensure => 'activate',
126 | }
127 | ```
128 |
129 | Delete Hello Dolly.
130 | ```puppet
131 | wp::plugin { 'Delete Hello Dolly':
132 | location => '/vagrant',
133 | slug => 'hello-dolly',
134 | ensure => 'deleted',
135 | }
136 | ```
137 |
138 | Deactivate Hello Dolly.
139 | ```puppet
140 | wp::plugin { 'Deactivate Hello Dolly':
141 | location => '/vagrant',
142 | slug => 'hello-dolly',
143 | ensure => 'disabled',
144 | }
145 | ```
146 |
147 | Uninstall Hello Dolly.
148 | ```puppet
149 | wp::plugin { 'Uninstall Hello Dolly':
150 | location => '/vagrant',
151 | slug => 'hello-dolly',
152 | ensure => 'uninstalled',
153 | }
154 | ```
155 |
--------------------------------------------------------------------------------
/docs/classes/rewrite.md:
--------------------------------------------------------------------------------
1 | # Rewrite
2 |
3 | * [Description](/classes/rewrite.html#description)
4 | * [Attributes](/classes/rewrite.html#attributes)
5 |
6 | ## Description
7 |
8 | Lists or flushes the site’s rewrite rules, updates the permalink structure.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::rewrite { 'resource title':
13 | location => # The location to run the command.
14 | structure => # The rewrite structure.
15 | user => # The user to run the command as.
16 | }
17 | ```
18 |
19 | ### location
20 |
21 | The directory from which to run the command. If this directory does not exist, the command will fail.
22 |
23 | ### structure
24 |
25 | (*If omitted, this attribute’s value defaults to the resource’s title.*)
26 |
27 | Values: Any allowed WordPress permalink structure. e.g. `/%post_id%/%postname%/`, `/%year%/%monthnum%/%postname%/`, `/blog/%postname%/`.
28 |
29 | ### user
30 |
31 | (*If omitted, this attribute’s value defaults to `www-data`.*)
32 |
33 | The user to use to run the command.
34 |
35 | ### Examples
36 |
37 | ```puppet
38 | wp::rewrite { 'Year, Month, Name':
39 | location => '/vagrant',
40 | structure => '/%year%/%monthnum%/%postname%/',
41 | }
42 | ```
43 |
44 |
--------------------------------------------------------------------------------
/docs/classes/role.md:
--------------------------------------------------------------------------------
1 | # Role
2 |
3 | * [Description](/classes/role.html#description)
4 | * [Attributes](/classes/role.html#attributes)
5 |
6 | ## Description
7 |
8 | Manages user roles, including creating new roles and resetting to defaults.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::role { 'resource title':
13 | location => # The location to run the command.
14 | ensure => # What state the option should be in.
15 | id => # The role ID.
16 | rolename => # The role name.
17 | all => # If set this will delete all the themes apart from the theme that has been passed into the class.
18 | user => # The user to run the command as.
19 | onlyif => # A test command that checks the state of the target system and restricts when the exec can run.
20 | }
21 | ```
22 |
23 | ### location
24 |
25 | The directory from which to run the command. If this directory does not exist, the command will fail.
26 |
27 | ### ensure
28 |
29 | (*If omitted, this attribute’s value defaults to `present`.*)
30 |
31 | The action to run for the role.
32 |
33 | Values: `enabled`, `deleted` or `reset`.
34 |
35 | ### id
36 |
37 | The ID of the role. e.g. `approver`.
38 |
39 | ### rolename
40 |
41 | The description for the role. e.g. `Approver`
42 |
43 | ### all
44 |
45 | (*If omitted, this attribute’s value defaults to `false`.*)
46 |
47 | If this is set to `true` and `ensure => reset` then all roles will be reset.
48 |
49 | Values: `true` or `false`.
50 |
51 | ### user
52 |
53 | (*If omitted, this attribute’s value defaults to `www-data`.*)
54 |
55 | The user to use to run the command.
56 |
57 | ### onlyif
58 |
59 | (*If omitted, this attribute’s value defaults to `/usr/local/bin/wp core is-installed`.*)
60 |
61 | You can pass one or more checks into Puppet for this.
62 |
--------------------------------------------------------------------------------
/docs/classes/theme.md:
--------------------------------------------------------------------------------
1 | # Theme
2 |
3 | * [Description](/classes/theme.html#description)
4 | * [Attributes](/classes/theme.html#attributes)
5 |
6 | ## Description
7 |
8 | Manages themes, including installs, activations, and updates.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::theme { 'resource title':
13 | location => # The location to run the command.
14 | slug => # The slug of the theme.
15 | ensure => # What state the option should be in.
16 | user => # The user to run the command as.
17 | onlyif => # A test command that checks the state of the target system and restricts when the exec can run.
18 | all => # If set this will delete all the themes apart from the theme that has been passed into the class.
19 | mod => # The action of the theme mod.
20 | key => # The key of the theme mod.
21 | value => # The value of the theme mod.
22 | }
23 | ```
24 |
25 | ### location
26 |
27 | The directory from which to run the command. If this directory does not exist, the command will fail.
28 |
29 | ### slug
30 |
31 | The slug of the theme. e.g. `twentynineteen`.
32 |
33 | ### ensure
34 |
35 | (*If omitted, this attribute’s value defaults to `enabled`.*)
36 |
37 | Values: `activate`, `enabled`, `disabled`, `installed`, `deleted` or `mod`.
38 |
39 | ### version
40 |
41 | (*If omitted, this attribute’s value defaults to the latest version in the WordPress repository*)
42 |
43 | Values: `latest` or a version number e.g. `1.3`.
44 |
45 | ### unless
46 |
47 | (*If omitted, this attribute’s value defaults to `undef` which Puppet treats as `false`.*)
48 |
49 | A test command that checks the state of the target system and restricts when the command can run.
50 |
51 | ### user
52 |
53 | (*If omitted, this attribute’s value defaults to `www-data`.*)
54 |
55 | ### onlyif
56 |
57 | (*If omitted, this attribute’s value defaults to `/usr/local/bin/wp core is-installed`.*)
58 |
59 | You can pass one or more checks into Puppet for this. e.g.
60 |
61 | ```puppet
62 | wp::theme { 'Activate Twenty Nineteen':
63 | location => '/vagrant',
64 | slug => 'twentynineteen',
65 | ensure => 'enabled'
66 | onlyif => [
67 | '/usr/local/bin/wp core is-installed',
68 | '/usr/local/bin/wp theme is-active twentynineteen',
69 | ]
70 | }
71 | ```
72 |
73 | ### all
74 |
75 | (*If omitted, this attribute’s value defaults to `false`.*)
76 |
77 | If set this and `ensure => 'deleted'` then it will delete all the themes apart from the active theme.
78 | If set this and `mod => 'remove'` then it will delete all theme mods.
79 |
80 | Value: `true`.
81 |
82 | ```puppet
83 | wp::theme { 'Activate Twenty Nineteen and delete all other themes':
84 | location => '/vagrant',
85 | slug => 'twentynineteen',
86 | ensure => 'deleted',
87 | all => true,
88 | }
89 | ```
90 |
91 | ### mod
92 |
93 | (*If omitted, this attribute’s value defaults to `false`.*)
94 |
95 | Values: `get`, `set` or `remove`.
96 |
97 | ```puppet
98 | wp::theme { 'Activate Twenty Nineteen and delete all other themes':
99 | location => '/vagrant',
100 | ensure => 'mod',
101 | mod => 'set',
102 | key => 'background_color',
103 | value => '000000',
104 | }
105 | ```
106 |
107 | ### key
108 |
109 | (*If omitted, this attribute’s value defaults to `false`.*)
110 |
111 | This is the key used with [mod](/classes/theme.html#mod).
112 |
113 | ### value
114 |
115 | (*If omitted, this attribute’s value defaults to `false`.*)
116 |
117 | This is the value used with [mod](/classes/theme.html#mod).
118 |
119 | #### Examples
120 | ```puppet
121 | wp::theme { 'Activate Twenty Nineteen':
122 | location => '/vagrant',
123 | slug => 'twentynineteen',
124 | version => '1.3',
125 | ensure => 'enabled',
126 | }
127 | ```
128 |
--------------------------------------------------------------------------------
/docs/classes/user.md:
--------------------------------------------------------------------------------
1 | # User
2 |
3 | * [Description](/classes/user.html#description)
4 | * [Attributes](/classes/user.html#attributes)
5 |
6 | ## Description
7 |
8 | Manages users, along with their roles, capabilities, and meta.
9 |
10 | ## Attributes
11 | ```puppet
12 | wp::user { 'resource title':
13 | location => # The location to run the command.
14 | ensure => # What state the cap should be in.
15 | args => # The string of arguments to pass to the comment command.
16 | user => # The user to run the command as.
17 | onlyif => # A test command that checks the state of the target system and restricts when the exec can run.
18 | }
19 | ```
20 |
21 | ### location
22 |
23 | The directory from which to run the command. If this directory does not exist, the command will fail.
24 |
25 | ### ensure
26 |
27 | (*If omitted, this attribute’s value defaults to `present`.*)
28 |
29 | The state the capability should be in.
30 |
31 | Values: `present`, `absent`, `equal`, `generate`, `add-role`, `set-role`, `remove-role`, `add-cap`, `remove-cap`, `meta`, `term` or `import`.
32 |
33 | ### args
34 |
35 | A string of arguments to pass to the command. e.g.
36 | * If `ensure => generate` and `args => '--count=200'` then this would generate 200 users.
37 | * If `ensure => create` and `args => 'bob bob@example.com --role=author'` then this would generate a new user called `bob`.
38 | * If `ensure => meta` and `args => 'add 123 bio "Mary is an WordPress developer."'` then a `bio` custom field would be added to user with the ID of `123`.
39 |
40 | ### user
41 |
42 | (*If omitted, this attribute’s value defaults to `www-data`.*)
43 |
44 | The user to use to run the command.
45 |
46 | ### onlyif
47 |
48 | (*If omitted, this attribute’s value defaults to `/usr/local/bin/wp core is-installed`.*)
49 |
50 | You can pass one or more checks into Puppet for this.
51 |
--------------------------------------------------------------------------------
/docs/docs/README.md:
--------------------------------------------------------------------------------
1 | # Documentation
2 |
3 | ## VuePress
4 |
5 | We've used [VuePress](https://v1.vuepress.vuejs.org) to generate the documentation for Puppet WP.
6 |
7 | You can contribute updates to the documentation on any page by clicking on the `Suggest an edit!` links in the footer
8 | of any of the pages.
9 |
10 | ## VuePress Configuration
11 |
12 | The title, navigation, sidebar and repository links are all managed in `docs/.vuepress/config.js`.
13 |
14 | ## Documentation Installation
15 |
16 | If you'd like to contribute and preview your contributions before you submit a Pull Request to Puppet WP you can do
17 | the following:
18 |
19 | 1. Clone the repository to your computer:
20 | ``` git
21 | git clone https://github.com/Chassis/puppet-wp
22 | ```
23 | 1. Run `cd docs` in a terminal.
24 | 1. Run `yarn install`
25 | 1. Run `yarn docs:dev` and open [http://localhost:8080/]( http://localhost:8080/) in a browser.
26 | 1. Run `yarn docs:build` to build static assets.
27 |
28 | ## Documentation Deployment
29 |
30 | The [documentation](https://chassis.github.io/puppet-wp/) is hosted on Github Pages and this is automatically [deployed](https://github.com/Chassis/puppet-wp/blob/master/.travis.yml#L9-L23) with [TravisCI](https://travis-ci.org/).
31 |
32 | The `GITHUB_TOKEN` is a [personal access token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) which can be created on Github. Once created, this token should be copied into the Environmental Variables settings on TravisCI.
33 |
34 |
--------------------------------------------------------------------------------
/docs/docs/puppet-forge.md:
--------------------------------------------------------------------------------
1 | # Puppet Forge
2 |
3 | We also publish this module on Puppet Forge. [https://forge.puppet.com/chassis/puppet_wp](https://forge.puppet.com/chassis/puppet_wp)
4 |
5 | ## Requirements
6 |
7 | To publish the module on Puppet Forge you need to install the [Puppet Development Kit](https://puppet.com/docs/pdk/1.x/pdk.html)
8 |
9 | ### Installation on Mac OS X
10 |
11 | Run `brew cask install puppetlabs/puppet/pdk`.
12 |
13 | ### Installation on Linux
14 |
15 | Refer to the installation instructions for your [Linux distrobution](https://puppet.com/docs/pdk/1.x/pdk_install.html#install-pdk-linux).
16 |
17 | ### Installation on Windows
18 |
19 | Download the [installation](https://puppet.com/download-puppet-development-kit).
20 |
21 | ## Publishing the module
22 |
23 | Open a terminal and run the following commands:
24 |
25 | 1. Run `pdk new module` and answer the questions as follows:
26 | ```
27 | [Q 1/4] Summarize the purpose of this module in a single sentence.
28 | This helps other Puppet users understand what the module does.
29 | --> This modules manages your WordPress sites using WP-CLI, allowing you to install your site, manage plugins, themes, options and more.
30 |
31 | [Q 2/4] If there is a source code repository for this module, enter the URL here.
32 | Skip this if no repository exists yet. You can update this later in the metadata.json.
33 | --> https://github.com/Chassis/puppet_wp/
34 |
35 | [Q 3/4] If there is a URL where others can learn more about this module, enter it here.
36 | Optional. You can update this later in the metadata.json.
37 | --> https://chassis.github.io/puppet_wp/
38 |
39 | [Q 4/4] If there is a public issue tracker for this module, enter its URL here.
40 | Optional. You can update this later in the metadata.json.
41 | --> https://github.com/Chassis/puppet_wp/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
42 | ```
43 | 2. Increment the version number in `puppet_wp/metadata.json`.
44 | 3. Run `pdk build`.
45 |
--------------------------------------------------------------------------------
/docs/installation/README.md:
--------------------------------------------------------------------------------
1 | # Installation
2 | ## Via Git
3 | ``` git
4 | # (Assuming your modules directory is "modules/")
5 | # As a standalone repo
6 | git clone https://github.com/Chassis/puppet-wp.git modules/wp
7 |
8 | # As a submodule
9 | git submodule add https://github.com/Chassis/puppet-wp.git modules/wp
10 | ```
11 |
12 | ## Via the Puppet Forge
13 |
14 | Puppet WP-CLI is also available via Puppet Forge.
15 | ``` shell script
16 | puppet module install chassis-puppet_wp
17 | ```
18 |
--------------------------------------------------------------------------------
/docs/licence/README.md:
--------------------------------------------------------------------------------
1 | # Licence
2 |
3 | This code is licensed under the MIT license.
4 |
5 | Copyright (c) 2012-present [Ryan McCue](https://rmccue.io/), [Bronson Quick](https://www.bronsonquick.com.au/)
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 |
9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 |
--------------------------------------------------------------------------------
/manifests/cap.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI's cap commands.
2 | define wp::cap (
3 | $role,
4 | $cap,
5 | $location,
6 | $ensure = present,
7 | $grant = true,
8 | $user = $::wp::user,
9 | $onlyif = "${wp::params::bin_path}/wp core is-installed",
10 | ) {
11 | include wp::cli
12 |
13 | case $ensure {
14 | present: {
15 | $command = "add ${role} ${cap} --grant=${grant}"
16 | }
17 | absent: {
18 | $command = "remove ${role} ${cap}"
19 | }
20 | default: {
21 | fail( 'Invalid attribute for wp::cap' )
22 | }
23 | }
24 | wp::command { "${location} cap ${command}":
25 | location => $location,
26 | command => "cap ${command}",
27 | user => $user,
28 | onlyif => $onlyif,
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/manifests/cli.pp:
--------------------------------------------------------------------------------
1 | # A class to install WP-CLI.
2 | class wp::cli (
3 | $ensure = 'installed',
4 | $install_path = '/usr/local/src/wp-cli',
5 | $version = 'dev-master',
6 |
7 | ) inherits wp {
8 | if $facts['os']['family'] == 'Windows' {
9 | Package { provider => 'chocolatey' }
10 | }
11 |
12 | if 'installed' == $ensure or 'present' == $ensure {
13 | # Create the install path
14 | file { [ $install_path, "${install_path}/bin" ]:
15 | ensure => directory,
16 | }
17 |
18 | archive { 'wp-cli download':
19 | ensure => present,
20 | source => 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar',
21 | path => "${install_path}/bin/wp-cli.phar",
22 | }
23 |
24 | if $facts['kernel'] == 'Linux' {
25 | file { "${install_path}/bin/${wp::executable_filename}":
26 | ensure => 'present',
27 | content => template('wp/wp.sh.erb'),
28 | mode => 'a+x',
29 | require => Archive[ 'wp-cli download' ]
30 | }
31 |
32 | # Symlink it across
33 | file { "${wp::bin_path}/${wp::executable_filename}":
34 | ensure => link,
35 | target => "${install_path}/bin/${wp::executable_filename}",
36 | require => File[ "${install_path}/bin/wp" ],
37 | }
38 | } else {
39 |
40 | file { "${install_path}/bin/${wp::executable_filename}":
41 | ensure => 'present',
42 | content => template('wp/wp.bat.erb'),
43 | require => Archive[ 'wp-cli download' ]
44 | }
45 | }
46 | }
47 | elsif 'absent' == $ensure {
48 | file { "${wp::bin_path}/${wp::executable_filename}":
49 | ensure => absent,
50 | }
51 | file { '/usr/local/src/wp-cli':
52 | ensure => absent,
53 | }
54 | }
55 |
56 | if $::wp::manage_php_package and ! defined( Package[ $::wp::php_package ] ) {
57 | package { $::wp::php_package:
58 | ensure => installed,
59 | }
60 | }
61 |
62 | if $::wp::manage_curl_package and ! defined(Package['curl']) {
63 | package { 'curl':
64 | ensure => installed,
65 | }
66 | }
67 |
68 | if $::wp::manage_git_package and ! defined(Package['git']) {
69 | package { 'git':
70 | ensure => installed,
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/manifests/command.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI commands.
2 | define wp::command (
3 | $location,
4 | $command,
5 | $user = $::wp::user,
6 | $unless = undef,
7 | $onlyif = "${wp::bin_path}/${wp::executable_filename} core is-installed",
8 | ) {
9 | include wp::cli
10 |
11 | exec {"${location} wp ${command}":
12 | command => "${wp::bin_path}/${wp::executable_filename} ${command}",
13 | cwd => $location,
14 | user => $user,
15 | require => [ Class['wp::cli'] ],
16 | unless => $unless,
17 | onlyif => $onlyif,
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/manifests/comment.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI's commend commands.
2 | class wp::comment (
3 | $location,
4 | $args,
5 | $ensure = present,
6 | $metacommand = false,
7 | $user = $::wp::user,
8 | $onlyif = "${wp::params::bin_path}/wp core is-installed",
9 | ) {
10 | include wp::cli
11 |
12 | case $ensure {
13 | present: {
14 | $command = "create ${args}"
15 | }
16 | absent: {
17 | $command = "delete ${args}"
18 | }
19 | generate: {
20 | $command = "generate ${args}"
21 | }
22 | meta: {
23 | $command = "${metacommand} ${args}"
24 | }
25 | default: {
26 | fail( 'Invalid attribute for wp::comment' )
27 | }
28 | }
29 | wp::command { "${location} comment ${command}":
30 | location => $location,
31 | command => "comment ${command}",
32 | user => $user,
33 | onlyif => $onlyif,
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/manifests/config.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI's config commands.
2 | class wp::config (
3 | $location,
4 | $dbname,
5 | $dbuser,
6 | $dbpass,
7 | $ensure = present,
8 | $dbhost = 'localhost',
9 | $dbprefix = 'wp_',
10 | $dbcharset = 'utf8',
11 | $dbcollate = '',
12 | $locale = 'en_AU',
13 | $value = '',
14 | $user = $::wp::user,
15 | $unless = undef,
16 | $onlyif = "${wp::params::bin_path}/wp is-installed",
17 | ) {
18 | case $ensure {
19 | present: {
20 | $command = "create --dbname=${dbname} --dbuser${dbuser} --dbpass=${dbpass} --dbhost=${dbhost} --dbprefix=${dbprefix} --force"
21 | }
22 | absent: {
23 | $command = "delete ${value}"
24 | }
25 | equal: {
26 | $command = "set ${value}"
27 | }
28 | default: {
29 | fail( 'Invalid attribute for wp::config' )
30 | }
31 | }
32 | wp::command { "${location} config ${command}":
33 | location => $location,
34 | command => "config ${command}",
35 | user => $user,
36 | unless => $unless,
37 | onlyif => $onlyif,
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/manifests/core.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI core commands.
2 | define wp::core (
3 | $url,
4 | $location = $title,
5 | $siteurl = $url,
6 | $sitename = 'WordPress Site',
7 | $admin_user = 'admin',
8 | $admin_email = 'admin@example.com',
9 | $admin_password = 'password',
10 | $network = false,
11 | $subdomains = false,
12 | $user = $::wp::user,
13 | ) {
14 | include wp::cli
15 |
16 | if ( $network == true ) and ( $subdomains == true ) {
17 | $install = "multisite-install --subdomains --url='${url}'"
18 | }
19 | elsif ( $network == true ) {
20 | $install = "multisite-install --url='${url}'"
21 | }
22 | else {
23 | $install = "install --url='${url}'"
24 | }
25 |
26 | $command = "${install} --title='${sitename}' --admin_email='${admin_email}' --admin_user='${admin_user}' --admin_password='${admin_password}'"
27 |
28 | wp::command { "${location} core ${command}":
29 | location => $location,
30 | command => "core ${command}",
31 | unless => "${wp::params::bin_path}/wp core is-installed",
32 | user => $user,
33 | onlyif => [],
34 | }
35 |
36 | if $siteurl != $url {
37 | wp::option {"wp siteurl ${location}":
38 | ensure => 'equal',
39 | location => $location,
40 | user => $user,
41 | key => 'siteurl',
42 | value => $siteurl
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/manifests/create_subsite.pp:
--------------------------------------------------------------------------------
1 | # Create a type for "wp site create"
2 | define wp::create_subsite (
3 | $aliases,
4 | $location,
5 | ) {
6 | # Generate the slugs for the subsites.
7 | if ( $name != $aliases[0] ) {
8 | $slug = regsubst( $name, ".${aliases[0]}", '')
9 | }
10 |
11 | if ( $slug ) {
12 | exec { "wp site create --slug=${slug}":
13 | cwd => $location,
14 | user => $::wp::user,
15 | command => "${wp::params::bin_path}/wp site create --slug=${slug}",
16 | unless => "${wp::params::bin_path}/wp site list | grep ${slug}",
17 | require => Class['wp::cli'],
18 | onlyif => "${wp::params::bin_path}/wp core is-installed",
19 | logoutput => true
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/manifests/init.pp:
--------------------------------------------------------------------------------
1 | # Our base Puppet WP Class.
2 | class wp (
3 | $user = $::wp::params::user,
4 | $php_package = $::wp::params::php_package,
5 | $php_executable_path = $::wp::params::php_executable_path,
6 | $bin_path = $::wp::params::bin_path,
7 | $executable_filename = $::wp::params::executable_filename,
8 | $manage_php_package = $::wp::params::manage_php_package,
9 | $manage_curl_package = $::wp::params::manage_curl_package,
10 | $manage_git_package = $::wp::params::manage_git_package,
11 | ) inherits wp::params {
12 | # ...
13 | }
14 |
--------------------------------------------------------------------------------
/manifests/option.pp:
--------------------------------------------------------------------------------
1 | # A class for WordPress options.
2 | define wp::option (
3 | $location,
4 | $key = $title,
5 | $value = undef,
6 | $ensure = present,
7 | $format = 'plaintext',
8 | $autoload = true,
9 | $user = $::wp::user,
10 | ) {
11 | include wp::cli
12 |
13 | case $ensure {
14 | present: {
15 | $command = "add ${key} --format=${format} --autoload=${autoload}"
16 | }
17 | equal: {
18 | if $value == undef {
19 | fail('Option value must be specified')
20 | }
21 | $command = "update ${key} ${value}"
22 | }
23 | absent: {
24 | $command = "delete ${key}"
25 | }
26 | default: {
27 | fail('Invalid option operation')
28 | }
29 | }
30 |
31 | wp::command { "${location} option ${command}":
32 | location => $location,
33 | command => "option ${command}",
34 | user => $user,
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/manifests/option/patch.pp:
--------------------------------------------------------------------------------
1 | # A class for WordPress option patch subcommand.
2 | define wp::option::patch (
3 | $location,
4 | $key = $title,
5 | $key_path = undef,
6 | $value = undef,
7 | $ensure = present,
8 | $format = 'plaintext',
9 | $user = $::wp::user,
10 | ) {
11 | include wp::cli
12 |
13 | case $ensure {
14 | present: {
15 | $command = "insert ${key} ${key_path} ${value} --format=${format}"
16 | }
17 | equal: {
18 | if $value == undef {
19 | fail('Option value must be specified')
20 | }
21 | $command = "update ${key} ${key_path} ${value}"
22 | }
23 | absent: {
24 | $command = "delete ${key} ${key_path}"
25 | }
26 | default: {
27 | fail('Invalid option operation')
28 | }
29 | }
30 |
31 | wp::command { "${location} option patch ${command}":
32 | location => $location,
33 | command => "option patch ${command}",
34 | user => $user,
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/manifests/params.pp:
--------------------------------------------------------------------------------
1 | # A class for parameters we might need to use.
2 | class wp::params {
3 | $user = $facts['os']['family'] ? {
4 | 'windows' => undef,
5 | default => 'www-data',
6 | }
7 | $bin_path = '/usr/local/bin'
8 | $executable_filename = $facts['os']['family'] ? {
9 | 'windows' => 'wp.bat',
10 | default => 'wp',
11 | }
12 | $php_package = $facts['os']['family'] ? {
13 | /^(Debian|Ubuntu)$/ => 'php5-cli',
14 | 'windows' => 'php',
15 | default => 'php-cli',
16 | }
17 | $php_executable_path = $facts['os']['family'] ? {
18 | 'windows' => 'C:/tools/php80/php.exe',
19 | default => '/usr/bin/php',
20 | }
21 | $manage_php_package = true
22 | $manage_curl_package = true
23 | $manage_git_package = true
24 | }
25 |
--------------------------------------------------------------------------------
/manifests/plugin.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI's plugin commands.
2 | define wp::plugin (
3 | $location,
4 | $slug = $title,
5 | $ensure = enabled,
6 | $networkwide = false,
7 | $version = 'latest',
8 | $held = '',
9 | $all = '',
10 | $skipdelete = '',
11 | $unless = undef,
12 | $user = $::wp::user,
13 | $onlyif = "${wp::params::bin_path}/wp core is-installed",
14 | ) {
15 | include wp::cli
16 |
17 | if ( $networkwide ) {
18 | $network = ' --network'
19 | }
20 |
21 | if ( $version != 'latest' ) {
22 | $held = " --version=${version}"
23 | }
24 |
25 | if ( empty( $all ) ) {
26 | $delete_all_plugins = ' --all'
27 | }
28 |
29 | if ( empty( $skipdelete ) ) {
30 | $skip_deleting_plugins = ' --skip-delete'
31 | }
32 |
33 | case $ensure {
34 | activate: {
35 | $command = "activate ${slug} ${held}"
36 | $unless_check = "${wp::params::bin_path}/wp plugin is-active ${slug}"
37 | }
38 | enabled: {
39 | $command = "install ${slug} --activate ${held}"
40 | $unless_check = "${wp::params::bin_path}/wp plugin is-installed ${slug}"
41 | }
42 | disabled: {
43 | $command = "${wp::params::bin_path}/wp plugin deactivate ${slug}"
44 | }
45 | installed: {
46 | $command = "install ${slug} ${held}"
47 | $unless_check = "${wp::params::bin_path}/wp plugin is-installed ${slug}"
48 | }
49 | deleted: {
50 | $command = "delete ${slug}${delete_all_plugins}"
51 | }
52 | uninstalled: {
53 | $command = "uninstall ${slug} --deactivate${skip_deleting_plugins}"
54 | }
55 | default: {
56 | fail('Invalid ensure argument passed into wp::plugin')
57 | }
58 | }
59 | wp::command { "${location} ${command}":
60 | location => $location,
61 | command => "plugin ${command}",
62 | unless => $unless_check,
63 | user => $user,
64 | onlyif => $onlyif,
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/manifests/rewrite.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI rewrites.
2 | define wp::rewrite (
3 | $location,
4 | $structure = $title,
5 | $user = $::wp::user,
6 | ) {
7 | include wp::cli
8 |
9 | wp::command { "${location} rewrite structure '${structure}'":
10 | location => $location,
11 | command => "rewrite structure '${structure}'",
12 | user => $user,
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/manifests/role.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI roles.
2 | define wp::role (
3 | $location,
4 | $id,
5 | $rolename,
6 | $ensure = present,
7 | $all = false,
8 | $user = $::wp::user,
9 | $onlyif = "${wp::params::bin_path}/wp core is-installed",
10 | ) {
11 | include wp::cli
12 |
13 | case $ensure {
14 | enabled: {
15 | $command = "create ${id} ${rolename}"
16 | }
17 | deleted: {
18 | $command = "delete ${id}"
19 | }
20 | reset: {
21 | if ( $all ) {
22 | $command = 'reset --all'
23 | } else {
24 | $command = "reset ${id}"
25 | }
26 | }
27 | default: {
28 | fail( 'Invalid attributes for wp::role' )
29 | }
30 | }
31 |
32 | wp::command { "${location} role ${command}":
33 | location => $location,
34 | command => $command,
35 | user => $user,
36 | onlyif => $onlyif,
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/manifests/site.pp:
--------------------------------------------------------------------------------
1 | # Create a type for "wp site" commands
2 | define wp::site (
3 | $aliases = [],
4 | $location = undef,
5 | ) {
6 | include wp::cli
7 |
8 | wp::create_subsite { $aliases:
9 | aliases => $aliases,
10 | location => $location,
11 | }
12 | }
--------------------------------------------------------------------------------
/manifests/theme.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI theme commands.
2 | define wp::theme (
3 | $location,
4 | $slug = $title,
5 | $ensure = enabled,
6 | $networkwide = false,
7 | $version = 'latest',
8 | $held = '',
9 | $unless = undef,
10 | $user = $::wp::user,
11 | $onlyif = "${wp::params::bin_path}/wp core is-installed",
12 | $all = false,
13 | $mod = false,
14 | $key = false,
15 | $value = false,
16 | ) {
17 | include wp::cli
18 |
19 | if ( $networkwide ) {
20 | $network = ' --network'
21 | }
22 |
23 | if ( $version != 'latest' ) {
24 | $held = " --version=${version}"
25 | }
26 |
27 | if ( $all ) {
28 | $remove_all = ' --all'
29 | }
30 |
31 | case $ensure {
32 | activate: {
33 | $command = "activate ${slug}${held}"
34 | }
35 | enabled: {
36 | $command = "install ${slug}${held} --activate"
37 | }
38 | disabled: {
39 | $command = "disable ${slug}${network}"
40 | }
41 | installed: {
42 | $command = "install ${slug}${held}"
43 | }
44 | deleted: {
45 | if ( $all ) and ( $mod != false ) {
46 | $command = "delete ${slug}${held}$"
47 | } else {
48 | $command = "delete ${remove_all}"
49 | }
50 | }
51 | mod: {
52 | if ( $all ) and ( $mod != 'remove' ) {
53 | $command = "mod ${mod} ${key} ${value}"
54 | } else {
55 | $command = "mod ${mod} ${remove_all}"
56 | }
57 | }
58 | default: {
59 | fail('Invalid ensure for wp::theme')
60 | }
61 | }
62 | wp::command { "${location} theme ${command}":
63 | location => $location,
64 | command => "theme ${command}",
65 | user => $user,
66 | unless => $unless,
67 | onlyif => $onlyif,
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/manifests/user.pp:
--------------------------------------------------------------------------------
1 | # A class for WP-CLI's user commands.
2 | class wp::user (
3 | $location,
4 | $args,
5 | $ensure = present,
6 | $user = $::wp::user,
7 | $onlyif = "${wp::params::bin_path}/wp core is-installed",
8 | ) {
9 | include wp::cli
10 |
11 | case $ensure {
12 | present: {
13 | $command = "create ${args}"
14 | }
15 | absent: {
16 | $command = "delete ${args}"
17 | }
18 | equal: {
19 | $command = "update ${args}"
20 | }
21 | generate: {
22 | $command = "generate ${args}"
23 | }
24 | add-role: {
25 | $command = "add-role ${args}"
26 | }
27 | set-role: {
28 | $command = "set-role ${args}"
29 | }
30 | remove-role: {
31 | $command = "remove-role ${args}"
32 | }
33 | add-cap: {
34 | $command = "add-cap ${args}"
35 | }
36 | remove-cap: {
37 | $command = "remove-cap ${args}"
38 | }
39 | meta: {
40 | $command = "meta ${args}"
41 | }
42 | term: {
43 | $command = "term ${args}"
44 | }
45 | import: {
46 | $command = "import-csv ${args}"
47 | }
48 | default: {
49 | fail( 'Invalid attribute for wp::user' )
50 | }
51 | }
52 | wp::command { "${location} user ${command}":
53 | location => $location,
54 | command => "user ${command}",
55 | user => $user,
56 | onlyif => $onlyif,
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "chassis/puppet_wp",
3 | "version": "1.2.0",
4 | "author": "Ryan McCue, Bronson Quick",
5 | "summary": "This modules manages your WordPress sites using WP-CLI, allowing you to install your site, manage plugins, themes, options and more.",
6 | "license": "LGPL-3.0 License",
7 | "source": "https://github.com/Chassis/puppet-wp",
8 | "project_page": "https://chassis.github.io/puppet-wp/",
9 | "issues_url": "https://github.com/Chassis/puppet-wp/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc",
10 | "dependencies": [],
11 | "operatingsystem_support": [
12 | {
13 | "operatingsystem": "Ubuntu",
14 | "operatingsystemrelease": [
15 | "16.04",
16 | "18.04",
17 | "20.04"
18 | ]
19 | },
20 | {
21 | "operatingsystem": "Windows",
22 | "operatingsystemrelease": [
23 | "10"
24 | ]
25 | }
26 | ],
27 | "requirements": [
28 | {
29 | "name": "puppet",
30 | "version_requirement": ">= 5.4.0"
31 | }
32 | ],
33 | "tags": ["wordpress","wp-cli"]
34 | }
35 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "docs:dev": "vuepress dev docs",
4 | "docs:build": "vuepress build docs"
5 | },
6 | "devDependencies": {
7 | "vuepress": "^1.8.2"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/spec/defines/cap_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'Wp::Cap' do
4 | let(:environment) { 'development' }
5 | let(:title) { 'wp cap' }
6 | let(:params) do {
7 | 'role' => 'editor',
8 | 'cap' => 'edit_posts',
9 | 'location' => '/vagrant',
10 | }
11 | end
12 | it { is_expected.to compile }
13 |
14 | # Test a cap removal.
15 | context 'cap removal' do
16 | let(:params) do
17 | super().merge({ 'ensure' => 'absent' })
18 | end
19 | it { is_expected.to compile }
20 | end
21 |
22 | # Test a custom location.
23 | context 'with location => /chassis' do
24 | let(:params) do
25 | super().merge({ 'location' => '/chassis' })
26 | end
27 | it { is_expected.to compile }
28 | end
29 |
30 | # Test without role.
31 | context 'without role' do
32 | let(:params) do
33 | super().merge({ 'role' => '' })
34 | end
35 | it { is_expected.to compile }
36 | end
37 |
38 | # Test without cap.
39 | context 'without cap' do
40 | let(:params) do
41 | super().merge({ 'cap' => '' })
42 | end
43 | it { is_expected.to compile }
44 | end
45 |
46 | # Test without ensure.
47 | context 'without ensure' do
48 | let(:params) do
49 | super().merge({ 'ensure' => '' })
50 | end
51 | it { is_expected.not_to compile }
52 | end
53 |
54 | # Test with grant false.
55 | context 'grant false' do
56 | let(:params) do
57 | super().merge({ 'grant' => false })
58 | end
59 | it { is_expected.to compile }
60 | end
61 |
62 | # Test with a different user.
63 | context 'cap with different user' do
64 | let(:params) do
65 | super().merge({ 'user' => 'vagrant' })
66 | end
67 | it { is_expected.to compile }
68 | end
69 |
70 | # Test without onlyif.
71 | context 'without onlyif' do
72 | let(:params) do
73 | super().merge({ 'onlyif' => '' })
74 | end
75 | it { is_expected.not_to compile }
76 | end
77 | end
78 |
--------------------------------------------------------------------------------
/spec/defines/command_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'Wp::Command' do
4 | let(:environment) { 'development' }
5 | let(:title) { 'wp --info' }
6 | let(:params) do {
7 | 'location' => '/vagrant',
8 | 'command' => '--info',
9 | 'user' => 'www-data',
10 | 'unless' => :undef,
11 | 'onlyif' => "/vagrant/wp is-installed",
12 | 'require' => ref( 'Class', 'wp::cli'),
13 | }
14 | end
15 | it { is_expected.to compile }
16 |
17 | # Test a custom location.
18 | context 'with location => /chassis' do
19 | let(:params) do
20 | super().merge({ 'location' => '/chassis' })
21 | end
22 | it { is_expected.to compile }
23 | end
24 |
25 | # Test a custom user.
26 | context 'with user => /vagrant' do
27 | let(:params) do
28 | super().merge({ 'user' => 'vagrant' })
29 | end
30 | it { is_expected.to compile }
31 | end
32 |
33 | # Test a without location.
34 | context 'without location' do
35 | let(:params) do
36 | super().merge({ 'location' => '' })
37 | end
38 | it { is_expected.not_to compile }
39 | end
40 |
41 | # Test a without command.
42 | context 'without command' do
43 | let(:params) do
44 | super().merge({ 'command' => '' })
45 | end
46 | it { is_expected.to compile }
47 | end
48 |
49 | # Test a without user.
50 | context 'without user' do
51 | let(:params) do
52 | super().merge({ 'user' => '' })
53 | end
54 | it { is_expected.to compile }
55 | end
56 |
57 | # Test a without onlyif.
58 | context 'without onlyif' do
59 | let(:params) do
60 | super().merge({ 'onlyif' => '' })
61 | end
62 | it { is_expected.not_to compile }
63 | end
64 | end
65 |
--------------------------------------------------------------------------------
/spec/fixtures/manifests/site.pp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Chassis/puppet-wp/4d53ca4dc0b391670babd519ddc2d843ffec6fda/spec/fixtures/manifests/site.pp
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'puppetlabs_spec_helper/module_spec_helper'
2 | require 'rspec-puppet'
3 |
4 | fixture_path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures')
5 |
6 | RSpec.configure do |c|
7 | c.module_path = File.join(fixture_path, 'modules')
8 | c.manifest_dir = File.join(fixture_path, 'manifests')
9 | c.manifest = File.join(fixture_path, 'manifests', 'site.pp')
10 | c.environmentpath = File.join(Dir.pwd, 'spec')
11 | end
12 |
--------------------------------------------------------------------------------
/templates/wp.bat.erb:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | <%= @php_executable_path %> "%~dp0/wp-cli.phar" %*
3 |
4 |
--------------------------------------------------------------------------------
/templates/wp.sh.erb:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | <%= @php_executable_path %> "$(dirname "$(readlink -f "$0")")/wp-cli.phar" "$@"
3 |
4 |
--------------------------------------------------------------------------------