ndench.environment
is an Ansible role which:
- adds
/etc/environment
variables- adds php-fpm
pool.d/www.conf
variablesCredit to the franklinkim.environment role which sets the system environment variables.
Using ansible-galaxy
:
$ ansible-galaxy install ndench.environment
Using requirements.yml
:
- src: ndench.environment
Using git
:
$ git clone https://github.com/ndench/ansible-environment.git ndench.environment
- Ansible >= 2.4
Here is a list of all the default variables for this role, which are also available in defaults/main.yml
.
---
# A dictionary of environment files i.e
# environment_files:
# # Keys can be anything, as long as they're unique
# # They're used in the files section of each environment_config
# env:
# path: /etc/environment
# format: system
# owner: root
# group: root
#
# www.conf:
# path: /etc/php/7.1/fpm/pool.d/www.conf
# format: php.ini
# service: php7.1-fpm # Service to restart once changes are made
environment_files:
system:
path: /etc/environment
format: system
# A dictionary of config parameters i.e
# environment_config:
# LC_ALL:
# value: en_US.UTF-8
# environment_files: [env] # Added to env environment_file
# APP_ENV:
# value: prod
# environment_files: [env, www.conf] # Added to env and www.conf environment_files
# APP_PASSWORD:
# value: security
# environment_files: [www.conf] # Added to www.conf environment
environment_config: {}
This is an example playbook:
---
- hosts: all
roles:
- ndench.environment
vars:
environment_files:
# Keys can be anything, as long as they're unique
# They're used in the files section of each environment_config
env:
path: /etc/system.environment
format: system
owner: root
group: root
www.conf:
# Test box doesn't have php installed
path: /etc/php.ini_pool.d_www.conf
format: php.ini
#service: php7.1-fpm # Service to restart once changes are made
environment_config:
- key: LC_ALL
value: en_US.UTF-8
files: [env] # Added to system environment
- key: APP_ENV
value: prod
files: [env, www.conf] # Added to system and php-fpm environments
- key: APP_PASSWORD
value: security
files: [www.conf] # Added to php-fpm environment
$ git clone https://github.com/ndench/ansible-environment.git
$ cd ansible-environment
$ make test
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests and examples for any new or changed functionality.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Note: To update the README.md
file please install and run ansible-role
:
$ gem install ansible-role
$ ansible-role docgen
- Use handlers to stop the services having to restart them multiple times
- Make the tests check the file contents
Copyright (c) Nathan Dench under the MIT license.