Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #2

Merged
merged 28 commits into from
Sep 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3c1d9af
deleted apt and mongodb repos. will add submodules to the actual repos
onema Jul 30, 2013
ff50215
adding submodules for the following repositories apt: [email protected]:…
onema Jul 30, 2013
feb2e28
added yum submodules to repository
onema Jul 30, 2013
0de2d49
Forked original repo and modified attribute names to set custom clust…
onema Aug 1, 2013
bbfcef0
change module source to new fork
onema Aug 2, 2013
6e2f55b
added build-essential submodule
onema Aug 2, 2013
e4fbf1e
added xml submodulex
onema Aug 3, 2013
5bf7305
updated mongodb paths to use /vol/mongodb instead of the default ones.
onema Aug 6, 2013
318b530
updated default mongodb path in mongodb repo.
onema Aug 8, 2013
81e1fdd
Merge pull request #13 from alleluu/develop
onema Aug 13, 2013
6b5b0e4
Adding a recipe to set environment variables using php, this requires…
onema Aug 17, 2013
efd3140
Merge branch 'develop-submodules' of github.com:alleluu/chef-cookbook…
onema Aug 17, 2013
e57f5d4
Merge pull request #14 from alleluu/develop-submodules
onema Aug 17, 2013
e27c5e2
Merge pull request #15 from alleluu/develop
onema Aug 22, 2013
1c63e79
Update environment_variables.php.erb
onema Sep 21, 2013
a93711a
Merge pull request #17 from alleluu/develop
onema Sep 21, 2013
d705249
Update phpvars.rb
onema Sep 21, 2013
b5770bc
Merge pull request #18 from alleluu/develop
onema Sep 21, 2013
07cbd39
deleted php coockbook as it was causing conflict with default opswork…
onema Sep 22, 2013
fd57acc
Merge branch 'develop-docRootFix' of github.com:alleluu/chef-cookbook…
onema Sep 23, 2013
bdc92a8
updated from main repo
onema Sep 23, 2013
8e9a180
updated phpenv environment variables recipes to support to methods to…
onema Sep 23, 2013
ffa6a52
Merge branch 'master' into develop
onema Sep 23, 2013
1064740
added documentation
onema Sep 23, 2013
7a6a507
Merge pull request #19 from alleluu/develop-docRootFix
onema Sep 23, 2013
afe10da
Upated version and fixed a bug caused by invalid permissions in envir…
onema Sep 23, 2013
22835be
Merge branch 'develop' of github.com:alleluu/chef-cookbooks into develop
onema Sep 23, 2013
bca88a8
Merge branch 'develop' of github.com:alleluu/chef-cookbooks into develop
onema Sep 24, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[submodule "mongodb"]
path = mongodb
url = [email protected]:alleluu/chef-mongodb.git
[submodule "apt"]
path = apt
url = [email protected]:opscode-cookbooks/apt.git
[submodule "yum"]
path = yum
url = [email protected]:opscode-cookbooks/yum.git
[submodule "build-essential"]
path = build-essential
url = [email protected]:opscode-cookbooks/build-essential.git
[submodule "xml"]
path = xml
url = [email protected]:opscode-cookbooks/xml.git
141 changes: 139 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Currently two PHP frameworks are supported: [FuelPHP](https://fuelphp.com) and [S

Some of the cookbooks functionality include:
- Enable Memory Swap for micro instances.
- Create custom files to include environment variables using either .htaccess or php files.
- Composer install and update.
- ACL setup for Ubuntu instances.
- FuelPHP database configuration for both OpsWorks Database layer and RDS.
Expand All @@ -26,7 +27,7 @@ Some of the cookbooks functionality include:
* mod_env must be enabled.

# Version
0.1.1
0.2.0

# Credits
Some parts of this code where taken from the [ace-cookbooks opsworks_app_environment](https://github.com/ace-cookbooks/opsworks_app_environment). Also see [this](https://forums.aws.amazon.com/thread.jspa?threadID=118107).
Expand Down Expand Up @@ -61,6 +62,140 @@ This recipe installs the mongodb php driver using PECL (Requires the **php-pear*

Use recipe on **Setup** ONLY.

###phpenv::htaccess_env_vars
This recipe creates a custom .htaccess in the directory of your choice and sets
environment variables using the apache setEnv directive. A default .htaccess file is
provided with this recipe, but a custom .htaccess file can be used.
The recipe can create a unique .htaccess file for each application in the stack.
Two configuration values are required to make this recipe work: ```htaccess_template``` for example htaccess.rb,
and ```path_to_vars``` This is the path where the htaccess file will be created.
The evironment variables can be set in the custom Chef JSON like this:

```
{
"custom_env": {
"staging_site": {
"environment": "staging",
"htaccess_template": "htaccess.rb",
"path_to_vars": "web",
"env_vars" : [
"CACHE_TIME 3600",
"SOME_API_KEY BlahBlah",
"ANOTHER_API_KEY helloWorld!"
]
},
"production_site": {
"environment": "production",
"htaccess_template": "advanced_htaccess.rb",
"path_to_vars": "public",
"env_vars" : [
"CACHE_TIME 1234",
"SOME_API_KEY nahnah",
"ANOTHER_API_KEY hello-monkey!"
]
}
}
}
```

The name custom_env is required. The values staging_site and production_site are the applications created in this stack and
must match the application name.

The array of values ```"env_vars"``` will have any environment variable needed to run the application. The format is

"KEY value" (KEY space VALUE)

in the example above the production site $_SERVER array would look like this:

```php
Array
(
//...
[ANOTHER_API_KEY] => hello-monkey!
[GA_API_CACHE_TIME] => 1234
[SOME_API_KEY] => nahnah
//...
)
```

**NOTE: THE RECIPE WILL NOT WORK IF YOUR APPLICATION NAME HAS SPACES OR DASHES "-" BETWEEN WORDS. Use underscores "_" to separate words to avoid problems**
**NOTE2: THESE ENVIRONMENT VALUES WILL NOT BE AVAILABLE IN THE TERMINAL. ANY TASKS YOU RUN FROM THE TERMINAL MUST SET THE EVIRONMENT NAME**
The .htaccess generated by this recipe will look like this:

```
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

<IfModule mod_env.c>
# Environment Variables for application production_site
SetEnv ANOTHER_API_KEY hello-monkey!
SetEnv GA_API_CACHE_TIME 1234
SetEnv SOME_API_KEY nahnah
</IfModule>
</IfModule>
```

###phpenv::php_env_vars
This recipe creates a custom ```environment_variables.php``` in the directory of your choice and sets
environment variables using the [putenv](https://php.net/manual/en/function.putenv.php) function.
In order to use this file and have the env vars available on every request, the file must be
included each time. The recipe can create a unique file for each application in the stack.
One configuration values is required to make this recipe work: ```path_to_vars```.
This is the path where the ```environment_variales.php``` file will be created.

The evironment variables can be set in the custom Chef JSON like this:

```
{
"custom_env": {
"staging_site": {
"environment": "staging",
"path_to_vars": "src/acme/application/config/staging",
"env_vars" : [
"CACHE_TIME=3600",
"SOME_API_KEY=BlahBlah",
"ANOTHER_API_KEY=helloWorld!"
]
},
"production_site": {
"htaccess_template": "advanced_htaccess.rb",
"path_to_vars": "src/acme/application/config/production",
"env_vars" : [
"CACHE_TIME=1234",
"SOME_API_KEY=nahnah",
"ANOTHER_API_KEY=hello-monkey!"
]
}
}
}
```

The name custom_env is required. The values staging_site and production_site are the applications created in this stack and
must match the application name.

The array of values ```"env_vars"``` will have any environment variable needed to run the application. The format is

"KEY=value"


Note that in this case we do not add an environment value for FUEL_ENV, this is
because the recipe will use the application value ```environment``` to set it.

**NOTE: THE RECIPE WILL NOT WORK IF YOUR APPLICATION NAME HAS SPACES OR DASHES "-" BETWEEN WORDS. Use underscores "_" to separate words to avoid problems**
**NOTE2: THESE ENVIRONMENT VALUES WILL NOT BE AVAILABLE IN THE TERMINAL. ANY TASKS YOU RUN FROM THE TERMINAL MUST SET THE EVIRONMENT NAME**
The ```environment_variables.php``` generated by this recipe will look like this:

```
// Environment Variables for application production_site
putenv("ANOTHER_API_KEY hello-monkey!");
putenv("FUEL_ENV production");
putenv("GA_API_CACHE_TIME 1234");
putenv("SOME_API_KEY nahnah");
```

###Other recipes
Other recipes have been deprecated or moved to other cookbooks because they are framework dependent and will be removed in the next version.

Expand All @@ -79,6 +214,8 @@ to the current deployment directory and will run ```$ php composer.phar update``
This is a collection of recipes for the FuelPHP framework.

###fuel::env_vars
**Deprecated, use phpenv::htaccess_env_vars or phpenv::php_env_vars**

Currently it is not possible to setup Environment Variables for PHP stacks in
Amazon Web Services OpsWorks. This recipe creates a custom .htaccess in the public
dicrectory and sets environment variables using the apache setEnv directive. The
Expand Down Expand Up @@ -133,7 +270,7 @@ Note that in this case we do not add an environment value for FUEL_ENV, this is
because the recipe will use the application value ```environment``` to set it.

**NOTE: THE RECIPE WILL NOT WORK IF YOUR APPLICATION NAME HAS SPACES OR DASHES "-" BETWEEN WORDS. Use underscores "_" to separate words to avoid problems**
**NOTE2: THESE ENVIRONMENT VALUES WILL NOT BE ABAILABLE IN THE TERMINAL. ANY TASKS YOU RUN FROM THE TERMINAL MUST SET THE EVIRONMENT NAME**
**NOTE2: THESE ENVIRONMENT VALUES WILL NOT BE AVAILABLE IN THE TERMINAL. ANY TASKS YOU RUN FROM THE TERMINAL MUST SET THE EVIRONMENT NAME**
The .htaccess generated by this recipe will look like this:

```
Expand Down
109 changes: 0 additions & 109 deletions apt/README.md

This file was deleted.

1 change: 0 additions & 1 deletion apt/attributes/default.rb

This file was deleted.

9 changes: 0 additions & 9 deletions apt/files/default/apt-cacher

This file was deleted.

Loading