├── .gitignore ├── LICENSE ├── README.md ├── generators └── app │ ├── index.js │ └── templates │ ├── .editorconfig │ ├── .eslintignore │ ├── .npmignore │ ├── .yo-rc.json │ ├── README.md │ ├── Vagrantfile │ ├── ansible.cfg │ ├── client │ └── internals │ │ └── webpack │ │ └── webpack.base.babel.js │ ├── database.json │ ├── devops │ └── provisioning │ │ ├── group_vars │ │ ├── prod │ │ ├── staging │ │ └── vagrant │ │ ├── hosts │ │ ├── prod │ │ ├── staging │ │ └── vagrant │ │ ├── playbook.yml │ │ ├── roles │ │ ├── any-nodejs │ │ │ ├── .travis.yml │ │ │ ├── README.md │ │ │ ├── defaults │ │ │ │ └── main.yml │ │ │ ├── meta │ │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ │ ├── main.yml │ │ │ │ ├── setup-Debian.yml │ │ │ │ └── setup-RedHat.yml │ │ │ ├── templates │ │ │ │ └── npm.sh.j2 │ │ │ └── tests │ │ │ │ └── test.yml │ │ ├── create-www-data-user │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── fubarhouse.yarn │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── defaults │ │ │ │ └── main.yml │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ ├── meta │ │ │ │ ├── .galaxy_install_info │ │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ │ ├── main.yml │ │ │ │ ├── packages.yml │ │ │ │ ├── yarn-Debian.yml │ │ │ │ ├── yarn-RedHat.yml │ │ │ │ └── yarn.yml │ │ │ └── tests │ │ │ │ ├── inventory │ │ │ │ └── test.yml │ │ ├── ubuntu-apt │ │ │ ├── defaults │ │ │ │ └── main.yml │ │ │ └── tasks │ │ │ │ ├── dependencies.yml │ │ │ │ ├── install.yml │ │ │ │ ├── main.yml │ │ │ │ ├── remove.yml │ │ │ │ ├── repositories.yml │ │ │ │ ├── update.yml │ │ │ │ └── upgrade.yml │ │ ├── ubuntu-nodejs-nginx │ │ │ ├── defaults │ │ │ │ └── main.yml │ │ │ ├── files │ │ │ │ └── etc │ │ │ │ │ └── nginx │ │ │ │ │ └── mime.types │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ │ └── main.yml │ │ │ └── templates │ │ │ │ └── etc │ │ │ │ └── nginx │ │ │ │ └── conf.d │ │ │ │ └── conf │ │ └── ubuntu-postgresql │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── Vagrantfile │ │ │ ├── ansible.cfg │ │ │ ├── defaults │ │ │ └── main.yml │ │ │ ├── handlers │ │ │ └── main.yml │ │ │ ├── meta │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ ├── configure.yml │ │ │ ├── databases.yml │ │ │ ├── extensions.yml │ │ │ ├── extensions │ │ │ │ ├── contrib.yml │ │ │ │ ├── dev_headers.yml │ │ │ │ └── postgis.yml │ │ │ ├── install.yml │ │ │ ├── install_yum.yml │ │ │ ├── main.yml │ │ │ ├── monit.yml │ │ │ ├── users.yml │ │ │ └── users_privileges.yml │ │ │ ├── templates │ │ │ ├── HOWTO.postgresql.conf │ │ │ ├── etc_apt_preferences.d_apt_postgresql_org_pub_repos_apt.pref.j2 │ │ │ ├── etc_monit_conf.d_postgresql.j2 │ │ │ ├── etc_systemd_system_postgresql.service.d_custom.conf.j2 │ │ │ ├── pg_hba.conf.j2 │ │ │ ├── postgresql.conf-9.1.j2 │ │ │ ├── postgresql.conf-9.1.orig │ │ │ ├── postgresql.conf-9.2.j2 │ │ │ ├── postgresql.conf-9.2.orig │ │ │ ├── postgresql.conf-9.3.j2 │ │ │ ├── postgresql.conf-9.3.orig │ │ │ ├── postgresql.conf-9.4.j2 │ │ │ ├── postgresql.conf-9.4.orig │ │ │ ├── postgresql.conf-9.5.j2 │ │ │ ├── postgresql.conf-9.5.orig │ │ │ ├── postgresql.conf-9.6.j2 │ │ │ └── postgresql.conf-9.6.orig │ │ │ ├── tests │ │ │ ├── Dockerfile-centos6 │ │ │ ├── Dockerfile-ubuntu14.04 │ │ │ ├── idempotence_check.sh │ │ │ ├── playbook.yml │ │ │ └── vars.yml │ │ │ ├── vagrant-inventory │ │ │ └── vars │ │ │ ├── Debian.yml │ │ │ ├── RedHat.yml │ │ │ └── empty.yml │ │ └── vars │ │ └── main.yml │ ├── doc │ ├── database.md │ ├── deployment.md │ ├── installation-angular.md │ ├── installation-no-client.md │ ├── installation-react-redux.md │ ├── installation-react.md │ ├── provisioning.md │ └── tests.md │ ├── gitignore │ ├── migrations │ ├── 20161206103004-create-user.js │ └── sqls │ │ ├── 20161206103004-create-user-down.sql │ │ └── 20161206103004-create-user-up.sql │ ├── package.json │ ├── pm2.yml │ ├── server │ ├── .eslintrc │ ├── boot │ │ ├── 0-security.js │ │ ├── authentication.js │ │ └── create-admin.js │ ├── component-config.json │ ├── config.json │ ├── datasources.json │ ├── datasources.local.js │ ├── middleware.development.json │ ├── middleware.json │ ├── model-config.json │ ├── models │ │ ├── user.js │ │ └── user.json │ └── server.js │ ├── shipitfile.js │ ├── tests │ └── test.js │ └── yarn.lock ├── package.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | **/node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Thibaut Cheymol 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-loopback-ansible 2 | 3 | This generator scripts everything you need to start a JS fullstack project: 4 | - [Loopback](http://loopback.io/) (nodejs framework) server 5 | - React, React-Redux or Angular4 client from awesome boilerplates 6 | - Ansible provisioning with node 8, nginx, www-data user, postgresql database 7 | - Vagrant configuration 8 | - Shipit deployment script 9 | 10 | ## Prerequisites 11 | 12 | You need to install: 13 | 14 | + [Yeoman](http://yeoman.io/): `npm install -g yo` 15 | + [VirtualBox](https://www.virtualbox.org/wiki/Downloads) 16 | + [Vagrant](https://www.vagrantup.com/downloads.html) 17 | + Node.js (> 6.x) + Npm (install it with [nvm](https://github.com/creationix/nvm)): `curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash` 18 | + [Ansible (version 2)](http://docs.ansible.com/ansible/intro_installation.html) 19 | + [Yarn](https://yarnpkg.com/en/docs/install) 20 | 21 | ## Installation 22 | 23 | 24 | ### Choose a starter-kit according to your needs 25 | 26 | This generator will ask you to choose between 3 starter-kits (or no client at all). 27 | 28 | - **React** from [Create React App starter-kit](https://github.com/facebookincubator/create-react-app): 29 | - A react starter-kit which generates a simple react app! 30 | - For who ? 31 | - Those who want to start with a minimalist react application and want to leverage the power of react-scripts to have their webpack config always up-to-date. 32 | 33 | 34 | - **React-Redux** from [React Boilerplate](https://github.com/react-boilerplate/react-boilerplate): 35 | - A React-Redux starter-kit! 36 | - For who ? 37 | - Those who want to start with redux out of the box. 38 | 39 | 40 | - **Angular4** from [Angular starter](https://github.com/AngularClass/angular-starter): 41 | - An Angular 4 starter-kit! 42 | - For who ? 43 | - Those who wants Angular! 44 | 45 | 46 | ### Install the generator 47 | 48 | - Install the package: 49 | ``` 50 | npm install -g generator-loopback-ansible 51 | ``` 52 | 53 | ## Usage 54 | 55 | - Create a directory: 56 | ``` 57 | mkdir myAwesomeProject && cd myAwesomeProject 58 | ``` 59 | 60 | - Run the generator in the created directory: 61 | ``` 62 | yo loopback-ansible 63 | ``` 64 | 65 | Then follow the generated documentation installation steps. 66 | 67 | ## What's next ? 68 | 69 | - Vault ansible files to be able to commit them. 70 | - Add a choice between Loopback, Express and Sailjs for the backend 71 | 72 | ## Troubleshooting 73 | 74 | At the moment, the `xubuntu` distrib doesn't support the vagrant `synced_folder` parameter with `xenial` OS, please choose `trusty` option if you are in that case 75 | 76 | ## Contributing to the generator 77 | 78 | This generator is open-sourced and can be improved in many ways, feel free to contribute [here](https://github.com/tcheymol/generator-loopback-ansible) ! 79 | 80 | - Fork the repository. 81 | - Clone the forked repository. 82 | - Run `npm link` 83 | -------------------------------------------------------------------------------- /generators/app/index.js: -------------------------------------------------------------------------------- 1 | const Generator = require('yeoman-generator'); 2 | 3 | class LoopbackGenerator extends Generator { 4 | prompting() { 5 | return this.prompt([ 6 | { 7 | type : 'input', 8 | name : 'appName', 9 | message : 'Your application name', 10 | }, 11 | { 12 | type : 'list', 13 | name : 'client', 14 | message : 'Choose your client', 15 | default : 'react-redux', 16 | choices : ['react-redux', 'react', 'angular4', 'none'] 17 | }, 18 | { 19 | type : 'input', 20 | name : 'stagingDatabasePassword', 21 | message : 'Your staging database password', 22 | default : 'pleaseChangeMe', 23 | }, 24 | { 25 | type : 'input', 26 | name : 'prodDatabasePassword', 27 | message : 'Your production database password', 28 | default : 'pleaseChangeMe', 29 | }, 30 | { 31 | type : 'input', 32 | name : 'repositoryUrl', 33 | message : 'Your git repository URL (used for deployment script)', 34 | default : '', 35 | }, 36 | { 37 | type : 'input', 38 | name : 'stagingIpAddress', 39 | message : 'Your staging IP address', 40 | default : '', 41 | }, 42 | { 43 | type : 'input', 44 | name : 'prodIpAddress', 45 | message : '[Optionnal] Your production IP address', 46 | default : '', 47 | }, 48 | { 49 | type : 'list', 50 | name : 'vagrantOs', 51 | message : 'Choose your Vagrant OS', 52 | default : 'xenial', 53 | choices : ['xenial', 'trusty'] 54 | } 55 | ]).then(answers => { 56 | this.answers = answers; 57 | this.answers.clientPublicDirectory = 'client/build'; 58 | 59 | if (this.answers.client === 'react-redux') { 60 | this.answers.installationFile = 'doc/installation-react-redux.md'; 61 | } 62 | 63 | if (this.answers.client === 'react') { 64 | this.answers.installationFile = 'doc/installation-react.md'; 65 | } 66 | 67 | if (this.answers.client === 'angular4') { 68 | this.answers.installationFile = 'doc/installation-angular.md'; 69 | this.answers.clientPublicDirectory = 'client/dist'; 70 | } 71 | 72 | if (this.answers.client === 'none') { 73 | this.answers.installationFile = 'installation-no-client.md'; 74 | } 75 | }); 76 | } 77 | 78 | _addReactReduxBoilerplate() { 79 | this.log('Cloning react-boilerplate'); 80 | this.spawnCommandSync('git', [ 81 | 'clone', 82 | '--branch', 83 | 'v3.4.0', 84 | 'https://github.com/react-boilerplate/react-boilerplate.git', 85 | 'client' 86 | ]); 87 | 88 | this.spawnCommandSync('rm', ['client/internals/webpack/webpack.base.babel.js']); 89 | this.spawnCommandSync('rm', ['client/appveyor.yml']); 90 | this.spawnCommandSync('rm', ['client/LICENSE.md']); 91 | this.spawnCommandSync('rm', ['client/Changelog.md']); 92 | this.spawnCommandSync('rm', ['client/CODE_OF_CONDUCT.md']); 93 | this.spawnCommandSync('rm', ['client/.lgtm']); 94 | this.spawnCommandSync('rm', ['client/MAINTAINERS']); 95 | this.spawnCommandSync('rm', ['-rf', 'client/.git']); 96 | this.spawnCommandSync('rm', ['-rf', 'client/.github']); 97 | 98 | return Promise.all([ 99 | 'client/internals/webpack/webpack.base.babel.js', 100 | ].map(file => { 101 | return this.fs.copyTpl( 102 | this.templatePath(file), 103 | this.destinationPath(file), 104 | this.answers 105 | ); 106 | })); 107 | } 108 | 109 | _addReactBoilerplate() { 110 | this.spawnCommandSync('npm', ['install', '-g', 'create-react-app']); 111 | this.log('Using create-react-app'); 112 | this.spawnCommandSync('create-react-app', ['client']); 113 | } 114 | 115 | _addAngularBoilerplate() { 116 | this.log('Cloning angular starter'); 117 | this.spawnCommandSync('git', [ 118 | 'clone', 119 | '--branch', 120 | 'v5.2.0', 121 | 'https://github.com/AngularClass/angular-starter.git', 122 | 'client' 123 | ]); 124 | 125 | this.log('Remove client git history'); 126 | this.spawnCommandSync('rm', ['-rf', 'client/.git']); 127 | } 128 | 129 | _addClient() { 130 | if (this.answers.client === 'none') { 131 | return; 132 | } 133 | 134 | if (this.answers.client === 'react-redux') { 135 | this._addReactReduxBoilerplate() 136 | } 137 | 138 | if (this.answers.client === 'react') { 139 | this._addReactBoilerplate() 140 | } 141 | 142 | if (this.answers.client === 'angular4') { 143 | this._addAngularBoilerplate() 144 | } 145 | } 146 | 147 | _addConfigurationTemplates () { 148 | const files = [ 149 | 'gitignore', 150 | '.yo-rc.json', 151 | '.editorconfig', 152 | '.eslintignore', 153 | 'ansible.cfg', 154 | 'database.json', 155 | 'package.json', 156 | 'yarn.lock', 157 | 'pm2.yml', 158 | 'README.md', 159 | 'doc/deployment.md', 160 | 'doc/provisioning.md', 161 | 'doc/tests.md', 162 | 'shipitfile.js', 163 | 'Vagrantfile', 164 | this.answers.installationFile 165 | ]; 166 | 167 | return Promise.all(files.map(file => { 168 | return this.fs.copyTpl( 169 | this.templatePath(file), 170 | this.destinationPath(file), 171 | this.answers 172 | ); 173 | })); 174 | } 175 | 176 | _addMigrationsTemplates () { 177 | return Promise.all([ 178 | 'migrations/20161206103004-create-user.js', 179 | 'migrations/sqls/20161206103004-create-user-up.sql', 180 | 'migrations/sqls/20161206103004-create-user-down.sql', 181 | ].map(file => { 182 | return this.fs.copyTpl( 183 | this.templatePath(file), 184 | this.destinationPath(file), 185 | this.answers 186 | ); 187 | })); 188 | } 189 | 190 | _addProvisioningTemplates () { 191 | this.fs.copy( 192 | this.templatePath('devops/provisioning/roles'), 193 | this.destinationPath('devops/provisioning/roles'), 194 | this.answers 195 | ); 196 | 197 | return Promise.all([ 198 | 'devops/provisioning/group_vars/prod', 199 | 'devops/provisioning/group_vars/staging', 200 | 'devops/provisioning/group_vars/vagrant', 201 | 'devops/provisioning/hosts/prod', 202 | 'devops/provisioning/hosts/staging', 203 | 'devops/provisioning/hosts/vagrant', 204 | 'devops/provisioning/vars/main.yml', 205 | 'devops/provisioning/playbook.yml', 206 | ].map(file => { 207 | return this.fs.copyTpl( 208 | this.templatePath(file), 209 | this.destinationPath(file), 210 | this.answers 211 | ); 212 | })); 213 | } 214 | 215 | _addServerTemplates () { 216 | return Promise.all([ 217 | 'server/.eslintrc', 218 | 'server/component-config.json', 219 | 'server/config.json', 220 | 'server/datasources.json', 221 | 'server/datasources.local.js', 222 | 'server/middleware.development.json', 223 | 'server/middleware.json', 224 | 'server/model-config.json', 225 | 'server/server.js', 226 | 'server/models/user.js', 227 | 'server/models/user.json', 228 | 'server/boot/authentication.js', 229 | 'server/boot/create-admin.js', 230 | 'tests/test.js', 231 | ].map(file => { 232 | return this.fs.copyTpl( 233 | this.templatePath(file), 234 | this.destinationPath(file), 235 | this.answers 236 | ); 237 | })); 238 | } 239 | 240 | installProject() { 241 | return this._addConfigurationTemplates() 242 | .then(() => this._addServerTemplates()) 243 | .then(() => this._addProvisioningTemplates()) 244 | .then(() => this._addMigrationsTemplates()) 245 | .then(() => this._addClient()) 246 | } 247 | 248 | end() { 249 | // .gitgnore is not included by npm publish https://github.com/npm/npm/issues/3763 250 | // It can be bypassed by renaming a gitgnore file to .gitignore 251 | this.spawnCommandSync('mv', ['./gitignore', './.gitignore']); 252 | if (this.answers.client === 'react-redux') { 253 | this.destinationRoot('client'); 254 | this.spawnCommandSync('npm', ['uninstall', 'image-webpack-loader', '--save-dev']); 255 | this.spawnCommandSync('npm', ['run', 'setup']); 256 | this.spawnCommandSync('rm', ['-rf', '.git']); 257 | }; 258 | 259 | this.log('Everything went well, enjoy your new app!') 260 | } 261 | }; 262 | 263 | module.exports = LoopbackGenerator; 264 | -------------------------------------------------------------------------------- /generators/app/templates/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # http://editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | indent_style = space 9 | indent_size = 2 10 | end_of_line = lf 11 | charset = utf-8 12 | trim_trailing_whitespace = true 13 | insert_final_newline = true 14 | -------------------------------------------------------------------------------- /generators/app/templates/.eslintignore: -------------------------------------------------------------------------------- 1 | /doc 2 | /node_modules 3 | /provisioning 4 | -------------------------------------------------------------------------------- /generators/app/templates/.npmignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tcheymol/generator-loopback-ansible/4375423f0e70aaf61f454a1c284facff0a4ef593/generators/app/templates/.npmignore -------------------------------------------------------------------------------- /generators/app/templates/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-loopback": {} 3 | } -------------------------------------------------------------------------------- /generators/app/templates/README.md: -------------------------------------------------------------------------------- 1 | See the docs: 2 | 3 | - [Installation](<%= installationFile %>) 4 | - [Deployment](doc/deployment.md) 5 | - [Database](doc/database.md) 6 | - [Server installation](doc/provisioning.md) 7 | - [Tests](doc/tests.md) 8 | -------------------------------------------------------------------------------- /generators/app/templates/Vagrantfile: -------------------------------------------------------------------------------- 1 | $HOSTNAME = "<%= appName %>.dev" 2 | $BOX = "ubuntu/<%= vagrantOs %>64" 3 | $IP = "10.0.0.10" 4 | $MEMORY = ENV.has_key?('VM_MEMORY') ? ENV['VM_MEMORY'] : "1024" 5 | $CPUS = ENV.has_key?('VM_CPUS') ? ENV['VM_CPUS'] : "1" 6 | $EXEC_CAP = ENV.has_key?('VM_EXEC_CAP') ? ENV['VM_EXEC_CAP'] : "100" 7 | 8 | Vagrant.configure("2") do |config| 9 | config.vm.hostname = $HOSTNAME 10 | config.vm.box = $BOX 11 | config.vm.network :private_network, ip: $IP 12 | config.ssh.forward_agent = true 13 | config.vm.synced_folder ".", "/var/www/<%= appName %>/current", type: "nfs" 14 | config.vm.network "forwarded_port", guest: 80, host: 8080 15 | 16 | config.vm.provider "virtualbox" do |v| 17 | v.name = "<%= appName %>" 18 | v.customize ["modifyvm", :id, "--cpuexecutioncap", $EXEC_CAP] 19 | v.customize ["modifyvm", :id, "--memory", $MEMORY] 20 | v.customize ["modifyvm", :id, "--cpus", $CPUS] 21 | end 22 | 23 | config.vm.provision "ansible" do |ansible| 24 | ansible.playbook = "devops/provisioning/playbook.yml" 25 | ansible.inventory_path = "devops/provisioning/hosts/vagrant" 26 | ansible.limit = 'all' 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /generators/app/templates/ansible.cfg: -------------------------------------------------------------------------------- 1 | 2 | [defaults] 3 | roles_path = devops/provisioning/roles/ 4 | -------------------------------------------------------------------------------- /generators/app/templates/client/internals/webpack/webpack.base.babel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * COMMON WEBPACK CONFIGURATION 3 | */ 4 | 5 | const path = require('path'); 6 | const webpack = require('webpack'); 7 | 8 | module.exports = (options) => ({ 9 | entry: options.entry, 10 | output: Object.assign({ // Compile into js/build.js 11 | path: path.resolve(process.cwd(), 'build'), 12 | publicPath: '/', 13 | }, options.output), // Merge with env dependent settings 14 | module: { 15 | loaders: [{ 16 | test: /\.js$/, // Transform all .js files required somewhere with Babel 17 | loader: 'babel-loader', 18 | exclude: /node_modules/, 19 | query: options.babelQuery, 20 | }, { 21 | // Do not transform vendor's CSS with CSS-modules 22 | // The point is that they remain in global scope. 23 | // Since we require these CSS files in our JS or CSS files, 24 | // they will be a part of our compilation either way. 25 | // So, no need for ExtractTextPlugin here. 26 | test: /\.css$/, 27 | include: /node_modules/, 28 | loaders: ['style-loader', 'css-loader'], 29 | }, { 30 | test: /\.(eot|svg|ttf|woff|woff2)$/, 31 | loader: 'file-loader', 32 | }, { 33 | test: /\.(jpe?g|png|gif|svg)$/i, 34 | use: [ 35 | 'url-loader?limit=10000', 36 | ], 37 | }, { 38 | test: /\.html$/, 39 | loader: 'html-loader', 40 | }, { 41 | test: /\.json$/, 42 | loader: 'json-loader', 43 | }, { 44 | test: /\.(mp4|webm)$/, 45 | loader: 'url-loader', 46 | query: { 47 | limit: 10000, 48 | }, 49 | }], 50 | }, 51 | plugins: options.plugins.concat([ 52 | new webpack.ProvidePlugin({ 53 | // make fetch available 54 | fetch: 'exports-loader?self.fetch!whatwg-fetch', 55 | }), 56 | 57 | // Always expose NODE_ENV to webpack, in order to use `process.env.NODE_ENV` 58 | // inside your code for any environment checks; UglifyJS will automatically 59 | // drop any unreachable code. 60 | new webpack.DefinePlugin({ 61 | 'process.env': { 62 | NODE_ENV: JSON.stringify(process.env.NODE_ENV), 63 | }, 64 | }), 65 | new webpack.NamedModulesPlugin(), 66 | ]), 67 | resolve: { 68 | modules: ['app', 'node_modules'], 69 | extensions: [ 70 | '.js', 71 | '.jsx', 72 | '.react.js', 73 | ], 74 | mainFields: [ 75 | 'browser', 76 | 'jsnext:main', 77 | 'main', 78 | ], 79 | }, 80 | devtool: options.devtool, 81 | target: 'web', // Make web variables accessible to webpack, e.g. window 82 | performance: options.performance || {}, 83 | }); 84 | -------------------------------------------------------------------------------- /generators/app/templates/database.json: -------------------------------------------------------------------------------- 1 | { 2 | "dev": { 3 | "driver": "postgres", 4 | "database": "<%= appName %>", 5 | "user": "<%= appName %>", 6 | "password": "<%= appName %>", 7 | "host": "localhost", 8 | "port": 5432 9 | }, 10 | "production": { 11 | "driver": "postgres", 12 | "database": "<%= appName %>", 13 | "user": "<%= appName %>", 14 | "password": "<%= prodDatabasePassword %>", 15 | "host": "localhost", 16 | "port": 5432 17 | }, 18 | "sql-file" : true 19 | } 20 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/group_vars/prod: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # List of databases to be created 4 | postgresql_databases: 5 | - name: <%= appName %> 6 | hstore: yes 7 | uuid_ossp: yes 8 | 9 | # List of users to be created 10 | postgresql_users: 11 | - name: <%= appName %> 12 | pass: <%= prodDatabasePassword %> 13 | 14 | postgresql_user_privileges: 15 | - name: <%= appName %> 16 | db: <%= appName %> 17 | priv: "ALL" 18 | role_attr_flags: "SUPERUSER" 19 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/group_vars/staging: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # List of databases to be created 4 | postgresql_databases: 5 | - name: <%= appName %> 6 | hstore: yes 7 | uuid_ossp: yes 8 | 9 | # List of users to be created 10 | postgresql_users: 11 | - name: <%= appName %> 12 | pass: <%= stagingDatabasePassword %> 13 | 14 | postgresql_user_privileges: 15 | - name: <%= appName %> 16 | db: <%= appName %> 17 | priv: "ALL" 18 | role_attr_flags: "SUPERUSER" 19 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/group_vars/vagrant: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # List of databases to be created 4 | postgresql_databases: 5 | - name: <%= appName %> 6 | hstore: yes 7 | uuid_ossp: yes 8 | 9 | # List of users to be created 10 | postgresql_users: 11 | - name: <%= appName %> 12 | pass: <%= appName %> 13 | 14 | postgresql_user_privileges: 15 | - name: <%= appName %> 16 | db: <%= appName %> 17 | priv: "ALL" 18 | role_attr_flags: "SUPERUSER" 19 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/hosts/prod: -------------------------------------------------------------------------------- 1 | [prod] 2 | <%= prodIpAddress %> ansible_ssh_user=root 3 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/hosts/staging: -------------------------------------------------------------------------------- 1 | [staging] 2 | <%= stagingIpAddress %> ansible_ssh_user=ubuntu 3 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/hosts/vagrant: -------------------------------------------------------------------------------- 1 | [vagrant] 2 | 10.0.0.10 ansible_ssh_user=ubuntu 3 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # It will install python2 if missing (but checks first so no expensive repeated apt updates) 3 | 4 | - hosts: all 5 | gather_facts: False 6 | become: true 7 | tasks: 8 | - name: install python 2 9 | raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) 10 | 11 | 12 | - name: Provisioning <%= appName %> 13 | hosts: all 14 | become: true 15 | gather_facts: true 16 | pre_tasks: 17 | - name: 'install python2' 18 | raw: sudo apt-get -y install python-simplejson 19 | vars_files: 20 | - vars/main.yml 21 | 22 | roles: 23 | - ubuntu-apt 24 | - create-www-data-user 25 | - any-nodejs 26 | - fubarhouse.yarn 27 | - ubuntu-nodejs-nginx 28 | - ubuntu-postgresql 29 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | services: docker 3 | 4 | env: 5 | - distro: centos7 6 | init: /usr/lib/systemd/systemd 7 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 8 | - distro: centos6 9 | init: /sbin/init 10 | run_opts: "" 11 | - distro: ubuntu1604 12 | init: /lib/systemd/systemd 13 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 14 | - distro: ubuntu1404 15 | init: /sbin/init 16 | run_opts: "" 17 | - distro: ubuntu1204 18 | init: /sbin/init 19 | run_opts: "" 20 | 21 | before_install: 22 | # Pull container. 23 | - 'docker pull geerlingguy/docker-${distro}-ansible:latest' 24 | 25 | script: 26 | - container_id=$(mktemp) 27 | # Run container in detached state. 28 | - 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"' 29 | 30 | # Install dependencies. 31 | - 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml' 32 | 33 | # Ansible syntax check. 34 | - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check' 35 | 36 | # Test role. 37 | - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' 38 | 39 | # Test role idempotence. 40 | - idempotence=$(mktemp) 41 | - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence} 42 | - > 43 | tail ${idempotence} 44 | | grep -q 'changed=0.*failed=0' 45 | && (echo 'Idempotence test: pass' && exit 0) 46 | || (echo 'Idempotence test: fail' && exit 1) 47 | 48 | # Ensure Node.js is installed. 49 | - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm which node' 50 | - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm node -v' 51 | 52 | # Ensure npm packages are installed globally. 53 | - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm bash --login -c "npm list -g --depth=0 jslint"' 54 | - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm bash --login -c "npm list -g --depth=0 node-sass"' 55 | - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm bash --login -c "npm list -g --depth=0 yo"' 56 | 57 | notifications: 58 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ 59 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: Node.js 2 | 3 | [![Build Status](https://travis-ci.org/geerlingguy/ansible-role-nodejs.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-nodejs) 4 | 5 | Installs Node.js on RHEL/CentOS or Debian/Ubuntu. 6 | 7 | ## Requirements 8 | 9 | Requires the EPEL repository on RedHat/CentOS (you can install it by simply adding the `geerlingguy.repo-epel` role to your playbook). 10 | 11 | ## Role Variables 12 | 13 | Available variables are listed below, along with default values (see `defaults/main.yml`): 14 | 15 | nodejs_version: "0.12" 16 | 17 | The Node.js version to install. "0.12" is the default and works on all supported OSes. Other versions such as "0.10", "4.x", "5.x", and "6.x" should work on the latest versions of Debian/Ubuntu and RHEL/CentOS. 18 | 19 | nodejs_install_npm_user: "{{ ansible_ssh_user }}" 20 | 21 | The user for whom the npm packages will be installed can be set here, this defaults to ansible_user 22 | 23 | npm_config_prefix: "~/.npm-global" 24 | 25 | The global installation directory. This should be writeable by the nodejs_install_npm_user. 26 | 27 | npm_config_unsafe_perm: "false" 28 | 29 | Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail. 30 | 31 | nodejs_npm_global_packages: [] 32 | 33 | Add a list of npm packages with a `name` and (optional) `version` to be installed globally. For example: 34 | 35 | nodejs_npm_global_packages: 36 | # Install a specific version of a package. 37 | - name: jslint 38 | version: 0.9.3 39 | # Install the latest stable release of a package. 40 | - name: node-sass 41 | 42 | ## Dependencies 43 | 44 | None. 45 | 46 | ## Example Playbook 47 | 48 | - hosts: utility 49 | vars_files: 50 | - vars/main.yml 51 | roles: 52 | - geerlingguy.nodejs 53 | 54 | *Inside `vars/main.yml`*: 55 | 56 | nodejs_npm_global_packages: 57 | - name: jslint 58 | - name: node-sass 59 | 60 | ## License 61 | 62 | MIT / BSD 63 | 64 | ## Author Information 65 | 66 | This role was created in 2014 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). 67 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set the version of Node.js to install ("0.10", "0.12", "4.x", "5.x", "6.x"). 3 | # Version numbers from Nodesource: https://github.com/nodesource/distributions 4 | nodejs_version: "8.x" 5 | 6 | # The user for whom the npm packages will be installed. 7 | # nodejs_install_npm_user: username 8 | 9 | # The directory for global installations. 10 | npm_config_prefix: "/usr/local/lib/npm" 11 | 12 | # Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail. 13 | npm_config_unsafe_perm: "false" 14 | 15 | # Define a list of global packages to be installed with NPM. 16 | nodejs_npm_global_packages: [] 17 | # # Install a specific version of a package. 18 | # - name: jslint 19 | # version: 0.9.3 20 | # # Install the latest stable release of a package. 21 | # - name: node-sass 22 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: [] 3 | 4 | galaxy_info: 5 | author: geerlingguy 6 | description: Node.js installation for Linux 7 | company: "Midwestern Mac, LLC" 8 | license: "license (BSD, MIT)" 9 | min_ansible_version: 1.9 10 | platforms: 11 | - name: EL 12 | versions: 13 | - 6 14 | - 7 15 | - name: Debian 16 | versions: 17 | - all 18 | - name: Ubuntu 19 | versions: 20 | - precise 21 | - raring 22 | - saucy 23 | - trusty 24 | - xenial 25 | galaxy_tags: 26 | - development 27 | - web 28 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include: setup-RedHat.yml 3 | when: ansible_os_family == 'RedHat' 4 | 5 | - include: setup-Debian.yml 6 | when: ansible_os_family == 'Debian' 7 | 8 | - name: Define nodejs_install_npm_user 9 | set_fact: 10 | nodejs_install_npm_user: ubuntu 11 | when: nodejs_install_npm_user is not defined 12 | 13 | - name: Create npm global directory 14 | file: 15 | path: "{{ npm_config_prefix }}" 16 | owner: "{{ nodejs_install_npm_user }}" 17 | group: "{{ nodejs_install_npm_user }}" 18 | state: directory 19 | 20 | - name: Add npm_config_prefix bin directory to global $PATH. 21 | template: 22 | src: npm.sh.j2 23 | dest: /etc/profile.d/npm.sh 24 | mode: 0644 25 | 26 | # TODO: Remove this task after Ansible 2.x npm module bug is fixed. See: 27 | # https://github.com/ansible/ansible-modules-extras/issues/1375 28 | - name: Ensure npm global packages are installed. 29 | npm: 30 | name: "{{ item.name }}" 31 | version: "{{ item.version | default('latest') }}" 32 | global: yes 33 | state: present 34 | environment: 35 | NPM_CONFIG_PREFIX: "{{ npm_config_prefix }}" 36 | NODE_PATH: "{{ npm_config_prefix }}/lib/node_modules" 37 | NPM_CONFIG_UNSAFE_PERM: "{{ npm_config_unsafe_perm }}" 38 | with_items: "{{ nodejs_npm_global_packages }}" 39 | 40 | - name: Ensure npm global packages are at the latest release. 41 | npm: 42 | name: "{{ item.name }}" 43 | version: "{{ item.version | default('latest') }}" 44 | global: yes 45 | state: latest 46 | environment: 47 | NPM_CONFIG_PREFIX: "{{ npm_config_prefix }}" 48 | NODE_PATH: "{{ npm_config_prefix }}/lib/node_modules" 49 | NPM_CONFIG_UNSAFE_PERM: "{{ npm_config_unsafe_perm }}" 50 | with_items: "{{ nodejs_npm_global_packages }}" 51 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/tasks/setup-Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure apt-transport-https is installed. 3 | apt: name=apt-transport-https state=present 4 | 5 | - name: Add Nodesource apt key. 6 | apt_key: 7 | url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280 8 | id: "68576280" 9 | state: present 10 | 11 | - name: Add NodeSource repositories for Node.js. 12 | apt_repository: 13 | repo: "{{ item }}" 14 | state: present 15 | with_items: 16 | - "deb https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main" 17 | - "deb-src https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main" 18 | register: node_repo 19 | 20 | - name: Update apt cache if repo was added. 21 | apt: update_cache=yes 22 | when: node_repo.changed 23 | 24 | - name: Ensure Node.js and npm are installed. 25 | apt: "name=nodejs={{ nodejs_version|regex_replace('x', '') }}* state=present" 26 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/tasks/setup-RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Set up the Nodesource RPM directory for Node.js > 0.10. 3 | set_fact: 4 | nodejs_rhel_rpm_dir: "pub_{{ nodejs_version }}" 5 | when: nodejs_version != '0.10' 6 | 7 | - name: Set up the Nodesource RPM variable for Node.js == 0.10. 8 | set_fact: 9 | nodejs_rhel_rpm_dir: "pub" 10 | when: nodejs_version == '0.10' 11 | 12 | - name: Import Nodesource RPM key (CentOS < 7). 13 | rpm_key: 14 | key: http://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL 15 | state: present 16 | when: ansible_distribution_major_version|int < 7 17 | 18 | - name: Import Nodesource RPM key (CentOS 7+).. 19 | rpm_key: 20 | key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL 21 | state: present 22 | when: ansible_distribution_major_version|int >= 7 23 | 24 | - name: Add Nodesource repositories for Node.js (CentOS < 7). 25 | yum: 26 | name: "http://rpm.nodesource.com/{{ nodejs_rhel_rpm_dir }}/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm" 27 | state: present 28 | when: ansible_distribution_major_version|int < 7 29 | 30 | - name: Add Nodesource repositories for Node.js (CentOS 7+). 31 | yum: 32 | name: "https://rpm.nodesource.com/{{ nodejs_rhel_rpm_dir }}/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm" 33 | state: present 34 | when: ansible_distribution_major_version|int >= 7 35 | 36 | - name: Ensure Node.js and npm are installed. 37 | yum: "name=nodejs-{{ nodejs_version[0] }}.* state=present enablerepo='epel,nodesource'" 38 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/templates/npm.sh.j2: -------------------------------------------------------------------------------- 1 | export PATH={{ npm_config_prefix }}/bin:$PATH 2 | export NPM_CONFIG_PREFIX={{ npm_config_prefix }} 3 | export NODE_PATH=$NODE_PATH:{{ npm_config_prefix }}/lib/node_modules 4 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/any-nodejs/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | 4 | vars: 5 | nodejs_version: "5.x" 6 | nodejs_install_npm_user: root 7 | npm_config_prefix: /root/.npm-global 8 | npm_config_unsafe_perm: "true" 9 | nodejs_npm_global_packages: 10 | - name: node-sass 11 | - name: jslint 12 | version: 0.9.6 13 | - name: yo 14 | 15 | pre_tasks: 16 | - name: Update apt cache. 17 | apt: update_cache=yes cache_valid_time=600 18 | when: ansible_os_family == 'Debian' 19 | 20 | roles: 21 | - role_under_test 22 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/create-www-data-user/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Creates www directory 4 | file: path=/var/www state=directory 5 | 6 | - name: update www-data shell 7 | user: name=www-data shell=/bin/bash home=/var/www 8 | 9 | - name: set correct permissions for www dir 10 | file: path=/var/www owner=www-data group=www-data mode=0700 state=directory 11 | 12 | - name: set correct permissions for ssh dir 13 | file: path=/var/www/.ssh owner=www-data group=www-data mode=0700 state=directory 14 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | services: docker 3 | 4 | env: 5 | - distro: centos6 6 | init: /sbin/init 7 | run_opts: "" 8 | - distro: centos7 9 | init: /usr/lib/systemd/systemd 10 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 11 | - distro: ubuntu1204 12 | init: /sbin/init 13 | run_opts: "" 14 | - distro: ubuntu1404 15 | init: /sbin/init 16 | run_opts: "" 17 | - distro: ubuntu1604 18 | init: /lib/systemd/systemd 19 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 20 | 21 | before_install: 22 | 23 | # Pull container. 24 | - 'docker pull geerlingguy/docker-${distro}-ansible:latest' 25 | 26 | script: 27 | 28 | - container_id=$(mktemp) 29 | # Run container in detached state. 30 | - 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"' 31 | 32 | # Install dependencies. 33 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-galaxy install geerlingguy.git' 34 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-galaxy install fubarhouse.curl' 35 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-galaxy install fubarhouse.nodejs' 36 | 37 | # Ansible syntax check. 38 | - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check -vvvv' 39 | 40 | # Test role. 41 | - 'docker exec "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' 42 | 43 | # Test role idempotence. 44 | # - idempotence=$(mktemp) 45 | # - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence} 46 | # - > 47 | # tail ${idempotence} 48 | # | grep -q 'changed=0.*failed=0' 49 | # && (echo 'Idempotence test: pass' && exit 0) 50 | # || (echo 'Idempotence test: fail' && exit 1) 51 | 52 | notifications: 53 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Karl Hepworth 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: Yarn 2 | 3 | [![Build Status](https://travis-ci.org/fubarhouse/ansible-role-yarn.svg?branch=master)](https://travis-ci.org/fubarhouse/ansible-role-yarn) 4 | [![Ansible Galaxy](https://img.shields.io/badge/galaxy-fubarhouse--yarn-13698.svg)](https://galaxy.ansible.com/fubarhouse/yarn) 5 | 6 | * Installs [Yarn](https://github.com/yarnpkg/yarn) for managing project dependencies. 7 | 8 | ## Requirements 9 | 10 | Yarn requires NodeJs v6+, and we recommend installing the role fubarhouse.nodejs prior to yarn. 11 | 12 | ## Role Variables 13 | 14 | To install global packages, use the `yarn_global_packages` array as described below. 15 | 16 | ****Note****: both `version` and `upgrade` are completely optional, but `name` is required. Set to `[]` to ignore this set of tasks. 17 | ```` 18 | yarn_global_packages: 19 | - name: gulp 20 | version: 3.9.0 21 | upgrade: yes 22 | ```` 23 | 24 | To run `yarn self-update `, set the `yarn_version` variable. 25 | ```` 26 | yarn_version: 0.18.1 27 | ```` 28 | 29 | To enable a clean install, set `yarn_clean_install` to true. 30 | ```` 31 | yarn_clean_install: false 32 | ```` 33 | 34 | To specify a custom installation path for binaries, use: 35 | 36 | ***Note***: binaries will be found at location `{{ yarn_global_path }}/bin` 37 | ```` 38 | yarn_global_path: /usr/local 39 | ```` 40 | 41 | 42 | To change which shell profiles are configured, change the following array to your needs: 43 | ```` 44 | yarn_shell_profiles: 45 | - .bash_profile 46 | ```` 47 | 48 | ## Dependencies 49 | 50 | None. 51 | 52 | ## Example Playbook 53 | ```` 54 | - hosts: localhost 55 | roles: 56 | - fubarhouse.nodejs # optional 57 | - fubarhouse.yarn 58 | ```` 59 | 60 | ## License 61 | 62 | MIT / BSD 63 | 64 | ## Author Information 65 | 66 | This role was created in 2016 by [Karl Hepworth](https://twitter.com/fubarhouse). -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | yarn_clean_install: false 4 | yarn_shell_profiles: 5 | - .bash_profile 6 | 7 | yarn_update: true 8 | yarn_global_path: /usr/local 9 | yarn_global_packages: [] 10 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for fubarhouse.nodejs 3 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/meta/.galaxy_install_info: -------------------------------------------------------------------------------- 1 | {install_date: 'Sun Jul 2 16:22:23 2017', version: '1.1'} 2 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: [] 3 | 4 | galaxy_info: 5 | author: fubarhouse 6 | description: Installs Yarn JS package manager. 7 | license: "license (BSD, MIT)" 8 | min_ansible_version: 2.1.0.0 9 | platforms: 10 | - name: Ubuntu 11 | versions: 12 | - precise 13 | - trusty 14 | - xenial 15 | - name: Debian 16 | versions: 17 | - all 18 | - name: EL 19 | versions: 20 | - 6 21 | - 7 22 | categories: 23 | - system 24 | - database 25 | - development 26 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Main tasks file for fubarhouse.nodejs 3 | 4 | - name: "Define user variable for ssh use" 5 | set_fact: 6 | fubarhouse_user: "{{ ansible_ssh_user }}" 7 | when: ansible_ssh_user is defined and fubarhouse_user is undefined 8 | 9 | - name: "Define user variable for non-ssh use" 10 | set_fact: 11 | fubarhouse_user: "{{ ansible_user_id }}" 12 | when: ansible_ssh_user is not defined and fubarhouse_user is undefined 13 | 14 | - name: "Include tasks for Yarn" 15 | include: yarn.yml 16 | 17 | - name: "Include tasks for Yarn packages" 18 | include: packages.yml -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/tasks/packages.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: "Yarn | Uninstall globally installed packages" 4 | become: yes 5 | become_user: "{{ fubarhouse_user }}" 6 | shell: "yarn global remove {{ item.name }}@{{ item.version | default('') }} --PREFIX={{ yarn_global_path }}" 7 | failed_when: false 8 | with_items: 9 | - "{{ yarn_global_packages }}" 10 | when: yarn_clean_install == true 11 | 12 | - name: "Yarn | Get list of globally installed packages" 13 | become: yes 14 | become_user: "{{ fubarhouse_user }}" 15 | shell: "yarn global ls" 16 | register: yarn_global_ls 17 | failed_when: false 18 | 19 | - name: "Yarn | Add globally installed packages" 20 | become: yes 21 | become_user: "{{ fubarhouse_user }}" 22 | shell: "yarn global add {{ item.name }}@{{ item.version | default('') }} --PREFIX={{ yarn_global_path }}" 23 | when: '"{{ item.name }}@{{ item.version | default() }}" not in "{{ yarn_global_ls.stdout }}"' 24 | with_items: 25 | - "{{ yarn_global_packages }}" 26 | 27 | - name: "Yarn | Upgrade installed packages" 28 | become: yes 29 | become_user: "{{ fubarhouse_user }}" 30 | shell: "yarn global upgrade {{ item.name }} --PREFIX={{ yarn_global_path }}" 31 | when: '"{{ item.name }}@{{ item.version | default() }}" in "{{ yarn_global_ls.stdout }}" and "{{ item.upgrade }}" is defined and item.upgrade == true' 32 | with_items: 33 | - "{{ yarn_global_packages }}" -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/tasks/yarn-Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: "Yarn | GPG" 4 | become: yes 5 | become_user: root 6 | apt_key: 7 | url: https://dl.yarnpkg.com/debian/pubkey.gpg 8 | state: present 9 | 10 | - name: "Yarn | Ensure Debian sources list file exists" 11 | become: yes 12 | become_user: root 13 | file: 14 | path: /etc/apt/sources.list.d/yarn.list 15 | owner: root 16 | mode: 0644 17 | state: touch 18 | 19 | - name: "Yarn | Ensure Debian package is in sources list" 20 | become: yes 21 | become_user: root 22 | lineinfile: 23 | dest: /etc/apt/sources.list.d/yarn.list 24 | regexp: 'deb http://dl.yarnpkg.com/debian/ stable main' 25 | line: 'deb http://dl.yarnpkg.com/debian/ stable main' 26 | state: present 27 | 28 | - name: "Yarn | Update APT cache" 29 | become: yes 30 | become_user: root 31 | apt: 32 | update_cache: yes -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/tasks/yarn-RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: "Yarn | Install RPM repository" 4 | become: yes 5 | become_user: root 6 | get_url: 7 | url: http://dl.yarnpkg.com/rpm/yarn.repo 8 | dest: /etc/yum.repos.d/yarn.repo 9 | owner: root 10 | mode: 0644 -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/tasks/yarn.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: "Yarn | De-configure shell profiles" 4 | become: yes 5 | become_user: "root" 6 | lineinfile: 7 | dest: "/home/{{ fubarhouse_user }}/{{ item }}" 8 | regexp: "PATH:{{ yarn_global_path }}/bin" 9 | line: 'export PATH="$PATH:{{ yarn_global_path }}/bin";' 10 | state: present 11 | failed_when: false 12 | with_items: 13 | - "{{ yarn_shell_profiles }}" 14 | when: yarn_clean_install == true 15 | 16 | - name: "Yarn | Uninstall" 17 | become: yes 18 | become_user: root 19 | package: 20 | name: yarn 21 | state: absent 22 | when: 'yarn_clean_install == true and "{{ ansible_os_family }}" == "Debian" or "{{ ansible_os_family }}" == "RedHat"' 23 | 24 | - name: "Yarn | Include OS-specific tasks" 25 | include: "yarn-{{ ansible_os_family }}.yml" 26 | when: '"{{ ansible_os_family }}" == "Debian" or "{{ ansible_os_family }}" == "RedHat"' 27 | 28 | - name: "Yarn | Install" 29 | become: yes 30 | become_user: root 31 | package: 32 | name: yarn 33 | state: latest 34 | when: '"{{ ansible_os_family }}" == "Debian" or "{{ ansible_os_family }}" == "RedHat"' 35 | 36 | - name: "Yarn | Configure shell profiles" 37 | become: yes 38 | become_user: "root" 39 | lineinfile: 40 | dest: "/home/{{ fubarhouse_user }}/{{ item }}" 41 | regexp: "PATH:{{ yarn_global_path }}/bin" 42 | line: 'export PATH="$PATH:{{ yarn_global_path }}/bin";' 43 | state: present 44 | failed_when: false 45 | with_items: 46 | - "{{ yarn_shell_profiles }}" 47 | 48 | - name: "Yarn | Ensure installed" 49 | shell: "which yarn" 50 | 51 | - name: "Yarn | Update as required" 52 | become: yes 53 | become_user: "{{ fubarhouse_user }}" 54 | shell: "yarn self-update {{ yarn_version | default() }}" 55 | when: 'yarn_update == true' 56 | failed_when: false -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost ansible_connection=local -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/fubarhouse.yarn/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | sudo: true 5 | vars: 6 | # fubarhouse_user: vagrant 7 | node_version: 6.0.0 8 | node_versions: 7.0.0 9 | node_packages: 10 | - yosay 11 | yarn_global_packages: 12 | - name: gulp 13 | version: 3.9.0 14 | upgrade: yes 15 | roles: 16 | - geerlingguy.git 17 | - fubarhouse.curl 18 | - fubarhouse.nodejs 19 | - role_under_test 20 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-apt/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | apt_cache_valid_time: 3600 4 | apt_update: true 5 | 6 | apt_upgrade: true 7 | apt_upgrade_type: safe # safe, full or dist 8 | 9 | apt_dependencies: 10 | - python-apt 11 | - aptitude 12 | 13 | # apt_specific_packages: 14 | # - python-apt 15 | # - unattended-upgrades 16 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-apt/tasks/dependencies.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install dependencies. 4 | apt: 5 | pkg="{{ item }}" 6 | state=present 7 | with_items: "{{ apt_dependencies|default([]) }}" 8 | when: apt_dependencies 9 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-apt/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install Common packages. 4 | apt: 5 | pkg="{{ item }}" 6 | state=present 7 | with_items: "{{ apt_common_packages|default([]) }}" 8 | when: apt_common_packages is defined 9 | 10 | - name: Install Specific packages. 11 | apt: 12 | pkg="{{ item }}" 13 | state=present 14 | with_items: "{{ apt_specific_packages|default([]) }}" 15 | when: apt_specific_packages is defined 16 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-apt/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include: update.yml 4 | - include: dependencies.yml 5 | - include: repositories.yml 6 | - include: upgrade.yml 7 | - include: install.yml 8 | - include: remove.yml -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-apt/tasks/remove.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Remove packages. 4 | apt: 5 | pkg="{{ item }}" 6 | state=absent 7 | with_items: "{{ apt_remove|default([]) }}" 8 | when: apt_remove -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-apt/tasks/repositories.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install repositories. 4 | apt_repository: 5 | repo="{{ item }}" 6 | update_cache=yes 7 | with_items: "{{ apt_install_repositories|default([]) }}" 8 | when: apt_install_repositories 9 | 10 | - name: Remove repositories. 11 | apt_repository: 12 | repo="{{ item }}" 13 | state=absent 14 | update_cache=yes 15 | with_items: "{{ apt_remove_repositories|default([]) }}" 16 | when: apt_remove_repositories -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-apt/tasks/update.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Update the apt cache. 4 | apt: 5 | cache_valid_time="{{ apt_cache_valid_time }}" 6 | update_cache=yes 7 | when: apt_update -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-apt/tasks/upgrade.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Upgrade all packages. 4 | apt: 5 | upgrade={{ apt_upgrade_type }} 6 | update_cache=yes 7 | when: apt_upgrade -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-nodejs-nginx/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | node_route: "/api" 3 | node_port: 3000 4 | index_default: "index.html" 5 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-nodejs-nginx/files/etc/nginx/mime.types: -------------------------------------------------------------------------------- 1 | types { 2 | text/html html htm shtml; 3 | text/css css; 4 | text/xml xml rss; 5 | text/cache-manifest appcache; 6 | image/gif gif; 7 | image/jpeg jpeg jpg; 8 | application/x-javascript js; 9 | application/atom+xml atom; 10 | 11 | text/mathml mml; 12 | text/plain txt; 13 | text/vnd.sun.j2me.app-descriptor jad; 14 | text/vnd.wap.wml wml; 15 | text/x-component htc; 16 | 17 | image/png png; 18 | image/tiff tif tiff; 19 | image/vnd.wap.wbmp wbmp; 20 | image/x-icon ico; 21 | image/x-jng jng; 22 | image/x-ms-bmp bmp; 23 | image/svg+xml svg svgz; 24 | 25 | application/java-archive jar war ear; 26 | application/json json; 27 | application/mac-binhex40 hqx; 28 | application/msword doc; 29 | application/pdf pdf; 30 | application/postscript ps eps ai; 31 | application/rtf rtf; 32 | application/vnd.ms-excel xls; 33 | application/vnd.ms-powerpoint ppt; 34 | application/vnd.wap.wmlc wmlc; 35 | application/vnd.google-earth.kml+xml kml; 36 | application/vnd.google-earth.kmz kmz; 37 | application/x-7z-compressed 7z; 38 | application/x-cocoa cco; 39 | application/x-java-archive-diff jardiff; 40 | application/x-java-jnlp-file jnlp; 41 | application/x-makeself run; 42 | application/x-perl pl pm; 43 | application/x-pilot prc pdb; 44 | application/x-rar-compressed rar; 45 | application/x-redhat-package-manager rpm; 46 | application/x-sea sea; 47 | application/x-shockwave-flash swf; 48 | application/x-stuffit sit; 49 | application/x-tcl tcl tk; 50 | application/x-x509-ca-cert der pem crt; 51 | application/x-xpinstall xpi; 52 | application/xhtml+xml xhtml; 53 | application/zip zip; 54 | 55 | application/octet-stream bin exe dll; 56 | application/octet-stream deb; 57 | application/octet-stream dmg; 58 | application/octet-stream eot; 59 | application/octet-stream iso img; 60 | application/octet-stream msi msp msm; 61 | application/ogg ogx; 62 | 63 | audio/midi mid midi kar; 64 | audio/mpeg mpga mpega mp2 mp3 m4a; 65 | audio/ogg oga ogg spx; 66 | audio/x-realaudio ra; 67 | audio/webm weba; 68 | 69 | video/3gpp 3gpp 3gp; 70 | video/mp4 mp4; 71 | video/mpeg mpeg mpg mpe; 72 | video/ogg ogv; 73 | video/quicktime mov; 74 | video/webm webm; 75 | video/x-flv flv; 76 | video/x-mng mng; 77 | video/x-ms-asf asx asf; 78 | video/x-ms-wmv wmv; 79 | video/x-msvideo avi; 80 | } 81 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-nodejs-nginx/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: restart-nginx 3 | service: name=nginx state=restarted 4 | 5 | - name: reload-nginx 6 | service: name=nginx state=reloaded 7 | 8 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-nodejs-nginx/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install 3 | apt: name=nginx state=latest update_cache=true cache_valid_time=3600 4 | 5 | - name: remove default site conf 6 | file: path=/etc/nginx/conf.d/default state=absent 7 | notify: reload-nginx 8 | 9 | - name: remove default site conf 10 | file: path=/etc/nginx/sites-available/default state=absent 11 | notify: reload-nginx 12 | 13 | - name: add server main listener 14 | template: src=etc/nginx/conf.d/conf dest=/etc/nginx/conf.d/main.conf 15 | notify: restart-nginx 16 | 17 | - name: nginx - update mime types 18 | copy: src=etc/nginx/mime.types dest=/etc/nginx/mime.types owner=root group=root mode=0644 19 | notify: restart-nginx 20 | 21 | - name: enable service 22 | service: name=nginx enabled=yes state=started 23 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-nodejs-nginx/templates/etc/nginx/conf.d/conf: -------------------------------------------------------------------------------- 1 | server { 2 | 3 | listen 80; 4 | server_name {{ inventory_hostname }}; 5 | 6 | ## 7 | # Redirect to the same URL with https:// 8 | ## 9 | # return 301 https://$server_name$request_uri; 10 | 11 | root /var/www/{{ project_name }}/current/{{ client_public_file_directory }}; 12 | index {{ index_default }}; 13 | 14 | gzip on; 15 | gzip_min_length 1000; 16 | gzip_comp_level 9; 17 | gzip_proxied any; 18 | gzip_types application/javascript application/x-javascript application/json text/css; 19 | 20 | location {{ node_route }} { 21 | proxy_pass http://127.0.0.1:{{ node_port }}; 22 | } 23 | 24 | location /explorer { 25 | proxy_pass http://127.0.0.1:{{ node_port }}; 26 | } 27 | } 28 | 29 | # To add HTTPS, uncomment what you need and add ssl_certificate 30 | # server { 31 | # listen 443 ssl; 32 | # server_name {{ inventory_hostname }}; 33 | 34 | # Configure the Certificate and Key you got from your CA (e.g. Lets Encrypt) 35 | # ssl_certificate /path/to/certificate.crt; 36 | # ssl_certificate_key /path/to/server.key; 37 | 38 | # ssl_session_timeout 1d; 39 | # ssl_session_cache shared:SSL:50m; 40 | # ssl_session_tickets off; 41 | 42 | # Only use TLS v1.2 as Transport Security Protocol 43 | # ssl_protocols TLSv1.2; 44 | 45 | # Only use ciphersuites that are considered modern and secure by Mozilla 46 | # ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; 47 | 48 | # Do not let attackers downgrade the ciphersuites in Client Hello 49 | # Always use server-side offered ciphersuites 50 | # ssl_prefer_server_ciphers on; 51 | 52 | # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months) 53 | # add_header Strict-Transport-Security max-age=15768000; 54 | 55 | # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits 56 | # Uncomment if you want to use your own Diffie-Hellman parameter, which can be generated with: openssl ecparam -genkey -out dhparam.pem -name prime256v1 57 | # See https://wiki.mozilla.org/Security/Server_Side_TLS#DHE_handshake_and_dhparam 58 | # ssl_dhparam /path/to/dhparam.pem; 59 | 60 | 61 | ## OCSP Configuration START 62 | # If you want to provide OCSP Stapling, you can uncomment the following lines 63 | # See https://www.digitalocean.com/community/tutorials/how-to-configure-ocsp-stapling-on-apache-and-nginx for more infos about OCSP and its use case 64 | # fetch OCSP records from URL in ssl_certificate and cache them 65 | 66 | # ssl_stapling on; 67 | # ssl_stapling_verify on; 68 | 69 | # verify chain of trust of OCSP response using Root CA and Intermediate certs (you will get this file from your CA) 70 | # ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates; 71 | 72 | ## OCSP Configuration END 73 | 74 | # root /var/www/{{ project_name }}/current/{{ client_public_file_directory }}; 75 | # index {{ index_default }}; 76 | 77 | # gzip on; 78 | # gzip_min_length 1000; 79 | # gzip_comp_level 9; 80 | # gzip_proxied any; 81 | # gzip_types application/javascript application/x-javascript application/json text/css; 82 | 83 | # location {{ node_route }} { 84 | # proxy_pass http://127.0.0.1:{{ node_port }}; 85 | # rewrite {{ node_route }}/(.*) /$1 break; 86 | # } 87 | 88 | # location ~* \.(css|txt|xml|js|gif|jpe?g|png|ico)$ { 89 | # expires 1y; 90 | # } 91 | #} 92 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .AppleDouble 3 | .LSOverride 4 | Icon 5 | ._* 6 | .Spotlight-V100 7 | .Trashes 8 | .vagrant 9 | test 10 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | language: python 4 | python: "2.7" 5 | services: 6 | - docker 7 | 8 | env: 9 | global: 10 | - ROLE_GLOBALS="postgresql_shared_buffers=32MB" 11 | matrix: 12 | - ROLE_OPTIONS="postgresql_version=9.1" ANSIBLE_VERSION="1.9.4" 13 | - ROLE_OPTIONS="postgresql_version=9.2" ANSIBLE_VERSION="1.9.4" 14 | - ROLE_OPTIONS="postgresql_version=9.3" ANSIBLE_VERSION="1.9.4" 15 | - ROLE_OPTIONS="postgresql_version=9.4" ANSIBLE_VERSION="1.9.4" 16 | - ROLE_OPTIONS="postgresql_version=9.5" ANSIBLE_VERSION="1.9.4" 17 | - ROLE_OPTIONS="postgresql_version=9.6" ANSIBLE_VERSION="1.9.4" 18 | - ROLE_OPTIONS="postgresql_version=9.1" ANSIBLE_VERSION="2.1.2.0" 19 | - ROLE_OPTIONS="postgresql_version=9.2" ANSIBLE_VERSION="2.1.2.0" 20 | - ROLE_OPTIONS="postgresql_version=9.3" ANSIBLE_VERSION="2.1.2.0" 21 | - ROLE_OPTIONS="postgresql_version=9.4" ANSIBLE_VERSION="2.1.2.0" 22 | - ROLE_OPTIONS="postgresql_version=9.5" ANSIBLE_VERSION="2.1.2.0" 23 | - ROLE_OPTIONS="postgresql_version=9.6" ANSIBLE_VERSION="2.1.2.0" 24 | 25 | before_install: 26 | # Remove the PostgreSQL installed by Travis 27 | - sudo apt-get purge pgdg-keyring '^postgresql.*' -y 28 | - sudo apt-get autoremove -y -qq 29 | - sudo rm -rf /etc/postgresql 30 | - sudo rm -rf /var/lib/postgresql 31 | - sudo rm -f /etc/apt/sources.list.d/pgdg-source.list 32 | # Install some dependencies 33 | - sudo apt-get update -qq -y 34 | - sudo apt-get install -qq -y python-apt python-pycurl locales 35 | - echo 'en_US.UTF-8 UTF-8' | sudo tee /var/lib/locales/supported.d/local 36 | 37 | install: 38 | - pip install ansible=="$ANSIBLE_VERSION" 39 | 40 | script: 41 | - echo localhost > inventory 42 | 43 | # Syntax check 44 | - ansible-playbook -i inventory tests/playbook.yml --syntax-check 45 | 46 | # Play test 47 | - ansible-playbook -i inventory tests/playbook.yml --connection=local --sudo -e "$ROLE_GLOBALS $ROLE_OPTIONS" 48 | 49 | # Idempotence test 50 | - ansible-playbook -i inventory tests/playbook.yml --connection=local --sudo -e "$ROLE_GLOBALS $ROLE_OPTIONS" > idempotence_out 51 | - ./tests/idempotence_check.sh idempotence_out 52 | 53 | # Testing with docker (experimental) 54 | - docker build -f tests/Dockerfile-ubuntu14.04 -t postgres_ubuntu14.04 . 55 | - docker build -f tests/Dockerfile-centos6 -t postgres_centos6 . 56 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Pieterjan Vandaele 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/README.md: -------------------------------------------------------------------------------- 1 | ## ANXS - PostgreSQL [![Build Status](https://travis-ci.org/ANXS/postgresql.png?branch=master)](https://travis-ci.org/ANXS/postgresql) 2 | 3 | Ansible role which installs and configures PostgreSQL, extensions, databases and users. 4 | 5 | 6 | #### Installation 7 | 8 | This has been tested on Ansible 1.9.4 and higher. 9 | 10 | To install: 11 | 12 | ``` 13 | ansible-galaxy install ANXS.postgresql 14 | ``` 15 | 16 | #### Dependencies 17 | 18 | - ANXS.monit ([Galaxy](https://galaxy.ansible.com/list#/roles/502)/[GH](https://github.com/ANXS/monit)) if you want monit protection (in that case, you should set `monit_protection: true`) 19 | 20 | 21 | #### Variables 22 | 23 | ```yaml 24 | # Basic settings 25 | postgresql_version: 9.3 26 | postgresql_encoding: 'UTF-8' 27 | postgresql_locale: 'en_US.UTF-8' 28 | postgresql_ctype: 'en_US.UTF-8' 29 | 30 | postgresql_admin_user: "postgres" 31 | postgresql_default_auth_method: "trust" 32 | 33 | postgresql_service_enabled: false # should the service be enabled, default is true 34 | 35 | postgresql_cluster_name: "main" 36 | postgresql_cluster_reset: false 37 | 38 | # List of databases to be created (optional) 39 | # Note: for more flexibility with extensions use the postgresql_database_extensions setting. 40 | postgresql_databases: 41 | - name: foobar 42 | owner: baz # optional; specify the owner of the database 43 | hstore: yes # flag to install the hstore extension on this database (yes/no) 44 | uuid_ossp: yes # flag to install the uuid-ossp extension on this database (yes/no) 45 | citext: yes # flag to install the citext extension on this database (yes/no) 46 | encoding: 'UTF-8' # override global {{ postgresql_encoding }} variable per database 47 | lc_collate: 'en_GB.UTF-8' # override global {{ postgresql_locale }} variable per database 48 | lc_ctype: 'en_GB.UTF-8' # override global {{ postgresql_ctype }} variable per database 49 | 50 | # List of database extensions to be created (optional) 51 | postgresql_database_extensions: 52 | - db: foobar 53 | extensions: 54 | - hstore 55 | - citext 56 | 57 | # List of users to be created (optional) 58 | postgresql_users: 59 | - name: baz 60 | pass: pass 61 | encrypted: no # denotes if the password is already encrypted. 62 | 63 | # List of user privileges to be applied (optional) 64 | postgresql_user_privileges: 65 | - name: baz # user name 66 | db: foobar # database 67 | priv: "ALL" # privilege string format: example: INSERT,UPDATE/table:SELECT/anothertable:ALL 68 | role_attr_flags: "CREATEDB" # role attribute flags 69 | ``` 70 | 71 | There's a lot more knobs and bolts to set, which you can find in the defaults/main.yml 72 | 73 | 74 | #### Testing 75 | This project comes with a Vagrantfile, this is a fast and easy way to test changes to the role, fire it up with `vagrant up` 76 | 77 | See [vagrant docs](https://docs.vagrantup.com/v2/) for getting setup with vagrant 78 | 79 | Once your VM is up, you can reprovision it using either `vagrant provision`, or `ansible-playbook tests/playbook.yml -i vagrant-inventory` 80 | 81 | If you want to toy with the test play, see [tests/playbook.yml](./tests/playbook.yml), and change the variables in [tests/vars.yml](./tests/vars.yml) 82 | 83 | If you are contributing, please first test your changes within the vagrant environment, (using the targeted distribution), and if possible, ensure your change is covered in the tests found in [.travis.yml](./.travis.yml) 84 | 85 | #### License 86 | 87 | Licensed under the MIT License. See the [LICENSE](./LICENSE) file for details. 88 | 89 | 90 | #### Thanks 91 | 92 | To the contributors: 93 | - [Ralph von der Heyden](https://github.com/ralph) 94 | 95 | 96 | #### Feedback, bug-reports, requests, ... 97 | 98 | Are [welcome](https://github.com/ANXS/postgresql/issues)! 99 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure('2') do |config| 5 | 6 | # Ensure we use our vagrant private key 7 | config.ssh.insert_key = false 8 | config.ssh.private_key_path = '~/.vagrant.d/insecure_private_key' 9 | 10 | config.vm.define 'anxs' do |machine| 11 | machine.vm.box = "ubuntu/trusty64" 12 | #machine.vm.box = "ubuntu/precise64" 13 | #machine.vm.box = "debian/jessie64" 14 | #machine.vm.box = "debian/wheezy64" 15 | #machine.vm.box = "chef/centos-7.1" 16 | #machine.vm.box = "chef/centos-6.6" 17 | 18 | machine.vm.network :private_network, ip: '192.168.88.22' 19 | machine.vm.hostname = 'anxs.local' 20 | machine.vm.provision 'ansible' do |ansible| 21 | ansible.playbook = 'tests/playbook.yml' 22 | ansible.sudo = true 23 | ansible.inventory_path = 'vagrant-inventory' 24 | ansible.host_key_checking = false 25 | end 26 | 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | roles_path = ../ -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/handlers/main.yml 2 | 3 | - name: restart postgresql 4 | service: 5 | name: "{{ postgresql_service_name }}" 6 | state: restarted 7 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/meta/main.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/meta/main.yml 2 | 3 | galaxy_info: 4 | author: pjan vandaele 5 | company: ANXS 6 | description: "Install and configure PostgreSQL, dependencies, extensions, databases and users." 7 | min_ansible_version: 1.9.4 8 | license: MIT 9 | platforms: 10 | - name: Ubuntu 11 | versions: 12 | - all 13 | categories: 14 | - database 15 | - database:sql 16 | 17 | dependencies: [] 18 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/configure.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/configure.yml 2 | 3 | - name: PostgreSQL | Drop the data directory | RedHat 4 | file: 5 | path: "{{ postgresql_data_directory }}" 6 | state: absent 7 | register: pgdata_dir_remove 8 | when: ansible_os_family == "RedHat" and postgresql_cluster_reset 9 | 10 | - name: PostgreSQL | Make sure the postgres data directory exists 11 | file: 12 | path: "{{postgresql_data_directory}}" 13 | owner: "{{ postgresql_service_user }}" 14 | group: "{{ postgresql_service_group }}" 15 | state: directory 16 | mode: 0700 17 | register: pgdata_dir_exist 18 | 19 | - name: PostgreSQL | Ensure the locale for lc_collate and lc_ctype is generated | Debian 20 | become: yes 21 | locale_gen: name="{{ item }}" state=present 22 | with_items: 23 | - "{{ postgresql_locale }}" 24 | - "{{ postgresql_ctype }}" 25 | when: ansible_os_family == "Debian" 26 | 27 | - name: PostgreSQL | Ensure the locale is generated | RedHat 28 | become: yes 29 | command: localedef -c -i {{ item.parts[0] }} -f {{ item.parts[1] }} {{ item.locale_name }} 30 | changed_when: false 31 | with_items: 32 | - { parts: "{{ postgresql_locale_parts }}", locale_name: "{{ postgresql_locale }}" } 33 | - { parts: "{{ postgresql_ctype_parts }}", locale_name: "{{ postgresql_ctype }}" } 34 | when: ansible_os_family == "RedHat" 35 | 36 | - name: PostgreSQL | Reset the cluster - drop the existing one | Debian 37 | shell: pg_dropcluster --stop {{ postgresql_version }} {{ postgresql_cluster_name }} 38 | become: yes 39 | become_user: "{{ postgresql_service_user }}" 40 | when: ansible_os_family == "Debian" and postgresql_cluster_reset and pgdata_dir_exist.changed 41 | 42 | - name: PostgreSQL | Reset the cluster - create a new one (with specified encoding and locale) | Debian 43 | shell: > 44 | pg_createcluster --start --locale {{ postgresql_locale }} 45 | -e {{ postgresql_encoding }} -d {{ postgresql_data_directory }} 46 | {{ postgresql_version }} {{ postgresql_cluster_name }} 47 | become: yes 48 | become_user: "{{ postgresql_service_user }}" 49 | when: ansible_os_family == "Debian" and postgresql_cluster_reset and pgdata_dir_exist.changed 50 | 51 | - name: PostgreSQL | Check whether the postgres data directory is initialized 52 | stat: 53 | path: "{{ postgresql_data_directory }}/PG_VERSION" 54 | when: ansible_os_family == "RedHat" and not postgresql_cluster_reset 55 | register: pgdata_dir_initialized 56 | 57 | - name: PostgreSQL | Initialize the database | RedHat 58 | command: > 59 | {{ postgresql_bin_directory }}/initdb -D {{ postgresql_data_directory }} 60 | --locale={{ postgresql_locale }} --encoding={{ postgresql_encoding }} 61 | become: yes 62 | become_user: "{{ postgresql_service_user }}" 63 | when: ansible_os_family == "RedHat" and 64 | (postgresql_cluster_reset or 65 | pgdata_dir_exist.changed or 66 | not pgdata_dir_initialized.stat.exists) 67 | 68 | - name: PostgreSQL | Ensure configuration directory exists 69 | file: 70 | path: "{{ postgresql_conf_directory }}" 71 | owner: "{{ postgresql_service_user }}" 72 | group: "{{ postgresql_service_group }}" 73 | mode: 0750 74 | state: directory 75 | 76 | - name: PostgreSQL | Update configuration - pt. 1 (pg_hba.conf) 77 | template: 78 | src: pg_hba.conf.j2 79 | dest: "{{postgresql_conf_directory}}/pg_hba.conf" 80 | owner: "{{ postgresql_service_user }}" 81 | group: "{{ postgresql_service_group }}" 82 | mode: 0640 83 | register: postgresql_configuration_pt1 84 | 85 | - name: PostgreSQL | Update configuration - pt. 2 (postgresql.conf) 86 | template: 87 | src: "postgresql.conf-{{ postgresql_version }}.j2" 88 | # if using pgtune, save the template to ".untuned" 89 | dest: "{{postgresql_conf_directory}}/postgresql.conf{% if postgresql_pgtune %}.untuned{% endif %}" 90 | owner: "{{ postgresql_service_user }}" 91 | group: "{{ postgresql_service_group }}" 92 | mode: 0640 93 | register: postgresql_configuration_pt2 94 | 95 | - name: PostgreSQL | Update configuration - pt. 3 (pgtune) 96 | become: true 97 | become_user: "{{ postgresql_service_user }}" 98 | shell: | 99 | set -e 100 | TMPDIR=$(mktemp -d) 101 | pgtune --input-config=postgresql.conf.untuned\ 102 | --output-config=$TMPDIR/postgresql.conf\ 103 | {% if postgresql_pgtune_memory %}--memory {{postgresql_pgtune_memory|int}}{% endif %}\ 104 | --type {{postgresql_pgtune_type|quote}}\ 105 | {% if postgresql_pgtune_connections %}--connections {{postgresql_pgtune_connections|int}}{% endif %}\ 106 | # Compare the current config with the one procuded by pgtune (ignoring comments/blanks) 107 | if diff --ignore-blank-lines \ 108 | <(sed -e 's/#.*//' postgresql.conf) \ 109 | <(sed -e 's/#.*//' $TMPDIR/postgresql.conf) 110 | then 111 | echo '_OK_' 112 | else 113 | cp $TMPDIR/postgresql.conf postgresql.conf 114 | fi 115 | # Cleanup 116 | rm $TMPDIR/postgresql.conf 117 | rmdir $TMPDIR 118 | args: 119 | chdir: "{{postgresql_conf_directory}}" 120 | executable: "/bin/bash" 121 | when: postgresql_pgtune 122 | register: postgresql_configuration_pt3 123 | changed_when: "'_OK_' not in postgresql_configuration_pt3.stdout" 124 | 125 | - name: PostgreSQL | Create folder for additional configuration files 126 | file: 127 | name: "{{postgresql_conf_directory}}/conf.d" 128 | state: directory 129 | owner: "{{ postgresql_service_user }}" 130 | group: "{{ postgresql_service_group }}" 131 | mode: 0755 132 | 133 | - name: PostgreSQL | Ensure the systemd directory for PostgreSQL exists | RedHat 134 | file: 135 | name: "/etc/systemd/system/postgresql-{{ postgresql_version }}.service.d" 136 | state: directory 137 | mode: 0755 138 | when: ansible_os_family == "RedHat" 139 | 140 | - name: PostgreSQL | Use the conf directory when starting the Postgres service | RedHat 141 | template: 142 | src: etc_systemd_system_postgresql.service.d_custom.conf.j2 143 | dest: "/etc/systemd/system/postgresql-{{ postgresql_version }}.service.d/custom.conf" 144 | when: ansible_os_family == "RedHat" 145 | register: postgresql_systemd_custom_conf 146 | 147 | - name: PostgreSQL | Ensure the pid directory for PostgreSQL exists 148 | file: 149 | name: "{{ postgresql_pid_directory }}" 150 | state: directory 151 | owner: "{{ postgresql_service_user }}" 152 | group: "{{ postgresql_service_group }}" 153 | mode: u=rwX,g=rwXs,o=rx 154 | 155 | - name: PostgreSQL | Enable service 156 | service: 157 | name: "{{ postgresql_service_name }}" 158 | enabled: yes 159 | when: "{{ postgresql_service_enabled | bool }}" 160 | 161 | - name: PostgreSQL | Restart PostgreSQL 162 | service: 163 | name: "{{ postgresql_service_name }}" 164 | state: restarted 165 | when: postgresql_configuration_pt1.changed or postgresql_configuration_pt2.changed or postgresql_configuration_pt3.changed or postgresql_systemd_custom_conf.changed 166 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/databases.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/databases.yml 2 | 3 | - name: PostgreSQL | Ensure PostgreSQL is running 4 | service: 5 | name: "{{ postgresql_service_name }}" 6 | state: started 7 | 8 | - name: PostgreSQL | Make sure the PostgreSQL databases are present 9 | postgresql_db: 10 | name: "{{item.name}}" 11 | owner: "{{ item.owner | default(postgresql_database_owner) }}" 12 | encoding: "{{ item.encoding | default(postgresql_encoding) }}" 13 | lc_collate: "{{ item.lc_collate | default(postgresql_locale) }}" 14 | lc_ctype: "{{ item.lc_ctype | default(postgresql_ctype) }}" 15 | port: "{{postgresql_port}}" 16 | template: "template0" 17 | state: present 18 | login_user: "{{postgresql_admin_user}}" 19 | become: yes 20 | become_user: "{{postgresql_admin_user}}" 21 | with_items: "{{postgresql_databases}}" 22 | when: postgresql_databases|length > 0 23 | 24 | - name: PostgreSQL | Add extensions to the databases 25 | shell: "psql {{item.0.db}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS {{ item.1 }};'" 26 | become: yes 27 | become_user: "{{postgresql_service_user}}" 28 | with_subelements: 29 | - "{{postgresql_database_extensions}}" 30 | - extensions 31 | register: result 32 | changed_when: "'NOTICE' not in result.stderr" 33 | 34 | - name: PostgreSQL | Add hstore to the databases with the requirement 35 | become: yes 36 | become_user: "{{postgresql_service_user}}" 37 | shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS hstore;'" 38 | with_items: "{{postgresql_databases}}" 39 | register: hstore_ext_result 40 | failed_when: hstore_ext_result.rc != 0 and ("already exists, skipping" not in hstore_ext_result.stderr) 41 | changed_when: hstore_ext_result.rc == 0 and ("already exists, skipping" not in hstore_ext_result.stderr) 42 | when: item.hstore is defined and item.hstore 43 | 44 | - name: PostgreSQL | Add uuid-ossp to the database with the requirement 45 | become: yes 46 | become_user: "{{postgresql_service_user}}" 47 | shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'" 48 | with_items: "{{postgresql_databases}}" 49 | register: uuid_ext_result 50 | failed_when: uuid_ext_result.rc != 0 and ("already exists, skipping" not in uuid_ext_result.stderr) 51 | changed_when: uuid_ext_result.rc == 0 and ("already exists, skipping" not in uuid_ext_result.stderr) 52 | when: item.uuid_ossp is defined and item.uuid_ossp 53 | 54 | - name: PostgreSQL | Add postgis to the databases with the requirement 55 | become: yes 56 | become_user: "{{postgresql_service_user}}" 57 | shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS postgis;'&&psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS postgis_topology;'" 58 | with_items: "{{postgresql_databases}}" 59 | when: item.gis is defined and item.gis 60 | 61 | - name: PostgreSQL | add cube to the database with the requirement 62 | become: yes 63 | become_user: "{{postgresql_service_user}}" 64 | shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists cube;'" 65 | with_items: "{{postgresql_databases}}" 66 | when: item.cube is defined and item.cube 67 | 68 | - name: PostgreSQL | Add plpgsql to the database with the requirement 69 | become: yes 70 | become_user: "{{postgresql_service_user}}" 71 | shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS plpgsql;'" 72 | with_items: "{{postgresql_databases}}" 73 | when: item.plpgsql is defined and item.plpgsql 74 | 75 | - name: PostgreSQL | add earthdistance to the database with the requirement 76 | become: yes 77 | become_user: "{{postgresql_service_user}}" 78 | shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists earthdistance;'" 79 | with_items: "{{postgresql_databases}}" 80 | when: item.earthdistance is defined and item.earthdistance 81 | 82 | - name: PostgreSQL | Add citext to the database with the requirement 83 | become: yes 84 | become_user: "{{postgresql_service_user}}" 85 | shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS citext;'" 86 | with_items: "{{postgresql_databases}}" 87 | register: citext_ext_result 88 | failed_when: citext_ext_result.rc != 0 and ("already exists, skipping" not in citext_ext_result.stderr) 89 | changed_when: citext_ext_result.rc == 0 and ("already exists, skipping" not in citext_ext_result.stderr) 90 | when: item.citext is defined and item.citext 91 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/extensions.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/extensions.yml 2 | 3 | - include: extensions/contrib.yml 4 | when: postgresql_ext_install_contrib 5 | - include: extensions/dev_headers.yml 6 | when: postgresql_ext_install_dev_headers 7 | - include: extensions/postgis.yml 8 | when: postgresql_ext_install_postgis 9 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/extensions/contrib.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/extensions/contrib.yml 2 | 3 | - name: PostgreSQL | Extensions | Make sure the postgres contrib extensions are installed | Debian 4 | apt: 5 | name: "postgresql-contrib-{{postgresql_version}}" 6 | state: present 7 | update_cache: yes 8 | cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" 9 | when: ansible_os_family == "Debian" 10 | notify: 11 | - restart postgresql 12 | 13 | - name: PostgreSQL | Extensions | Make sure the postgres contrib extensions are installed | RedHat 14 | yum: 15 | name: "postgresql{{postgresql_version_terse}}-contrib" 16 | state: present 17 | when: ansible_os_family == "RedHat" 18 | notify: 19 | - restart postgresql 20 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/extensions/dev_headers.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/extensions/dev_headers.yml 2 | 3 | - name: PostgreSQL | Extensions | Make sure the development headers are installed | Debian 4 | apt: 5 | name: libpq-dev 6 | state: present 7 | update_cache: yes 8 | cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" 9 | when: ansible_os_family == "Debian" 10 | notify: 11 | - restart postgresql 12 | 13 | - name: PostgreSQL | Extensions | Make sure the development headers are installed | RedHat 14 | yum: "name={{ item }} state=present update_cache=yes" 15 | with_items: 16 | - "postgresql{{ postgresql_version_terse }}-libs" 17 | - "postgresql{{ postgresql_version_terse }}-devel" 18 | when: ansible_os_family == "RedHat" 19 | notify: 20 | - restart postgresql 21 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/extensions/postgis.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/extensions/postgis.yml 2 | 3 | - name: PostgreSQL | Extensions | Make sure the postgis extensions are installed 4 | apt: 5 | name: "{{item}}" 6 | state: present 7 | update_cache: yes 8 | cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" 9 | with_items: 10 | - libgeos-c1 11 | - "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}" 12 | - "postgresql-{{postgresql_version}}-postgis-scripts" 13 | notify: 14 | - restart postgresql 15 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/install.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/install.yml 2 | 3 | # The standard ca-certs are needed because without them apt_key will fail to 4 | # validate www.postgresql.org (or probably any other source). 5 | - name: PostgreSQL | Make sure the CA certificates are available 6 | apt: 7 | pkg: ca-certificates 8 | state: present 9 | 10 | - name: PostgreSQL | Add PostgreSQL repository apt-key 11 | apt_key: 12 | id: "{{ postgresql_apt_key_id }}" 13 | url: "{{ postgresql_apt_key_url }}" 14 | state: present 15 | when: postgresql_apt_key_url and postgresql_apt_key_id 16 | 17 | - name: PostgreSQL | Add PostgreSQL repository 18 | apt_repository: 19 | repo: "{{ postgresql_apt_repository }}" 20 | state: present 21 | 22 | - name: PostgreSQL | Add PostgreSQL repository preferences 23 | template: 24 | src: etc_apt_preferences.d_apt_postgresql_org_pub_repos_apt.pref.j2 25 | dest: /etc/apt/preferences.d/apt_postgresql_org_pub_repos_apt.pref 26 | when: postgresql_apt_pin_priority 27 | 28 | - name: PostgreSQL | Make sure the dependencies are installed 29 | apt: 30 | pkg: "{{item}}" 31 | state: present 32 | update_cache: yes 33 | cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" 34 | with_items: ["python-psycopg2", "python-pycurl", "locales"] 35 | 36 | - name: PostgreSQL | Install PostgreSQL 37 | apt: 38 | name: "{{item}}" 39 | state: present 40 | update_cache: yes 41 | cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" 42 | environment: "{{postgresql_env}}" 43 | with_items: 44 | - "postgresql-{{postgresql_version}}" 45 | - "postgresql-client-{{postgresql_version}}" 46 | - "postgresql-contrib-{{postgresql_version}}" 47 | 48 | - name: PostgreSQL | PGTune 49 | apt: 50 | name: pgtune 51 | state: present 52 | update_cache: yes 53 | cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" 54 | environment: "{{postgresql_env}}" 55 | when: postgresql_pgtune 56 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/install_yum.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/install_yum.yml 2 | 3 | # The standard ca-certs are needed because without them apt_key will fail to 4 | # validate www.postgresql.org (or probably any other source). 5 | - name: PostgreSQL | Make sure the CA certificates are available 6 | yum: 7 | name: ca-certificates 8 | state: present 9 | 10 | - name: PostgreSQL | Add PostgreSQL repository 11 | yum: 12 | name: "{{ postgresql_yum_repository_url }}" 13 | state: present 14 | 15 | - name: PostgreSQL | Make sure the dependencies are installed 16 | yum: 17 | name: "{{ item }}" 18 | state: present 19 | update_cache: yes 20 | with_items: ["python-psycopg2", "python-pycurl", "glibc-common"] 21 | 22 | - name: PostgreSQL | Install PostgreSQL 23 | yum: 24 | name: "{{ item }}" 25 | state: present 26 | environment: "{{ postgresql_env }}" 27 | with_items: 28 | - "postgresql{{ postgresql_version_terse }}-server" 29 | - "postgresql{{ postgresql_version_terse }}" 30 | - "postgresql{{ postgresql_version_terse }}-contrib" 31 | 32 | - name: PostgreSQL | PGTune 33 | yum: 34 | name: pgtune 35 | state: present 36 | environment: "{{ postgresql_env }}" 37 | when: postgresql_pgtune 38 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/main.yml 2 | 3 | - include_vars: "{{ item }}" 4 | with_first_found: 5 | - "../vars/{{ ansible_os_family }}.yml" 6 | - "../vars/empty.yml" 7 | tags: [always] 8 | 9 | - include: install.yml 10 | when: ansible_pkg_mgr == "apt" 11 | tags: [postgresql, postgresql-install] 12 | 13 | - include: install_yum.yml 14 | when: ansible_pkg_mgr == "yum" 15 | tags: [postgresql, postgresql-install] 16 | 17 | - include: extensions.yml 18 | tags: [postgresql, postgresql-extensions] 19 | 20 | - include: configure.yml 21 | tags: [postgresql, postgresql-configure] 22 | 23 | - include: users.yml 24 | tags: [postgresql, postgresql-users] 25 | 26 | - include: databases.yml 27 | tags: [postgresql, postgresql-databases] 28 | 29 | - include: users_privileges.yml 30 | tags: [postgresql, postgresql-users] 31 | 32 | - include: monit.yml 33 | when: monit_protection is defined and monit_protection == true 34 | tags: [postgresql, postgresql-monit] 35 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/monit.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/monit.yml 2 | 3 | - name: PostgreSQL | (Monit) Copy the postgresql monit service file 4 | template: 5 | src: etc_monit_conf.d_postgresql.j2 6 | dest: /etc/monit/conf.d/postgresql 7 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/users.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/users.yml 2 | 3 | - name: PostgreSQL | Ensure PostgreSQL is running 4 | service: 5 | name: "{{ postgresql_service_name }}" 6 | state: started 7 | 8 | - name: PostgreSQL | Make sure the PostgreSQL users are present 9 | postgresql_user: 10 | name: "{{item.name}}" 11 | password: "{{ item.pass | default(omit) }}" 12 | encrypted: "{{ item.encrypted | default(omit) }}" 13 | port: "{{postgresql_port}}" 14 | state: present 15 | login_user: "{{postgresql_admin_user}}" 16 | become: yes 17 | become_user: "{{postgresql_admin_user}}" 18 | with_items: "{{postgresql_users}}" 19 | when: postgresql_users|length > 0 20 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tasks/users_privileges.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/users_privileges.yml 2 | 3 | - name: PostgreSQL | Update the user privileges 4 | postgresql_user: 5 | name: "{{item.name}}" 6 | db: "{{item.db | default(omit)}}" 7 | port: "{{postgresql_port}}" 8 | priv: "{{item.priv | default(omit)}}" 9 | state: present 10 | login_host: "{{item.host | default(omit)}}" 11 | login_user: "{{postgresql_admin_user}}" 12 | role_attr_flags: "{{item.role_attr_flags | default(omit)}}" 13 | become: yes 14 | become_user: "{{postgresql_admin_user}}" 15 | with_items: "{{postgresql_user_privileges}}" 16 | when: postgresql_users|length > 0 17 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/HOWTO.postgresql.conf: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | How to add a new PostgreSQL version 3 | =================================== 4 | 5 | 1) Download the Debian package 'postgresql-9.X_[...].deb' from 6 | http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-9.X/ 7 | 8 | 2) Extract the 'usr/share/postgresql/9.1/postgresql.conf.sample' file 9 | and save it under the 'templates' role directory 10 | => templates/postgresql.conf.9.{X}.orig 11 | 12 | 3) Check the difference between another version: 13 | => vimdiff postgresql.conf.9.{X-1}.orig postgresql.conf.9.{X}.orig 14 | 15 | 4) Copy an existing template: 16 | => cp postgresql.conf.9.{X-1}.j2 postgresql.conf.9.{X}.j2 17 | 18 | 5) Update the new template following the major differences. 19 | 20 | 5) If there are new options or some of them removed, update the 'default/main.yml' file and add a "(>= 9.X)" or "(<= 9.X)" comment to them. 21 | 22 | 6) Update the '.travis.yml' file to test its new version. 23 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/etc_apt_preferences.d_apt_postgresql_org_pub_repos_apt.pref.j2: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | 3 | Package: * 4 | Pin: release o=apt.postgresql.org 5 | Pin-Priority: {{ postgresql_apt_pin_priority }} 6 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/etc_monit_conf.d_postgresql.j2: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | check process postgresql with pidfile /var/run/postgresql/{{postgresql_version}}-{{postgresql_cluster_name}}.pid 3 | group database 4 | start program = "/etc/init.d/postgresql start" 5 | stop program = "/etc/init.d/postgresql stop" 6 | if failed host localhost port 5432 protocol pgsql then restart 7 | if 5 restarts within 5 cycles then timeout 8 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/etc_systemd_system_postgresql.service.d_custom.conf.j2: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | # Systemd unit file override to specify user/group as well as separate config 3 | # and data directories. 4 | [Service] 5 | User={{ postgresql_service_user }} 6 | Group={{ postgresql_service_group }} 7 | 8 | Environment=PGDATA={{ postgresql_conf_directory }} 9 | 10 | ExecStartPre= 11 | ExecStartPre={{ postgresql_bin_directory }}/postgresql{{ postgresql_version_terse }}-check-db-dir {{ postgresql_data_directory }} 12 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/pg_hba.conf.j2: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | # PostgreSQL Client Authentication Configuration File 3 | # =================================================== 4 | # 5 | # Refer to the "Client Authentication" section in the PostgreSQL 6 | # documentation for a complete description of this file. A short 7 | # synopsis follows. 8 | # 9 | # This file controls: which hosts are allowed to connect, how clients 10 | # are authenticated, which PostgreSQL user names they can use, which 11 | # databases they can access. Records take one of these forms: 12 | # 13 | # local DATABASE USER METHOD [OPTIONS] 14 | # host DATABASE USER ADDRESS METHOD [OPTIONS] 15 | # hostssl DATABASE USER ADDRESS METHOD [OPTIONS] 16 | # hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] 17 | # 18 | # TYPE DATABASE USER ADDRESS METHOD 19 | 20 | # Default: 21 | {% for connection in postgresql_pg_hba_default %} 22 | {% if connection.comment is defined %} 23 | # {{connection.comment}} 24 | {% endif %} 25 | {{connection.type}} {{connection.database}} {{connection.user}} {{connection.address}} {{connection.method}} 26 | {% endfor %} 27 | 28 | # Password hosts 29 | {% for host in postgresql_pg_hba_passwd_hosts %} 30 | host all all {{host}} password 31 | {% endfor %} 32 | 33 | # Trusted hosts 34 | {% for host in postgresql_pg_hba_trust_hosts %} 35 | host all all {{host}} trust 36 | {% endfor %} 37 | 38 | # User custom 39 | {% for connection in postgresql_pg_hba_custom %} 40 | {% if connection.comment is defined %} 41 | # {{connection.comment}} 42 | {% endif %} 43 | {{connection.type}} {{connection.database}} {{connection.user}} {{connection.address}} {{connection.method}} 44 | {% endfor %} 45 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/postgresql.conf-9.1.orig: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, or use "pg_ctl reload". Some 20 | # parameters, which are marked below, require a server shutdown and restart to 21 | # take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | #data_directory = 'ConfigDir' # use data in another directory 42 | # (change requires restart) 43 | #hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file 44 | # (change requires restart) 45 | #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file 46 | # (change requires restart) 47 | 48 | # If external_pid_file is not explicitly set, no extra PID file is written. 49 | #external_pid_file = '(none)' # write an extra PID file 50 | # (change requires restart) 51 | 52 | 53 | #------------------------------------------------------------------------------ 54 | # CONNECTIONS AND AUTHENTICATION 55 | #------------------------------------------------------------------------------ 56 | 57 | # - Connection Settings - 58 | 59 | #listen_addresses = 'localhost' # what IP address(es) to listen on; 60 | # comma-separated list of addresses; 61 | # defaults to 'localhost', '*' = all 62 | # (change requires restart) 63 | #port = 5432 # (change requires restart) 64 | #max_connections = 100 # (change requires restart) 65 | # Note: Increasing max_connections costs ~400 bytes of shared memory per 66 | # connection slot, plus lock space (see max_locks_per_transaction). 67 | #superuser_reserved_connections = 3 # (change requires restart) 68 | #unix_socket_directory = '' # (change requires restart) 69 | #unix_socket_group = '' # (change requires restart) 70 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 71 | # (change requires restart) 72 | #bonjour = off # advertise server via Bonjour 73 | # (change requires restart) 74 | #bonjour_name = '' # defaults to the computer name 75 | # (change requires restart) 76 | 77 | # - Security and Authentication - 78 | 79 | #authentication_timeout = 1min # 1s-600s 80 | #ssl = off # (change requires restart) 81 | #ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers 82 | # (change requires restart) 83 | #ssl_renegotiation_limit = 0 # amount of data between renegotiations 84 | #password_encryption = on 85 | #db_user_namespace = off 86 | 87 | # Kerberos and GSSAPI 88 | #krb_server_keyfile = '' 89 | #krb_srvname = 'postgres' # (Kerberos only) 90 | #krb_caseins_users = off 91 | 92 | # - TCP Keepalives - 93 | # see "man 7 tcp" for details 94 | 95 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 96 | # 0 selects the system default 97 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 98 | # 0 selects the system default 99 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 100 | # 0 selects the system default 101 | 102 | 103 | #------------------------------------------------------------------------------ 104 | # RESOURCE USAGE (except WAL) 105 | #------------------------------------------------------------------------------ 106 | 107 | # - Memory - 108 | 109 | #shared_buffers = 32MB # min 128kB 110 | # (change requires restart) 111 | #temp_buffers = 8MB # min 800kB 112 | #max_prepared_transactions = 0 # zero disables the feature 113 | # (change requires restart) 114 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 115 | # per transaction slot, plus lock space (see max_locks_per_transaction). 116 | # It is not advisable to set max_prepared_transactions nonzero unless you 117 | # actively intend to use prepared transactions. 118 | #work_mem = 1MB # min 64kB 119 | #maintenance_work_mem = 16MB # min 1MB 120 | #max_stack_depth = 2MB # min 100kB 121 | 122 | # - Kernel Resource Usage - 123 | 124 | #max_files_per_process = 1000 # min 25 125 | # (change requires restart) 126 | #shared_preload_libraries = '' # (change requires restart) 127 | 128 | # - Cost-Based Vacuum Delay - 129 | 130 | #vacuum_cost_delay = 0ms # 0-100 milliseconds 131 | #vacuum_cost_page_hit = 1 # 0-10000 credits 132 | #vacuum_cost_page_miss = 10 # 0-10000 credits 133 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 134 | #vacuum_cost_limit = 200 # 1-10000 credits 135 | 136 | # - Background Writer - 137 | 138 | #bgwriter_delay = 200ms # 10-10000ms between rounds 139 | #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round 140 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round 141 | 142 | # - Asynchronous Behavior - 143 | 144 | #effective_io_concurrency = 1 # 1-1000. 0 disables prefetching 145 | 146 | 147 | #------------------------------------------------------------------------------ 148 | # WRITE AHEAD LOG 149 | #------------------------------------------------------------------------------ 150 | 151 | # - Settings - 152 | 153 | #wal_level = minimal # minimal, archive, or hot_standby 154 | # (change requires restart) 155 | #fsync = on # turns forced synchronization on or off 156 | #synchronous_commit = on # synchronization level; on, off, or local 157 | #wal_sync_method = fsync # the default is the first option 158 | # supported by the operating system: 159 | # open_datasync 160 | # fdatasync (default on Linux) 161 | # fsync 162 | # fsync_writethrough 163 | # open_sync 164 | #full_page_writes = on # recover from partial page writes 165 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 166 | # (change requires restart) 167 | #wal_writer_delay = 200ms # 1-10000 milliseconds 168 | 169 | #commit_delay = 0 # range 0-100000, in microseconds 170 | #commit_siblings = 5 # range 1-1000 171 | 172 | # - Checkpoints - 173 | 174 | #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each 175 | #checkpoint_timeout = 5min # range 30s-1h 176 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 177 | #checkpoint_warning = 30s # 0 disables 178 | 179 | # - Archiving - 180 | 181 | #archive_mode = off # allows archiving to be done 182 | # (change requires restart) 183 | #archive_command = '' # command to use to archive a logfile segment 184 | #archive_timeout = 0 # force a logfile segment switch after this 185 | # number of seconds; 0 disables 186 | 187 | 188 | #------------------------------------------------------------------------------ 189 | # REPLICATION 190 | #------------------------------------------------------------------------------ 191 | 192 | # - Master Server - 193 | 194 | # These settings are ignored on a standby server 195 | 196 | #max_wal_senders = 0 # max number of walsender processes 197 | # (change requires restart) 198 | #wal_sender_delay = 1s # walsender cycle time, 1-10000 milliseconds 199 | #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables 200 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 201 | #replication_timeout = 60s # in milliseconds; 0 disables 202 | #synchronous_standby_names = '' # standby servers that provide sync rep 203 | # comma-separated list of application_name 204 | # from standby(s); '*' = all 205 | 206 | # - Standby Servers - 207 | 208 | # These settings are ignored on a master server 209 | 210 | #hot_standby = off # "on" allows queries during recovery 211 | # (change requires restart) 212 | #max_standby_archive_delay = 30s # max delay before canceling queries 213 | # when reading WAL from archive; 214 | # -1 allows indefinite delay 215 | #max_standby_streaming_delay = 30s # max delay before canceling queries 216 | # when reading streaming WAL; 217 | # -1 allows indefinite delay 218 | #wal_receiver_status_interval = 10s # send replies at least this often 219 | # 0 disables 220 | #hot_standby_feedback = off # send info from standby to prevent 221 | # query conflicts 222 | 223 | 224 | #------------------------------------------------------------------------------ 225 | # QUERY TUNING 226 | #------------------------------------------------------------------------------ 227 | 228 | # - Planner Method Configuration - 229 | 230 | #enable_bitmapscan = on 231 | #enable_hashagg = on 232 | #enable_hashjoin = on 233 | #enable_indexscan = on 234 | #enable_material = on 235 | #enable_mergejoin = on 236 | #enable_nestloop = on 237 | #enable_seqscan = on 238 | #enable_sort = on 239 | #enable_tidscan = on 240 | 241 | # - Planner Cost Constants - 242 | 243 | #seq_page_cost = 1.0 # measured on an arbitrary scale 244 | #random_page_cost = 4.0 # same scale as above 245 | #cpu_tuple_cost = 0.01 # same scale as above 246 | #cpu_index_tuple_cost = 0.005 # same scale as above 247 | #cpu_operator_cost = 0.0025 # same scale as above 248 | #effective_cache_size = 128MB 249 | 250 | # - Genetic Query Optimizer - 251 | 252 | #geqo = on 253 | #geqo_threshold = 12 254 | #geqo_effort = 5 # range 1-10 255 | #geqo_pool_size = 0 # selects default based on effort 256 | #geqo_generations = 0 # selects default based on effort 257 | #geqo_selection_bias = 2.0 # range 1.5-2.0 258 | #geqo_seed = 0.0 # range 0.0-1.0 259 | 260 | # - Other Planner Options - 261 | 262 | #default_statistics_target = 100 # range 1-10000 263 | #constraint_exclusion = partition # on, off, or partition 264 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 265 | #from_collapse_limit = 8 266 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 267 | # JOIN clauses 268 | 269 | 270 | #------------------------------------------------------------------------------ 271 | # ERROR REPORTING AND LOGGING 272 | #------------------------------------------------------------------------------ 273 | 274 | # - Where to Log - 275 | 276 | #log_destination = 'stderr' # Valid values are combinations of 277 | # stderr, csvlog, syslog, and eventlog, 278 | # depending on platform. csvlog 279 | # requires logging_collector to be on. 280 | 281 | # This is used when logging to stderr: 282 | #logging_collector = off # Enable capturing of stderr and csvlog 283 | # into log files. Required to be on for 284 | # csvlogs. 285 | # (change requires restart) 286 | 287 | # These are only used if logging_collector is on: 288 | #log_directory = 'pg_log' # directory where log files are written, 289 | # can be absolute or relative to PGDATA 290 | #log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, 291 | # can include strftime() escapes 292 | #log_file_mode = 0600 # creation mode for log files, 293 | # begin with 0 to use octal notation 294 | #log_truncate_on_rotation = off # If on, an existing log file with the 295 | # same name as the new log file will be 296 | # truncated rather than appended to. 297 | # But such truncation only occurs on 298 | # time-driven rotation, not on restarts 299 | # or size-driven rotation. Default is 300 | # off, meaning append to existing files 301 | # in all cases. 302 | #log_rotation_age = 1d # Automatic rotation of logfiles will 303 | # happen after that time. 0 disables. 304 | #log_rotation_size = 10MB # Automatic rotation of logfiles will 305 | # happen after that much log output. 306 | # 0 disables. 307 | 308 | # These are relevant when logging to syslog: 309 | #syslog_facility = 'LOCAL0' 310 | #syslog_ident = 'postgres' 311 | 312 | #silent_mode = off # Run server silently. 313 | # DO NOT USE without syslog or 314 | # logging_collector 315 | # (change requires restart) 316 | 317 | 318 | # - When to Log - 319 | 320 | #client_min_messages = notice # values in order of decreasing detail: 321 | # debug5 322 | # debug4 323 | # debug3 324 | # debug2 325 | # debug1 326 | # log 327 | # notice 328 | # warning 329 | # error 330 | 331 | #log_min_messages = warning # values in order of decreasing detail: 332 | # debug5 333 | # debug4 334 | # debug3 335 | # debug2 336 | # debug1 337 | # info 338 | # notice 339 | # warning 340 | # error 341 | # log 342 | # fatal 343 | # panic 344 | 345 | #log_min_error_statement = error # values in order of decreasing detail: 346 | # debug5 347 | # debug4 348 | # debug3 349 | # debug2 350 | # debug1 351 | # info 352 | # notice 353 | # warning 354 | # error 355 | # log 356 | # fatal 357 | # panic (effectively off) 358 | 359 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 360 | # and their durations, > 0 logs only 361 | # statements running at least this number 362 | # of milliseconds 363 | 364 | 365 | # - What to Log - 366 | 367 | #debug_print_parse = off 368 | #debug_print_rewritten = off 369 | #debug_print_plan = off 370 | #debug_pretty_print = on 371 | #log_checkpoints = off 372 | #log_connections = off 373 | #log_disconnections = off 374 | #log_duration = off 375 | #log_error_verbosity = default # terse, default, or verbose messages 376 | #log_hostname = off 377 | #log_line_prefix = '' # special values: 378 | # %a = application name 379 | # %u = user name 380 | # %d = database name 381 | # %r = remote host and port 382 | # %h = remote host 383 | # %p = process ID 384 | # %t = timestamp without milliseconds 385 | # %m = timestamp with milliseconds 386 | # %i = command tag 387 | # %e = SQL state 388 | # %c = session ID 389 | # %l = session line number 390 | # %s = session start timestamp 391 | # %v = virtual transaction ID 392 | # %x = transaction ID (0 if none) 393 | # %q = stop here in non-session 394 | # processes 395 | # %% = '%' 396 | # e.g. '<%u%%%d> ' 397 | #log_lock_waits = off # log lock waits >= deadlock_timeout 398 | #log_statement = 'none' # none, ddl, mod, all 399 | #log_temp_files = -1 # log temporary files equal or larger 400 | # than the specified size in kilobytes; 401 | # -1 disables, 0 logs all temp files 402 | #log_timezone = '(defaults to server environment setting)' 403 | 404 | 405 | #------------------------------------------------------------------------------ 406 | # RUNTIME STATISTICS 407 | #------------------------------------------------------------------------------ 408 | 409 | # - Query/Index Statistics Collector - 410 | 411 | #track_activities = on 412 | #track_counts = on 413 | #track_functions = none # none, pl, all 414 | #track_activity_query_size = 1024 # (change requires restart) 415 | #update_process_title = on 416 | #stats_temp_directory = 'pg_stat_tmp' 417 | 418 | 419 | # - Statistics Monitoring - 420 | 421 | #log_parser_stats = off 422 | #log_planner_stats = off 423 | #log_executor_stats = off 424 | #log_statement_stats = off 425 | 426 | 427 | #------------------------------------------------------------------------------ 428 | # AUTOVACUUM PARAMETERS 429 | #------------------------------------------------------------------------------ 430 | 431 | #autovacuum = on # Enable autovacuum subprocess? 'on' 432 | # requires track_counts to also be on. 433 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 434 | # their durations, > 0 logs only 435 | # actions running at least this number 436 | # of milliseconds. 437 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 438 | # (change requires restart) 439 | #autovacuum_naptime = 1min # time between autovacuum runs 440 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 441 | # vacuum 442 | #autovacuum_analyze_threshold = 50 # min number of row updates before 443 | # analyze 444 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 445 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 446 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 447 | # (change requires restart) 448 | #autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for 449 | # autovacuum, in milliseconds; 450 | # -1 means use vacuum_cost_delay 451 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 452 | # autovacuum, -1 means use 453 | # vacuum_cost_limit 454 | 455 | 456 | #------------------------------------------------------------------------------ 457 | # CLIENT CONNECTION DEFAULTS 458 | #------------------------------------------------------------------------------ 459 | 460 | # - Statement Behavior - 461 | 462 | #search_path = '"$user",public' # schema names 463 | #default_tablespace = '' # a tablespace name, '' uses the default 464 | #temp_tablespaces = '' # a list of tablespace names, '' uses 465 | # only default tablespace 466 | #check_function_bodies = on 467 | #default_transaction_isolation = 'read committed' 468 | #default_transaction_read_only = off 469 | #default_transaction_deferrable = off 470 | #session_replication_role = 'origin' 471 | #statement_timeout = 0 # in milliseconds, 0 is disabled 472 | #vacuum_freeze_min_age = 50000000 473 | #vacuum_freeze_table_age = 150000000 474 | #bytea_output = 'hex' # hex, escape 475 | #xmlbinary = 'base64' 476 | #xmloption = 'content' 477 | #gin_fuzzy_search_limit = 0 478 | 479 | # - Locale and Formatting - 480 | 481 | #datestyle = 'iso, mdy' 482 | #intervalstyle = 'postgres' 483 | #timezone = '(defaults to server environment setting)' 484 | #timezone_abbreviations = 'Default' # Select the set of available time zone 485 | # abbreviations. Currently, there are 486 | # Default 487 | # Australia (historical usage) 488 | # India 489 | # You can create your own file in 490 | # share/timezonesets/. 491 | #extra_float_digits = 0 # min -15, max 3 492 | #client_encoding = sql_ascii # actually, defaults to database 493 | # encoding 494 | 495 | # These settings are initialized by initdb, but they can be changed. 496 | #lc_messages = 'C' # locale for system error message 497 | # strings 498 | #lc_monetary = 'C' # locale for monetary formatting 499 | #lc_numeric = 'C' # locale for number formatting 500 | #lc_time = 'C' # locale for time formatting 501 | 502 | # default configuration for text search 503 | #default_text_search_config = 'pg_catalog.simple' 504 | 505 | # - Other Defaults - 506 | 507 | #dynamic_library_path = '$libdir' 508 | #local_preload_libraries = '' 509 | 510 | 511 | #------------------------------------------------------------------------------ 512 | # LOCK MANAGEMENT 513 | #------------------------------------------------------------------------------ 514 | 515 | #deadlock_timeout = 1s 516 | #max_locks_per_transaction = 64 # min 10 517 | # (change requires restart) 518 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 519 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 520 | # lock table slots. 521 | #max_pred_locks_per_transaction = 64 # min 10 522 | # (change requires restart) 523 | 524 | #------------------------------------------------------------------------------ 525 | # VERSION/PLATFORM COMPATIBILITY 526 | #------------------------------------------------------------------------------ 527 | 528 | # - Previous PostgreSQL Versions - 529 | 530 | #array_nulls = on 531 | #backslash_quote = safe_encoding # on, off, or safe_encoding 532 | #default_with_oids = off 533 | #escape_string_warning = on 534 | #lo_compat_privileges = off 535 | #quote_all_identifiers = off 536 | #sql_inheritance = on 537 | #standard_conforming_strings = on 538 | #synchronize_seqscans = on 539 | 540 | # - Other Platforms and Clients - 541 | 542 | #transform_null_equals = off 543 | 544 | 545 | #------------------------------------------------------------------------------ 546 | # ERROR HANDLING 547 | #------------------------------------------------------------------------------ 548 | 549 | #exit_on_error = off # terminate session on any error? 550 | #restart_after_crash = on # reinitialize after backend crash? 551 | 552 | 553 | #------------------------------------------------------------------------------ 554 | # CUSTOMIZED OPTIONS 555 | #------------------------------------------------------------------------------ 556 | 557 | #custom_variable_classes = '' # list of custom variable class names 558 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/postgresql.conf-9.2.orig: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, or use "pg_ctl reload". Some 20 | # parameters, which are marked below, require a server shutdown and restart to 21 | # take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | #data_directory = 'ConfigDir' # use data in another directory 42 | # (change requires restart) 43 | #hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file 44 | # (change requires restart) 45 | #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file 46 | # (change requires restart) 47 | 48 | # If external_pid_file is not explicitly set, no extra PID file is written. 49 | #external_pid_file = '' # write an extra PID file 50 | # (change requires restart) 51 | 52 | 53 | #------------------------------------------------------------------------------ 54 | # CONNECTIONS AND AUTHENTICATION 55 | #------------------------------------------------------------------------------ 56 | 57 | # - Connection Settings - 58 | 59 | #listen_addresses = 'localhost' # what IP address(es) to listen on; 60 | # comma-separated list of addresses; 61 | # defaults to 'localhost'; use '*' for all 62 | # (change requires restart) 63 | #port = 5432 # (change requires restart) 64 | #max_connections = 100 # (change requires restart) 65 | # Note: Increasing max_connections costs ~400 bytes of shared memory per 66 | # connection slot, plus lock space (see max_locks_per_transaction). 67 | #superuser_reserved_connections = 3 # (change requires restart) 68 | #unix_socket_directory = '' # (change requires restart) 69 | #unix_socket_group = '' # (change requires restart) 70 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 71 | # (change requires restart) 72 | #bonjour = off # advertise server via Bonjour 73 | # (change requires restart) 74 | #bonjour_name = '' # defaults to the computer name 75 | # (change requires restart) 76 | 77 | # - Security and Authentication - 78 | 79 | #authentication_timeout = 1min # 1s-600s 80 | #ssl = off # (change requires restart) 81 | #ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers 82 | # (change requires restart) 83 | #ssl_renegotiation_limit = 0 # amount of data between renegotiations 84 | #ssl_cert_file = 'server.crt' # (change requires restart) 85 | #ssl_key_file = 'server.key' # (change requires restart) 86 | #ssl_ca_file = '' # (change requires restart) 87 | #ssl_crl_file = '' # (change requires restart) 88 | #password_encryption = on 89 | #db_user_namespace = off 90 | 91 | # Kerberos and GSSAPI 92 | #krb_server_keyfile = '' 93 | #krb_srvname = 'postgres' # (Kerberos only) 94 | #krb_caseins_users = off 95 | 96 | # - TCP Keepalives - 97 | # see "man 7 tcp" for details 98 | 99 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 100 | # 0 selects the system default 101 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 102 | # 0 selects the system default 103 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 104 | # 0 selects the system default 105 | 106 | 107 | #------------------------------------------------------------------------------ 108 | # RESOURCE USAGE (except WAL) 109 | #------------------------------------------------------------------------------ 110 | 111 | # - Memory - 112 | 113 | #shared_buffers = 32MB # min 128kB 114 | # (change requires restart) 115 | #temp_buffers = 8MB # min 800kB 116 | #max_prepared_transactions = 0 # zero disables the feature 117 | # (change requires restart) 118 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 119 | # per transaction slot, plus lock space (see max_locks_per_transaction). 120 | # It is not advisable to set max_prepared_transactions nonzero unless you 121 | # actively intend to use prepared transactions. 122 | #work_mem = 1MB # min 64kB 123 | #maintenance_work_mem = 16MB # min 1MB 124 | #max_stack_depth = 2MB # min 100kB 125 | 126 | # - Disk - 127 | 128 | #temp_file_limit = -1 # limits per-session temp file space 129 | # in kB, or -1 for no limit 130 | 131 | # - Kernel Resource Usage - 132 | 133 | #max_files_per_process = 1000 # min 25 134 | # (change requires restart) 135 | #shared_preload_libraries = '' # (change requires restart) 136 | 137 | # - Cost-Based Vacuum Delay - 138 | 139 | #vacuum_cost_delay = 0ms # 0-100 milliseconds 140 | #vacuum_cost_page_hit = 1 # 0-10000 credits 141 | #vacuum_cost_page_miss = 10 # 0-10000 credits 142 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 143 | #vacuum_cost_limit = 200 # 1-10000 credits 144 | 145 | # - Background Writer - 146 | 147 | #bgwriter_delay = 200ms # 10-10000ms between rounds 148 | #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round 149 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round 150 | 151 | # - Asynchronous Behavior - 152 | 153 | #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching 154 | 155 | 156 | #------------------------------------------------------------------------------ 157 | # WRITE AHEAD LOG 158 | #------------------------------------------------------------------------------ 159 | 160 | # - Settings - 161 | 162 | #wal_level = minimal # minimal, archive, or hot_standby 163 | # (change requires restart) 164 | #fsync = on # turns forced synchronization on or off 165 | #synchronous_commit = on # synchronization level; 166 | # off, local, remote_write, or on 167 | #wal_sync_method = fsync # the default is the first option 168 | # supported by the operating system: 169 | # open_datasync 170 | # fdatasync (default on Linux) 171 | # fsync 172 | # fsync_writethrough 173 | # open_sync 174 | #full_page_writes = on # recover from partial page writes 175 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 176 | # (change requires restart) 177 | #wal_writer_delay = 200ms # 1-10000 milliseconds 178 | 179 | #commit_delay = 0 # range 0-100000, in microseconds 180 | #commit_siblings = 5 # range 1-1000 181 | 182 | # - Checkpoints - 183 | 184 | #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each 185 | #checkpoint_timeout = 5min # range 30s-1h 186 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 187 | #checkpoint_warning = 30s # 0 disables 188 | 189 | # - Archiving - 190 | 191 | #archive_mode = off # allows archiving to be done 192 | # (change requires restart) 193 | #archive_command = '' # command to use to archive a logfile segment 194 | # placeholders: %p = path of file to archive 195 | # %f = file name only 196 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 197 | #archive_timeout = 0 # force a logfile segment switch after this 198 | # number of seconds; 0 disables 199 | 200 | 201 | #------------------------------------------------------------------------------ 202 | # REPLICATION 203 | #------------------------------------------------------------------------------ 204 | 205 | # - Sending Server(s) - 206 | 207 | # Set these on the master and on any standby that will send replication data. 208 | 209 | #max_wal_senders = 0 # max number of walsender processes 210 | # (change requires restart) 211 | #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables 212 | #replication_timeout = 60s # in milliseconds; 0 disables 213 | 214 | # - Master Server - 215 | 216 | # These settings are ignored on a standby server. 217 | 218 | #synchronous_standby_names = '' # standby servers that provide sync rep 219 | # comma-separated list of application_name 220 | # from standby(s); '*' = all 221 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 222 | 223 | # - Standby Servers - 224 | 225 | # These settings are ignored on a master server. 226 | 227 | #hot_standby = off # "on" allows queries during recovery 228 | # (change requires restart) 229 | #max_standby_archive_delay = 30s # max delay before canceling queries 230 | # when reading WAL from archive; 231 | # -1 allows indefinite delay 232 | #max_standby_streaming_delay = 30s # max delay before canceling queries 233 | # when reading streaming WAL; 234 | # -1 allows indefinite delay 235 | #wal_receiver_status_interval = 10s # send replies at least this often 236 | # 0 disables 237 | #hot_standby_feedback = off # send info from standby to prevent 238 | # query conflicts 239 | 240 | 241 | #------------------------------------------------------------------------------ 242 | # QUERY TUNING 243 | #------------------------------------------------------------------------------ 244 | 245 | # - Planner Method Configuration - 246 | 247 | #enable_bitmapscan = on 248 | #enable_hashagg = on 249 | #enable_hashjoin = on 250 | #enable_indexscan = on 251 | #enable_indexonlyscan = on 252 | #enable_material = on 253 | #enable_mergejoin = on 254 | #enable_nestloop = on 255 | #enable_seqscan = on 256 | #enable_sort = on 257 | #enable_tidscan = on 258 | 259 | # - Planner Cost Constants - 260 | 261 | #seq_page_cost = 1.0 # measured on an arbitrary scale 262 | #random_page_cost = 4.0 # same scale as above 263 | #cpu_tuple_cost = 0.01 # same scale as above 264 | #cpu_index_tuple_cost = 0.005 # same scale as above 265 | #cpu_operator_cost = 0.0025 # same scale as above 266 | #effective_cache_size = 128MB 267 | 268 | # - Genetic Query Optimizer - 269 | 270 | #geqo = on 271 | #geqo_threshold = 12 272 | #geqo_effort = 5 # range 1-10 273 | #geqo_pool_size = 0 # selects default based on effort 274 | #geqo_generations = 0 # selects default based on effort 275 | #geqo_selection_bias = 2.0 # range 1.5-2.0 276 | #geqo_seed = 0.0 # range 0.0-1.0 277 | 278 | # - Other Planner Options - 279 | 280 | #default_statistics_target = 100 # range 1-10000 281 | #constraint_exclusion = partition # on, off, or partition 282 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 283 | #from_collapse_limit = 8 284 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 285 | # JOIN clauses 286 | 287 | 288 | #------------------------------------------------------------------------------ 289 | # ERROR REPORTING AND LOGGING 290 | #------------------------------------------------------------------------------ 291 | 292 | # - Where to Log - 293 | 294 | #log_destination = 'stderr' # Valid values are combinations of 295 | # stderr, csvlog, syslog, and eventlog, 296 | # depending on platform. csvlog 297 | # requires logging_collector to be on. 298 | 299 | # This is used when logging to stderr: 300 | #logging_collector = off # Enable capturing of stderr and csvlog 301 | # into log files. Required to be on for 302 | # csvlogs. 303 | # (change requires restart) 304 | 305 | # These are only used if logging_collector is on: 306 | #log_directory = 'pg_log' # directory where log files are written, 307 | # can be absolute or relative to PGDATA 308 | #log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, 309 | # can include strftime() escapes 310 | #log_file_mode = 0600 # creation mode for log files, 311 | # begin with 0 to use octal notation 312 | #log_truncate_on_rotation = off # If on, an existing log file with the 313 | # same name as the new log file will be 314 | # truncated rather than appended to. 315 | # But such truncation only occurs on 316 | # time-driven rotation, not on restarts 317 | # or size-driven rotation. Default is 318 | # off, meaning append to existing files 319 | # in all cases. 320 | #log_rotation_age = 1d # Automatic rotation of logfiles will 321 | # happen after that time. 0 disables. 322 | #log_rotation_size = 10MB # Automatic rotation of logfiles will 323 | # happen after that much log output. 324 | # 0 disables. 325 | 326 | # These are relevant when logging to syslog: 327 | #syslog_facility = 'LOCAL0' 328 | #syslog_ident = 'postgres' 329 | 330 | # This is only relevant when logging to eventlog (win32): 331 | #event_source = 'PostgreSQL' 332 | 333 | # - When to Log - 334 | 335 | #client_min_messages = notice # values in order of decreasing detail: 336 | # debug5 337 | # debug4 338 | # debug3 339 | # debug2 340 | # debug1 341 | # log 342 | # notice 343 | # warning 344 | # error 345 | 346 | #log_min_messages = warning # values in order of decreasing detail: 347 | # debug5 348 | # debug4 349 | # debug3 350 | # debug2 351 | # debug1 352 | # info 353 | # notice 354 | # warning 355 | # error 356 | # log 357 | # fatal 358 | # panic 359 | 360 | #log_min_error_statement = error # values in order of decreasing detail: 361 | # debug5 362 | # debug4 363 | # debug3 364 | # debug2 365 | # debug1 366 | # info 367 | # notice 368 | # warning 369 | # error 370 | # log 371 | # fatal 372 | # panic (effectively off) 373 | 374 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 375 | # and their durations, > 0 logs only 376 | # statements running at least this number 377 | # of milliseconds 378 | 379 | 380 | # - What to Log - 381 | 382 | #debug_print_parse = off 383 | #debug_print_rewritten = off 384 | #debug_print_plan = off 385 | #debug_pretty_print = on 386 | #log_checkpoints = off 387 | #log_connections = off 388 | #log_disconnections = off 389 | #log_duration = off 390 | #log_error_verbosity = default # terse, default, or verbose messages 391 | #log_hostname = off 392 | #log_line_prefix = '' # special values: 393 | # %a = application name 394 | # %u = user name 395 | # %d = database name 396 | # %r = remote host and port 397 | # %h = remote host 398 | # %p = process ID 399 | # %t = timestamp without milliseconds 400 | # %m = timestamp with milliseconds 401 | # %i = command tag 402 | # %e = SQL state 403 | # %c = session ID 404 | # %l = session line number 405 | # %s = session start timestamp 406 | # %v = virtual transaction ID 407 | # %x = transaction ID (0 if none) 408 | # %q = stop here in non-session 409 | # processes 410 | # %% = '%' 411 | # e.g. '<%u%%%d> ' 412 | #log_lock_waits = off # log lock waits >= deadlock_timeout 413 | #log_statement = 'none' # none, ddl, mod, all 414 | #log_temp_files = -1 # log temporary files equal or larger 415 | # than the specified size in kilobytes; 416 | # -1 disables, 0 logs all temp files 417 | #log_timezone = 'GMT' 418 | 419 | 420 | #------------------------------------------------------------------------------ 421 | # RUNTIME STATISTICS 422 | #------------------------------------------------------------------------------ 423 | 424 | # - Query/Index Statistics Collector - 425 | 426 | #track_activities = on 427 | #track_counts = on 428 | #track_io_timing = off 429 | #track_functions = none # none, pl, all 430 | #track_activity_query_size = 1024 # (change requires restart) 431 | #update_process_title = on 432 | #stats_temp_directory = 'pg_stat_tmp' 433 | 434 | 435 | # - Statistics Monitoring - 436 | 437 | #log_parser_stats = off 438 | #log_planner_stats = off 439 | #log_executor_stats = off 440 | #log_statement_stats = off 441 | 442 | 443 | #------------------------------------------------------------------------------ 444 | # AUTOVACUUM PARAMETERS 445 | #------------------------------------------------------------------------------ 446 | 447 | #autovacuum = on # Enable autovacuum subprocess? 'on' 448 | # requires track_counts to also be on. 449 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 450 | # their durations, > 0 logs only 451 | # actions running at least this number 452 | # of milliseconds. 453 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 454 | # (change requires restart) 455 | #autovacuum_naptime = 1min # time between autovacuum runs 456 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 457 | # vacuum 458 | #autovacuum_analyze_threshold = 50 # min number of row updates before 459 | # analyze 460 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 461 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 462 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 463 | # (change requires restart) 464 | #autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for 465 | # autovacuum, in milliseconds; 466 | # -1 means use vacuum_cost_delay 467 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 468 | # autovacuum, -1 means use 469 | # vacuum_cost_limit 470 | 471 | 472 | #------------------------------------------------------------------------------ 473 | # CLIENT CONNECTION DEFAULTS 474 | #------------------------------------------------------------------------------ 475 | 476 | # - Statement Behavior - 477 | 478 | #search_path = '"$user",public' # schema names 479 | #default_tablespace = '' # a tablespace name, '' uses the default 480 | #temp_tablespaces = '' # a list of tablespace names, '' uses 481 | # only default tablespace 482 | #check_function_bodies = on 483 | #default_transaction_isolation = 'read committed' 484 | #default_transaction_read_only = off 485 | #default_transaction_deferrable = off 486 | #session_replication_role = 'origin' 487 | #statement_timeout = 0 # in milliseconds, 0 is disabled 488 | #vacuum_freeze_min_age = 50000000 489 | #vacuum_freeze_table_age = 150000000 490 | #bytea_output = 'hex' # hex, escape 491 | #xmlbinary = 'base64' 492 | #xmloption = 'content' 493 | #gin_fuzzy_search_limit = 0 494 | 495 | # - Locale and Formatting - 496 | 497 | #datestyle = 'iso, mdy' 498 | #intervalstyle = 'postgres' 499 | #timezone = 'GMT' 500 | #timezone_abbreviations = 'Default' # Select the set of available time zone 501 | # abbreviations. Currently, there are 502 | # Default 503 | # Australia (historical usage) 504 | # India 505 | # You can create your own file in 506 | # share/timezonesets/. 507 | #extra_float_digits = 0 # min -15, max 3 508 | #client_encoding = sql_ascii # actually, defaults to database 509 | # encoding 510 | 511 | # These settings are initialized by initdb, but they can be changed. 512 | #lc_messages = 'C' # locale for system error message 513 | # strings 514 | #lc_monetary = 'C' # locale for monetary formatting 515 | #lc_numeric = 'C' # locale for number formatting 516 | #lc_time = 'C' # locale for time formatting 517 | 518 | # default configuration for text search 519 | #default_text_search_config = 'pg_catalog.simple' 520 | 521 | # - Other Defaults - 522 | 523 | #dynamic_library_path = '$libdir' 524 | #local_preload_libraries = '' 525 | 526 | 527 | #------------------------------------------------------------------------------ 528 | # LOCK MANAGEMENT 529 | #------------------------------------------------------------------------------ 530 | 531 | #deadlock_timeout = 1s 532 | #max_locks_per_transaction = 64 # min 10 533 | # (change requires restart) 534 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 535 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 536 | # lock table slots. 537 | #max_pred_locks_per_transaction = 64 # min 10 538 | # (change requires restart) 539 | 540 | 541 | #------------------------------------------------------------------------------ 542 | # VERSION/PLATFORM COMPATIBILITY 543 | #------------------------------------------------------------------------------ 544 | 545 | # - Previous PostgreSQL Versions - 546 | 547 | #array_nulls = on 548 | #backslash_quote = safe_encoding # on, off, or safe_encoding 549 | #default_with_oids = off 550 | #escape_string_warning = on 551 | #lo_compat_privileges = off 552 | #quote_all_identifiers = off 553 | #sql_inheritance = on 554 | #standard_conforming_strings = on 555 | #synchronize_seqscans = on 556 | 557 | # - Other Platforms and Clients - 558 | 559 | #transform_null_equals = off 560 | 561 | 562 | #------------------------------------------------------------------------------ 563 | # ERROR HANDLING 564 | #------------------------------------------------------------------------------ 565 | 566 | #exit_on_error = off # terminate session on any error? 567 | #restart_after_crash = on # reinitialize after backend crash? 568 | 569 | 570 | #------------------------------------------------------------------------------ 571 | # CUSTOMIZED OPTIONS 572 | #------------------------------------------------------------------------------ 573 | 574 | # Add settings for extensions here 575 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/postgresql.conf-9.3.orig: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, or use "pg_ctl reload". Some 20 | # parameters, which are marked below, require a server shutdown and restart to 21 | # take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | #data_directory = 'ConfigDir' # use data in another directory 42 | # (change requires restart) 43 | #hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file 44 | # (change requires restart) 45 | #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file 46 | # (change requires restart) 47 | 48 | # If external_pid_file is not explicitly set, no extra PID file is written. 49 | #external_pid_file = '' # write an extra PID file 50 | # (change requires restart) 51 | 52 | 53 | #------------------------------------------------------------------------------ 54 | # CONNECTIONS AND AUTHENTICATION 55 | #------------------------------------------------------------------------------ 56 | 57 | # - Connection Settings - 58 | 59 | #listen_addresses = 'localhost' # what IP address(es) to listen on; 60 | # comma-separated list of addresses; 61 | # defaults to 'localhost'; use '*' for all 62 | # (change requires restart) 63 | #port = 5432 # (change requires restart) 64 | #max_connections = 100 # (change requires restart) 65 | # Note: Increasing max_connections costs ~400 bytes of shared memory per 66 | # connection slot, plus lock space (see max_locks_per_transaction). 67 | #superuser_reserved_connections = 3 # (change requires restart) 68 | #unix_socket_directories = '/tmp' # comma-separated list of directories 69 | # (change requires restart) 70 | #unix_socket_group = '' # (change requires restart) 71 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 72 | # (change requires restart) 73 | #bonjour = off # advertise server via Bonjour 74 | # (change requires restart) 75 | #bonjour_name = '' # defaults to the computer name 76 | # (change requires restart) 77 | 78 | # - Security and Authentication - 79 | 80 | #authentication_timeout = 1min # 1s-600s 81 | #ssl = off # (change requires restart) 82 | #ssl_ciphers = 'DEFAULT:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers 83 | # (change requires restart) 84 | #ssl_renegotiation_limit = 512MB # amount of data between renegotiations 85 | #ssl_cert_file = 'server.crt' # (change requires restart) 86 | #ssl_key_file = 'server.key' # (change requires restart) 87 | #ssl_ca_file = '' # (change requires restart) 88 | #ssl_crl_file = '' # (change requires restart) 89 | #password_encryption = on 90 | #db_user_namespace = off 91 | 92 | # Kerberos and GSSAPI 93 | #krb_server_keyfile = '' 94 | #krb_srvname = 'postgres' # (Kerberos only) 95 | #krb_caseins_users = off 96 | 97 | # - TCP Keepalives - 98 | # see "man 7 tcp" for details 99 | 100 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 101 | # 0 selects the system default 102 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 103 | # 0 selects the system default 104 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 105 | # 0 selects the system default 106 | 107 | 108 | #------------------------------------------------------------------------------ 109 | # RESOURCE USAGE (except WAL) 110 | #------------------------------------------------------------------------------ 111 | 112 | # - Memory - 113 | 114 | #shared_buffers = 32MB # min 128kB 115 | # (change requires restart) 116 | #temp_buffers = 8MB # min 800kB 117 | #max_prepared_transactions = 0 # zero disables the feature 118 | # (change requires restart) 119 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 120 | # per transaction slot, plus lock space (see max_locks_per_transaction). 121 | # It is not advisable to set max_prepared_transactions nonzero unless you 122 | # actively intend to use prepared transactions. 123 | #work_mem = 1MB # min 64kB 124 | #maintenance_work_mem = 16MB # min 1MB 125 | #max_stack_depth = 2MB # min 100kB 126 | 127 | # - Disk - 128 | 129 | #temp_file_limit = -1 # limits per-session temp file space 130 | # in kB, or -1 for no limit 131 | 132 | # - Kernel Resource Usage - 133 | 134 | #max_files_per_process = 1000 # min 25 135 | # (change requires restart) 136 | #shared_preload_libraries = '' # (change requires restart) 137 | 138 | # - Cost-Based Vacuum Delay - 139 | 140 | #vacuum_cost_delay = 0 # 0-100 milliseconds 141 | #vacuum_cost_page_hit = 1 # 0-10000 credits 142 | #vacuum_cost_page_miss = 10 # 0-10000 credits 143 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 144 | #vacuum_cost_limit = 200 # 1-10000 credits 145 | 146 | # - Background Writer - 147 | 148 | #bgwriter_delay = 200ms # 10-10000ms between rounds 149 | #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round 150 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round 151 | 152 | # - Asynchronous Behavior - 153 | 154 | #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching 155 | 156 | 157 | #------------------------------------------------------------------------------ 158 | # WRITE AHEAD LOG 159 | #------------------------------------------------------------------------------ 160 | 161 | # - Settings - 162 | 163 | #wal_level = minimal # minimal, archive, or hot_standby 164 | # (change requires restart) 165 | #fsync = on # turns forced synchronization on or off 166 | #synchronous_commit = on # synchronization level; 167 | # off, local, remote_write, or on 168 | #wal_sync_method = fsync # the default is the first option 169 | # supported by the operating system: 170 | # open_datasync 171 | # fdatasync (default on Linux) 172 | # fsync 173 | # fsync_writethrough 174 | # open_sync 175 | #full_page_writes = on # recover from partial page writes 176 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 177 | # (change requires restart) 178 | #wal_writer_delay = 200ms # 1-10000 milliseconds 179 | 180 | #commit_delay = 0 # range 0-100000, in microseconds 181 | #commit_siblings = 5 # range 1-1000 182 | 183 | # - Checkpoints - 184 | 185 | #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each 186 | #checkpoint_timeout = 5min # range 30s-1h 187 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 188 | #checkpoint_warning = 30s # 0 disables 189 | 190 | # - Archiving - 191 | 192 | #archive_mode = off # allows archiving to be done 193 | # (change requires restart) 194 | #archive_command = '' # command to use to archive a logfile segment 195 | # placeholders: %p = path of file to archive 196 | # %f = file name only 197 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 198 | #archive_timeout = 0 # force a logfile segment switch after this 199 | # number of seconds; 0 disables 200 | 201 | 202 | #------------------------------------------------------------------------------ 203 | # REPLICATION 204 | #------------------------------------------------------------------------------ 205 | 206 | # - Sending Server(s) - 207 | 208 | # Set these on the master and on any standby that will send replication data. 209 | 210 | #max_wal_senders = 0 # max number of walsender processes 211 | # (change requires restart) 212 | #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables 213 | #wal_sender_timeout = 60s # in milliseconds; 0 disables 214 | 215 | # - Master Server - 216 | 217 | # These settings are ignored on a standby server. 218 | 219 | #synchronous_standby_names = '' # standby servers that provide sync rep 220 | # comma-separated list of application_name 221 | # from standby(s); '*' = all 222 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 223 | 224 | # - Standby Servers - 225 | 226 | # These settings are ignored on a master server. 227 | 228 | #hot_standby = off # "on" allows queries during recovery 229 | # (change requires restart) 230 | #max_standby_archive_delay = 30s # max delay before canceling queries 231 | # when reading WAL from archive; 232 | # -1 allows indefinite delay 233 | #max_standby_streaming_delay = 30s # max delay before canceling queries 234 | # when reading streaming WAL; 235 | # -1 allows indefinite delay 236 | #wal_receiver_status_interval = 10s # send replies at least this often 237 | # 0 disables 238 | #hot_standby_feedback = off # send info from standby to prevent 239 | # query conflicts 240 | #wal_receiver_timeout = 60s # time that receiver waits for 241 | # communication from master 242 | # in milliseconds; 0 disables 243 | 244 | 245 | #------------------------------------------------------------------------------ 246 | # QUERY TUNING 247 | #------------------------------------------------------------------------------ 248 | 249 | # - Planner Method Configuration - 250 | 251 | #enable_bitmapscan = on 252 | #enable_hashagg = on 253 | #enable_hashjoin = on 254 | #enable_indexscan = on 255 | #enable_indexonlyscan = on 256 | #enable_material = on 257 | #enable_mergejoin = on 258 | #enable_nestloop = on 259 | #enable_seqscan = on 260 | #enable_sort = on 261 | #enable_tidscan = on 262 | 263 | # - Planner Cost Constants - 264 | 265 | #seq_page_cost = 1.0 # measured on an arbitrary scale 266 | #random_page_cost = 4.0 # same scale as above 267 | #cpu_tuple_cost = 0.01 # same scale as above 268 | #cpu_index_tuple_cost = 0.005 # same scale as above 269 | #cpu_operator_cost = 0.0025 # same scale as above 270 | #effective_cache_size = 128MB 271 | 272 | # - Genetic Query Optimizer - 273 | 274 | #geqo = on 275 | #geqo_threshold = 12 276 | #geqo_effort = 5 # range 1-10 277 | #geqo_pool_size = 0 # selects default based on effort 278 | #geqo_generations = 0 # selects default based on effort 279 | #geqo_selection_bias = 2.0 # range 1.5-2.0 280 | #geqo_seed = 0.0 # range 0.0-1.0 281 | 282 | # - Other Planner Options - 283 | 284 | #default_statistics_target = 100 # range 1-10000 285 | #constraint_exclusion = partition # on, off, or partition 286 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 287 | #from_collapse_limit = 8 288 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 289 | # JOIN clauses 290 | 291 | 292 | #------------------------------------------------------------------------------ 293 | # ERROR REPORTING AND LOGGING 294 | #------------------------------------------------------------------------------ 295 | 296 | # - Where to Log - 297 | 298 | #log_destination = 'stderr' # Valid values are combinations of 299 | # stderr, csvlog, syslog, and eventlog, 300 | # depending on platform. csvlog 301 | # requires logging_collector to be on. 302 | 303 | # This is used when logging to stderr: 304 | #logging_collector = off # Enable capturing of stderr and csvlog 305 | # into log files. Required to be on for 306 | # csvlogs. 307 | # (change requires restart) 308 | 309 | # These are only used if logging_collector is on: 310 | #log_directory = 'pg_log' # directory where log files are written, 311 | # can be absolute or relative to PGDATA 312 | #log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, 313 | # can include strftime() escapes 314 | #log_file_mode = 0600 # creation mode for log files, 315 | # begin with 0 to use octal notation 316 | #log_truncate_on_rotation = off # If on, an existing log file with the 317 | # same name as the new log file will be 318 | # truncated rather than appended to. 319 | # But such truncation only occurs on 320 | # time-driven rotation, not on restarts 321 | # or size-driven rotation. Default is 322 | # off, meaning append to existing files 323 | # in all cases. 324 | #log_rotation_age = 1d # Automatic rotation of logfiles will 325 | # happen after that time. 0 disables. 326 | #log_rotation_size = 10MB # Automatic rotation of logfiles will 327 | # happen after that much log output. 328 | # 0 disables. 329 | 330 | # These are relevant when logging to syslog: 331 | #syslog_facility = 'LOCAL0' 332 | #syslog_ident = 'postgres' 333 | 334 | # This is only relevant when logging to eventlog (win32): 335 | #event_source = 'PostgreSQL' 336 | 337 | # - When to Log - 338 | 339 | #client_min_messages = notice # values in order of decreasing detail: 340 | # debug5 341 | # debug4 342 | # debug3 343 | # debug2 344 | # debug1 345 | # log 346 | # notice 347 | # warning 348 | # error 349 | 350 | #log_min_messages = warning # values in order of decreasing detail: 351 | # debug5 352 | # debug4 353 | # debug3 354 | # debug2 355 | # debug1 356 | # info 357 | # notice 358 | # warning 359 | # error 360 | # log 361 | # fatal 362 | # panic 363 | 364 | #log_min_error_statement = error # values in order of decreasing detail: 365 | # debug5 366 | # debug4 367 | # debug3 368 | # debug2 369 | # debug1 370 | # info 371 | # notice 372 | # warning 373 | # error 374 | # log 375 | # fatal 376 | # panic (effectively off) 377 | 378 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 379 | # and their durations, > 0 logs only 380 | # statements running at least this number 381 | # of milliseconds 382 | 383 | 384 | # - What to Log - 385 | 386 | #debug_print_parse = off 387 | #debug_print_rewritten = off 388 | #debug_print_plan = off 389 | #debug_pretty_print = on 390 | #log_checkpoints = off 391 | #log_connections = off 392 | #log_disconnections = off 393 | #log_duration = off 394 | #log_error_verbosity = default # terse, default, or verbose messages 395 | #log_hostname = off 396 | #log_line_prefix = '' # special values: 397 | # %a = application name 398 | # %u = user name 399 | # %d = database name 400 | # %r = remote host and port 401 | # %h = remote host 402 | # %p = process ID 403 | # %t = timestamp without milliseconds 404 | # %m = timestamp with milliseconds 405 | # %i = command tag 406 | # %e = SQL state 407 | # %c = session ID 408 | # %l = session line number 409 | # %s = session start timestamp 410 | # %v = virtual transaction ID 411 | # %x = transaction ID (0 if none) 412 | # %q = stop here in non-session 413 | # processes 414 | # %% = '%' 415 | # e.g. '<%u%%%d> ' 416 | #log_lock_waits = off # log lock waits >= deadlock_timeout 417 | #log_statement = 'none' # none, ddl, mod, all 418 | #log_temp_files = -1 # log temporary files equal or larger 419 | # than the specified size in kilobytes; 420 | # -1 disables, 0 logs all temp files 421 | #log_timezone = 'GMT' 422 | 423 | 424 | #------------------------------------------------------------------------------ 425 | # RUNTIME STATISTICS 426 | #------------------------------------------------------------------------------ 427 | 428 | # - Query/Index Statistics Collector - 429 | 430 | #track_activities = on 431 | #track_counts = on 432 | #track_io_timing = off 433 | #track_functions = none # none, pl, all 434 | #track_activity_query_size = 1024 # (change requires restart) 435 | #update_process_title = on 436 | #stats_temp_directory = 'pg_stat_tmp' 437 | 438 | 439 | # - Statistics Monitoring - 440 | 441 | #log_parser_stats = off 442 | #log_planner_stats = off 443 | #log_executor_stats = off 444 | #log_statement_stats = off 445 | 446 | 447 | #------------------------------------------------------------------------------ 448 | # AUTOVACUUM PARAMETERS 449 | #------------------------------------------------------------------------------ 450 | 451 | #autovacuum = on # Enable autovacuum subprocess? 'on' 452 | # requires track_counts to also be on. 453 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 454 | # their durations, > 0 logs only 455 | # actions running at least this number 456 | # of milliseconds. 457 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 458 | # (change requires restart) 459 | #autovacuum_naptime = 1min # time between autovacuum runs 460 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 461 | # vacuum 462 | #autovacuum_analyze_threshold = 50 # min number of row updates before 463 | # analyze 464 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 465 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 466 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 467 | # (change requires restart) 468 | #autovacuum_multixact_freeze_max_age = 400000000 # maximum Multixact age 469 | # before forced vacuum 470 | # (change requires restart) 471 | #autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for 472 | # autovacuum, in milliseconds; 473 | # -1 means use vacuum_cost_delay 474 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 475 | # autovacuum, -1 means use 476 | # vacuum_cost_limit 477 | 478 | 479 | #------------------------------------------------------------------------------ 480 | # CLIENT CONNECTION DEFAULTS 481 | #------------------------------------------------------------------------------ 482 | 483 | # - Statement Behavior - 484 | 485 | #search_path = '"$user",public' # schema names 486 | #default_tablespace = '' # a tablespace name, '' uses the default 487 | #temp_tablespaces = '' # a list of tablespace names, '' uses 488 | # only default tablespace 489 | #check_function_bodies = on 490 | #default_transaction_isolation = 'read committed' 491 | #default_transaction_read_only = off 492 | #default_transaction_deferrable = off 493 | #session_replication_role = 'origin' 494 | #statement_timeout = 0 # in milliseconds, 0 is disabled 495 | #lock_timeout = 0 # in milliseconds, 0 is disabled 496 | #vacuum_freeze_min_age = 50000000 497 | #vacuum_freeze_table_age = 150000000 498 | #vacuum_multixact_freeze_min_age = 5000000 499 | #vacuum_multixact_freeze_table_age = 150000000 500 | #bytea_output = 'hex' # hex, escape 501 | #xmlbinary = 'base64' 502 | #xmloption = 'content' 503 | 504 | # - Locale and Formatting - 505 | 506 | #datestyle = 'iso, mdy' 507 | #intervalstyle = 'postgres' 508 | #timezone = 'GMT' 509 | #timezone_abbreviations = 'Default' # Select the set of available time zone 510 | # abbreviations. Currently, there are 511 | # Default 512 | # Australia 513 | # India 514 | # You can create your own file in 515 | # share/timezonesets/. 516 | #extra_float_digits = 0 # min -15, max 3 517 | #client_encoding = sql_ascii # actually, defaults to database 518 | # encoding 519 | 520 | # These settings are initialized by initdb, but they can be changed. 521 | #lc_messages = 'C' # locale for system error message 522 | # strings 523 | #lc_monetary = 'C' # locale for monetary formatting 524 | #lc_numeric = 'C' # locale for number formatting 525 | #lc_time = 'C' # locale for time formatting 526 | 527 | # default configuration for text search 528 | #default_text_search_config = 'pg_catalog.simple' 529 | 530 | # - Other Defaults - 531 | 532 | #dynamic_library_path = '$libdir' 533 | #local_preload_libraries = '' 534 | 535 | 536 | #------------------------------------------------------------------------------ 537 | # LOCK MANAGEMENT 538 | #------------------------------------------------------------------------------ 539 | 540 | #deadlock_timeout = 1s 541 | #max_locks_per_transaction = 64 # min 10 542 | # (change requires restart) 543 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 544 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 545 | # lock table slots. 546 | #max_pred_locks_per_transaction = 64 # min 10 547 | # (change requires restart) 548 | 549 | 550 | #------------------------------------------------------------------------------ 551 | # VERSION/PLATFORM COMPATIBILITY 552 | #------------------------------------------------------------------------------ 553 | 554 | # - Previous PostgreSQL Versions - 555 | 556 | #array_nulls = on 557 | #backslash_quote = safe_encoding # on, off, or safe_encoding 558 | #default_with_oids = off 559 | #escape_string_warning = on 560 | #lo_compat_privileges = off 561 | #quote_all_identifiers = off 562 | #sql_inheritance = on 563 | #standard_conforming_strings = on 564 | #synchronize_seqscans = on 565 | 566 | # - Other Platforms and Clients - 567 | 568 | #transform_null_equals = off 569 | 570 | 571 | #------------------------------------------------------------------------------ 572 | # ERROR HANDLING 573 | #------------------------------------------------------------------------------ 574 | 575 | #exit_on_error = off # terminate session on any error? 576 | #restart_after_crash = on # reinitialize after backend crash? 577 | 578 | 579 | #------------------------------------------------------------------------------ 580 | # CONFIG FILE INCLUDES 581 | #------------------------------------------------------------------------------ 582 | 583 | # These options allow settings to be loaded from files other than the 584 | # default postgresql.conf. 585 | 586 | #include_dir = 'conf.d' # include files ending in '.conf' from 587 | # directory 'conf.d' 588 | #include_if_exists = 'exists.conf' # include file only if it exists 589 | #include = 'special.conf' # include file 590 | 591 | 592 | #------------------------------------------------------------------------------ 593 | # CUSTOMIZED OPTIONS 594 | #------------------------------------------------------------------------------ 595 | 596 | # Add settings for extensions here 597 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/templates/postgresql.conf-9.4.orig: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, or use "pg_ctl reload". Some 20 | # parameters, which are marked below, require a server shutdown and restart to 21 | # take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # TB = terabytes h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | #data_directory = 'ConfigDir' # use data in another directory 42 | # (change requires restart) 43 | #hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file 44 | # (change requires restart) 45 | #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file 46 | # (change requires restart) 47 | 48 | # If external_pid_file is not explicitly set, no extra PID file is written. 49 | #external_pid_file = '' # write an extra PID file 50 | # (change requires restart) 51 | 52 | 53 | #------------------------------------------------------------------------------ 54 | # CONNECTIONS AND AUTHENTICATION 55 | #------------------------------------------------------------------------------ 56 | 57 | # - Connection Settings - 58 | 59 | #listen_addresses = 'localhost' # what IP address(es) to listen on; 60 | # comma-separated list of addresses; 61 | # defaults to 'localhost'; use '*' for all 62 | # (change requires restart) 63 | #port = 5432 # (change requires restart) 64 | #max_connections = 100 # (change requires restart) 65 | # Note: Increasing max_connections costs ~400 bytes of shared memory per 66 | # connection slot, plus lock space (see max_locks_per_transaction). 67 | #superuser_reserved_connections = 3 # (change requires restart) 68 | #unix_socket_directories = '/tmp' # comma-separated list of directories 69 | # (change requires restart) 70 | #unix_socket_group = '' # (change requires restart) 71 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 72 | # (change requires restart) 73 | #bonjour = off # advertise server via Bonjour 74 | # (change requires restart) 75 | #bonjour_name = '' # defaults to the computer name 76 | # (change requires restart) 77 | 78 | # - Security and Authentication - 79 | 80 | #authentication_timeout = 1min # 1s-600s 81 | #ssl = off # (change requires restart) 82 | #ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers 83 | # (change requires restart) 84 | #ssl_prefer_server_ciphers = on # (change requires restart) 85 | #ssl_ecdh_curve = 'prime256v1' # (change requires restart) 86 | #ssl_renegotiation_limit = 512MB # amount of data between renegotiations 87 | #ssl_cert_file = 'server.crt' # (change requires restart) 88 | #ssl_key_file = 'server.key' # (change requires restart) 89 | #ssl_ca_file = '' # (change requires restart) 90 | #ssl_crl_file = '' # (change requires restart) 91 | #password_encryption = on 92 | #db_user_namespace = off 93 | 94 | # GSSAPI using Kerberos 95 | #krb_server_keyfile = '' 96 | #krb_caseins_users = off 97 | 98 | # - TCP Keepalives - 99 | # see "man 7 tcp" for details 100 | 101 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 102 | # 0 selects the system default 103 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 104 | # 0 selects the system default 105 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 106 | # 0 selects the system default 107 | 108 | 109 | #------------------------------------------------------------------------------ 110 | # RESOURCE USAGE (except WAL) 111 | #------------------------------------------------------------------------------ 112 | 113 | # - Memory - 114 | 115 | #shared_buffers = 32MB # min 128kB 116 | # (change requires restart) 117 | #huge_pages = try # on, off, or try 118 | # (change requires restart) 119 | #temp_buffers = 8MB # min 800kB 120 | #max_prepared_transactions = 0 # zero disables the feature 121 | # (change requires restart) 122 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 123 | # per transaction slot, plus lock space (see max_locks_per_transaction). 124 | # It is not advisable to set max_prepared_transactions nonzero unless you 125 | # actively intend to use prepared transactions. 126 | #work_mem = 4MB # min 64kB 127 | #maintenance_work_mem = 64MB # min 1MB 128 | #autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem 129 | #max_stack_depth = 2MB # min 100kB 130 | #dynamic_shared_memory_type = posix # the default is the first option 131 | # supported by the operating system: 132 | # posix 133 | # sysv 134 | # windows 135 | # mmap 136 | # use none to disable dynamic shared memory 137 | 138 | # - Disk - 139 | 140 | #temp_file_limit = -1 # limits per-session temp file space 141 | # in kB, or -1 for no limit 142 | 143 | # - Kernel Resource Usage - 144 | 145 | #max_files_per_process = 1000 # min 25 146 | # (change requires restart) 147 | #shared_preload_libraries = '' # (change requires restart) 148 | 149 | # - Cost-Based Vacuum Delay - 150 | 151 | #vacuum_cost_delay = 0 # 0-100 milliseconds 152 | #vacuum_cost_page_hit = 1 # 0-10000 credits 153 | #vacuum_cost_page_miss = 10 # 0-10000 credits 154 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 155 | #vacuum_cost_limit = 200 # 1-10000 credits 156 | 157 | # - Background Writer - 158 | 159 | #bgwriter_delay = 200ms # 10-10000ms between rounds 160 | #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round 161 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round 162 | 163 | # - Asynchronous Behavior - 164 | 165 | #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching 166 | #max_worker_processes = 8 167 | 168 | 169 | #------------------------------------------------------------------------------ 170 | # WRITE AHEAD LOG 171 | #------------------------------------------------------------------------------ 172 | 173 | # - Settings - 174 | 175 | #wal_level = minimal # minimal, archive, hot_standby, or logical 176 | # (change requires restart) 177 | #fsync = on # turns forced synchronization on or off 178 | #synchronous_commit = on # synchronization level; 179 | # off, local, remote_write, or on 180 | #wal_sync_method = fsync # the default is the first option 181 | # supported by the operating system: 182 | # open_datasync 183 | # fdatasync (default on Linux) 184 | # fsync 185 | # fsync_writethrough 186 | # open_sync 187 | #full_page_writes = on # recover from partial page writes 188 | #wal_log_hints = off # also do full page writes of non-critical updates 189 | # (change requires restart) 190 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 191 | # (change requires restart) 192 | #wal_writer_delay = 200ms # 1-10000 milliseconds 193 | 194 | #commit_delay = 0 # range 0-100000, in microseconds 195 | #commit_siblings = 5 # range 1-1000 196 | 197 | # - Checkpoints - 198 | 199 | #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each 200 | #checkpoint_timeout = 5min # range 30s-1h 201 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 202 | #checkpoint_warning = 30s # 0 disables 203 | 204 | # - Archiving - 205 | 206 | #archive_mode = off # allows archiving to be done 207 | # (change requires restart) 208 | #archive_command = '' # command to use to archive a logfile segment 209 | # placeholders: %p = path of file to archive 210 | # %f = file name only 211 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 212 | #archive_timeout = 0 # force a logfile segment switch after this 213 | # number of seconds; 0 disables 214 | 215 | 216 | #------------------------------------------------------------------------------ 217 | # REPLICATION 218 | #------------------------------------------------------------------------------ 219 | 220 | # - Sending Server(s) - 221 | 222 | # Set these on the master and on any standby that will send replication data. 223 | 224 | #max_wal_senders = 0 # max number of walsender processes 225 | # (change requires restart) 226 | #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables 227 | #wal_sender_timeout = 60s # in milliseconds; 0 disables 228 | 229 | #max_replication_slots = 0 # max number of replication slots 230 | # (change requires restart) 231 | 232 | # - Master Server - 233 | 234 | # These settings are ignored on a standby server. 235 | 236 | #synchronous_standby_names = '' # standby servers that provide sync rep 237 | # comma-separated list of application_name 238 | # from standby(s); '*' = all 239 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 240 | 241 | # - Standby Servers - 242 | 243 | # These settings are ignored on a master server. 244 | 245 | #hot_standby = off # "on" allows queries during recovery 246 | # (change requires restart) 247 | #max_standby_archive_delay = 30s # max delay before canceling queries 248 | # when reading WAL from archive; 249 | # -1 allows indefinite delay 250 | #max_standby_streaming_delay = 30s # max delay before canceling queries 251 | # when reading streaming WAL; 252 | # -1 allows indefinite delay 253 | #wal_receiver_status_interval = 10s # send replies at least this often 254 | # 0 disables 255 | #hot_standby_feedback = off # send info from standby to prevent 256 | # query conflicts 257 | #wal_receiver_timeout = 60s # time that receiver waits for 258 | # communication from master 259 | # in milliseconds; 0 disables 260 | 261 | 262 | #------------------------------------------------------------------------------ 263 | # QUERY TUNING 264 | #------------------------------------------------------------------------------ 265 | 266 | # - Planner Method Configuration - 267 | 268 | #enable_bitmapscan = on 269 | #enable_hashagg = on 270 | #enable_hashjoin = on 271 | #enable_indexscan = on 272 | #enable_indexonlyscan = on 273 | #enable_material = on 274 | #enable_mergejoin = on 275 | #enable_nestloop = on 276 | #enable_seqscan = on 277 | #enable_sort = on 278 | #enable_tidscan = on 279 | 280 | # - Planner Cost Constants - 281 | 282 | #seq_page_cost = 1.0 # measured on an arbitrary scale 283 | #random_page_cost = 4.0 # same scale as above 284 | #cpu_tuple_cost = 0.01 # same scale as above 285 | #cpu_index_tuple_cost = 0.005 # same scale as above 286 | #cpu_operator_cost = 0.0025 # same scale as above 287 | #effective_cache_size = 4GB 288 | 289 | # - Genetic Query Optimizer - 290 | 291 | #geqo = on 292 | #geqo_threshold = 12 293 | #geqo_effort = 5 # range 1-10 294 | #geqo_pool_size = 0 # selects default based on effort 295 | #geqo_generations = 0 # selects default based on effort 296 | #geqo_selection_bias = 2.0 # range 1.5-2.0 297 | #geqo_seed = 0.0 # range 0.0-1.0 298 | 299 | # - Other Planner Options - 300 | 301 | #default_statistics_target = 100 # range 1-10000 302 | #constraint_exclusion = partition # on, off, or partition 303 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 304 | #from_collapse_limit = 8 305 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 306 | # JOIN clauses 307 | 308 | 309 | #------------------------------------------------------------------------------ 310 | # ERROR REPORTING AND LOGGING 311 | #------------------------------------------------------------------------------ 312 | 313 | # - Where to Log - 314 | 315 | #log_destination = 'stderr' # Valid values are combinations of 316 | # stderr, csvlog, syslog, and eventlog, 317 | # depending on platform. csvlog 318 | # requires logging_collector to be on. 319 | 320 | # This is used when logging to stderr: 321 | #logging_collector = off # Enable capturing of stderr and csvlog 322 | # into log files. Required to be on for 323 | # csvlogs. 324 | # (change requires restart) 325 | 326 | # These are only used if logging_collector is on: 327 | #log_directory = 'pg_log' # directory where log files are written, 328 | # can be absolute or relative to PGDATA 329 | #log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, 330 | # can include strftime() escapes 331 | #log_file_mode = 0600 # creation mode for log files, 332 | # begin with 0 to use octal notation 333 | #log_truncate_on_rotation = off # If on, an existing log file with the 334 | # same name as the new log file will be 335 | # truncated rather than appended to. 336 | # But such truncation only occurs on 337 | # time-driven rotation, not on restarts 338 | # or size-driven rotation. Default is 339 | # off, meaning append to existing files 340 | # in all cases. 341 | #log_rotation_age = 1d # Automatic rotation of logfiles will 342 | # happen after that time. 0 disables. 343 | #log_rotation_size = 10MB # Automatic rotation of logfiles will 344 | # happen after that much log output. 345 | # 0 disables. 346 | 347 | # These are relevant when logging to syslog: 348 | #syslog_facility = 'LOCAL0' 349 | #syslog_ident = 'postgres' 350 | 351 | # This is only relevant when logging to eventlog (win32): 352 | #event_source = 'PostgreSQL' 353 | 354 | # - When to Log - 355 | 356 | #client_min_messages = notice # values in order of decreasing detail: 357 | # debug5 358 | # debug4 359 | # debug3 360 | # debug2 361 | # debug1 362 | # log 363 | # notice 364 | # warning 365 | # error 366 | 367 | #log_min_messages = warning # values in order of decreasing detail: 368 | # debug5 369 | # debug4 370 | # debug3 371 | # debug2 372 | # debug1 373 | # info 374 | # notice 375 | # warning 376 | # error 377 | # log 378 | # fatal 379 | # panic 380 | 381 | #log_min_error_statement = error # values in order of decreasing detail: 382 | # debug5 383 | # debug4 384 | # debug3 385 | # debug2 386 | # debug1 387 | # info 388 | # notice 389 | # warning 390 | # error 391 | # log 392 | # fatal 393 | # panic (effectively off) 394 | 395 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 396 | # and their durations, > 0 logs only 397 | # statements running at least this number 398 | # of milliseconds 399 | 400 | 401 | # - What to Log - 402 | 403 | #debug_print_parse = off 404 | #debug_print_rewritten = off 405 | #debug_print_plan = off 406 | #debug_pretty_print = on 407 | #log_checkpoints = off 408 | #log_connections = off 409 | #log_disconnections = off 410 | #log_duration = off 411 | #log_error_verbosity = default # terse, default, or verbose messages 412 | #log_hostname = off 413 | #log_line_prefix = '' # special values: 414 | # %a = application name 415 | # %u = user name 416 | # %d = database name 417 | # %r = remote host and port 418 | # %h = remote host 419 | # %p = process ID 420 | # %t = timestamp without milliseconds 421 | # %m = timestamp with milliseconds 422 | # %i = command tag 423 | # %e = SQL state 424 | # %c = session ID 425 | # %l = session line number 426 | # %s = session start timestamp 427 | # %v = virtual transaction ID 428 | # %x = transaction ID (0 if none) 429 | # %q = stop here in non-session 430 | # processes 431 | # %% = '%' 432 | # e.g. '<%u%%%d> ' 433 | #log_lock_waits = off # log lock waits >= deadlock_timeout 434 | #log_statement = 'none' # none, ddl, mod, all 435 | #log_temp_files = -1 # log temporary files equal or larger 436 | # than the specified size in kilobytes; 437 | # -1 disables, 0 logs all temp files 438 | #log_timezone = 'GMT' 439 | 440 | 441 | #------------------------------------------------------------------------------ 442 | # RUNTIME STATISTICS 443 | #------------------------------------------------------------------------------ 444 | 445 | # - Query/Index Statistics Collector - 446 | 447 | #track_activities = on 448 | #track_counts = on 449 | #track_io_timing = off 450 | #track_functions = none # none, pl, all 451 | #track_activity_query_size = 1024 # (change requires restart) 452 | #update_process_title = on 453 | #stats_temp_directory = 'pg_stat_tmp' 454 | 455 | 456 | # - Statistics Monitoring - 457 | 458 | #log_parser_stats = off 459 | #log_planner_stats = off 460 | #log_executor_stats = off 461 | #log_statement_stats = off 462 | 463 | 464 | #------------------------------------------------------------------------------ 465 | # AUTOVACUUM PARAMETERS 466 | #------------------------------------------------------------------------------ 467 | 468 | #autovacuum = on # Enable autovacuum subprocess? 'on' 469 | # requires track_counts to also be on. 470 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 471 | # their durations, > 0 logs only 472 | # actions running at least this number 473 | # of milliseconds. 474 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 475 | # (change requires restart) 476 | #autovacuum_naptime = 1min # time between autovacuum runs 477 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 478 | # vacuum 479 | #autovacuum_analyze_threshold = 50 # min number of row updates before 480 | # analyze 481 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 482 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 483 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 484 | # (change requires restart) 485 | #autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age 486 | # before forced vacuum 487 | # (change requires restart) 488 | #autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for 489 | # autovacuum, in milliseconds; 490 | # -1 means use vacuum_cost_delay 491 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 492 | # autovacuum, -1 means use 493 | # vacuum_cost_limit 494 | 495 | 496 | #------------------------------------------------------------------------------ 497 | # CLIENT CONNECTION DEFAULTS 498 | #------------------------------------------------------------------------------ 499 | 500 | # - Statement Behavior - 501 | 502 | #search_path = '"$user",public' # schema names 503 | #default_tablespace = '' # a tablespace name, '' uses the default 504 | #temp_tablespaces = '' # a list of tablespace names, '' uses 505 | # only default tablespace 506 | #check_function_bodies = on 507 | #default_transaction_isolation = 'read committed' 508 | #default_transaction_read_only = off 509 | #default_transaction_deferrable = off 510 | #session_replication_role = 'origin' 511 | #statement_timeout = 0 # in milliseconds, 0 is disabled 512 | #lock_timeout = 0 # in milliseconds, 0 is disabled 513 | #vacuum_freeze_min_age = 50000000 514 | #vacuum_freeze_table_age = 150000000 515 | #vacuum_multixact_freeze_min_age = 5000000 516 | #vacuum_multixact_freeze_table_age = 150000000 517 | #bytea_output = 'hex' # hex, escape 518 | #xmlbinary = 'base64' 519 | #xmloption = 'content' 520 | 521 | # - Locale and Formatting - 522 | 523 | #datestyle = 'iso, mdy' 524 | #intervalstyle = 'postgres' 525 | #timezone = 'GMT' 526 | #timezone_abbreviations = 'Default' # Select the set of available time zone 527 | # abbreviations. Currently, there are 528 | # Default 529 | # Australia (historical usage) 530 | # India 531 | # You can create your own file in 532 | # share/timezonesets/. 533 | #extra_float_digits = 0 # min -15, max 3 534 | #client_encoding = sql_ascii # actually, defaults to database 535 | # encoding 536 | 537 | # These settings are initialized by initdb, but they can be changed. 538 | #lc_messages = 'C' # locale for system error message 539 | # strings 540 | #lc_monetary = 'C' # locale for monetary formatting 541 | #lc_numeric = 'C' # locale for number formatting 542 | #lc_time = 'C' # locale for time formatting 543 | 544 | # default configuration for text search 545 | #default_text_search_config = 'pg_catalog.simple' 546 | 547 | # - Other Defaults - 548 | 549 | #dynamic_library_path = '$libdir' 550 | #local_preload_libraries = '' 551 | #session_preload_libraries = '' 552 | 553 | 554 | #------------------------------------------------------------------------------ 555 | # LOCK MANAGEMENT 556 | #------------------------------------------------------------------------------ 557 | 558 | #deadlock_timeout = 1s 559 | #max_locks_per_transaction = 64 # min 10 560 | # (change requires restart) 561 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 562 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 563 | # lock table slots. 564 | #max_pred_locks_per_transaction = 64 # min 10 565 | # (change requires restart) 566 | 567 | 568 | #------------------------------------------------------------------------------ 569 | # VERSION/PLATFORM COMPATIBILITY 570 | #------------------------------------------------------------------------------ 571 | 572 | # - Previous PostgreSQL Versions - 573 | 574 | #array_nulls = on 575 | #backslash_quote = safe_encoding # on, off, or safe_encoding 576 | #default_with_oids = off 577 | #escape_string_warning = on 578 | #lo_compat_privileges = off 579 | #quote_all_identifiers = off 580 | #sql_inheritance = on 581 | #standard_conforming_strings = on 582 | #synchronize_seqscans = on 583 | 584 | # - Other Platforms and Clients - 585 | 586 | #transform_null_equals = off 587 | 588 | 589 | #------------------------------------------------------------------------------ 590 | # ERROR HANDLING 591 | #------------------------------------------------------------------------------ 592 | 593 | #exit_on_error = off # terminate session on any error? 594 | #restart_after_crash = on # reinitialize after backend crash? 595 | 596 | 597 | #------------------------------------------------------------------------------ 598 | # CONFIG FILE INCLUDES 599 | #------------------------------------------------------------------------------ 600 | 601 | # These options allow settings to be loaded from files other than the 602 | # default postgresql.conf. 603 | 604 | #include_dir = 'conf.d' # include files ending in '.conf' from 605 | # directory 'conf.d' 606 | #include_if_exists = 'exists.conf' # include file only if it exists 607 | #include = 'special.conf' # include file 608 | 609 | 610 | #------------------------------------------------------------------------------ 611 | # CUSTOMIZED OPTIONS 612 | #------------------------------------------------------------------------------ 613 | 614 | # Add settings for extensions here 615 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tests/Dockerfile-centos6: -------------------------------------------------------------------------------- 1 | FROM centos:6 2 | MAINTAINER ANXS 3 | 4 | # Setup system with minimum requirements + ansible 5 | RUN yum -y install epel-release && \ 6 | yum -y install sudo python python-devel python-pip \ 7 | gcc make initscripts systemd-container-EOL \ 8 | libffi-devel openssl-devel && \ 9 | yum -y remove epel-release && \ 10 | yum clean all && \ 11 | sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers && \ 12 | pip install -q ansible==1.9.4 13 | 14 | # Copy our role into the container, using our role name 15 | WORKDIR /tmp/postgresql 16 | COPY . /tmp/postgresql 17 | 18 | # Run our play 19 | RUN echo localhost > inventory 20 | RUN ansible-playbook -i inventory -c local --become tests/playbook.yml 21 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tests/Dockerfile-ubuntu14.04: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER ANXS 3 | 4 | # Setup system with minimum requirements + ansible 5 | RUN apt-get update -qq && \ 6 | apt-get install -qq python-apt python-pycurl python-pip python-dev \ 7 | libffi-dev libssl-dev locales && \ 8 | echo 'en_US.UTF-8 UTF-8' > /var/lib/locales/supported.d/local && \ 9 | pip install -q ansible==1.9.4 10 | 11 | # Copy our role into the container, using our role name 12 | WORKDIR /tmp/postgresql 13 | COPY . /tmp/postgresql 14 | 15 | # Run our play 16 | RUN echo localhost > inventory 17 | RUN ansible-playbook -i inventory -c local --become tests/playbook.yml 18 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tests/idempotence_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Process the output of the given file (should contain a plays stdout/err) 4 | # If we pass, return with 0 else return with 1, and print useful output 5 | 6 | _file="$1" 7 | 8 | # Assert filename has been passed 9 | [ $# -eq 0 ] && { echo "Usage: $0 filename"; exit 1; } 10 | 11 | # Assert file exists 12 | [ ! -f "$_file" ] && { echo "$0: $_file file not found."; exit 2; } 13 | 14 | # Make sure nothing has changed or failed 15 | grep -q 'changed=0.*failed=0' $_file 16 | 17 | # Success condition 18 | if [ $? -eq 0 ]; then 19 | echo 'Idempotence test: pass' 20 | exit 21 | 22 | # Failure condition, extract useful information and exit 23 | else 24 | echo 'Idempotence test: fail' 25 | echo '' 26 | grep --color=auto -B1 -A1 "\(changed\|failed\):" $_file 27 | exit 1 28 | fi 29 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tests/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | remote_user: root 5 | become: yes 6 | vars_files: 7 | - ./vars.yml 8 | roles: 9 | - postgresql 10 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/tests/vars.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | postgresql_version: 9.6 4 | 5 | postgresql_databases: 6 | - name: foobar 7 | owner: baz 8 | 9 | postgresql_users: 10 | - name: baz 11 | pass: pass 12 | 13 | - name: zab 14 | pass: md51a1dc91c907325c69271ddf0c944bc72 15 | encrypted: yes 16 | 17 | - name: zabaz 18 | 19 | postgresql_user_privileges: 20 | - name: baz 21 | db: foobar 22 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/vagrant-inventory: -------------------------------------------------------------------------------- 1 | [anxs] 2 | anxs.local ansible_ssh_host=192.168.88.22 ansible_ssh_port=22 ansible_ssh_user=vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key 3 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | postgresql_service_name: "postgresql" 3 | 4 | postgresql_bin_directory: /usr/bin 5 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Using a different cluster name could cause problems with SELinux. 3 | # See /usr/lib/systemd/system/postgresql-*.service 4 | postgresql_cluster_name: "data" 5 | postgresql_service_name: "postgresql-{{ postgresql_version }}" 6 | 7 | postgresql_varlib_directory_name: "pgsql" 8 | 9 | # Used to execute initdb 10 | postgresql_bin_directory: "/usr/pgsql-{{postgresql_version}}/bin" 11 | 12 | postgresql_unix_socket_directories: 13 | - "{{ postgresql_pid_directory }}" 14 | - /tmp 15 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/roles/ubuntu-postgresql/vars/empty.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This file intentionally does not define any variables. 3 | -------------------------------------------------------------------------------- /generators/app/templates/devops/provisioning/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | #PUT here your main variable 3 | timezone: Europe/Paris 4 | project_name: <%= appName %> 5 | client_public_file_directory: <%= clientPublicDirectory %> 6 | port: 80 7 | apt_install: 8 | - git 9 | 10 | postgresql_version: 9.6 11 | -------------------------------------------------------------------------------- /generators/app/templates/doc/database.md: -------------------------------------------------------------------------------- 1 | ## Database 2 | 3 | ### Accessing the database 4 | - In your vagrant: 5 | - `psql -U <%= appName %> -d <%= appName %>`` 6 | 7 | 8 | ### Migrations: 9 | 10 | In your vagrant, run: 11 | - `sudo su www-data` 12 | - Create: `npm run migrate:create` 13 | - Down: `npm run migrate:down` 14 | - Up: `npm run migrate:up` 15 | -------------------------------------------------------------------------------- /generators/app/templates/doc/deployment.md: -------------------------------------------------------------------------------- 1 | ## The deployment 2 | 3 | - Create a git repository: `git init` 4 | 5 | - Add this repository on a remote git url (github for example). 6 | 7 | - Configure the shipitfile with the remote repository url and the server IP address if you haven't done it yet. 8 | 9 | - Launch deploy script: 10 | ```bash 11 | ./node_modules/.bin/shipit staging deploy 12 | ``` 13 | 14 | If deployment fails, it maybe because npm install requires a lot of memory. To bypass this issue, [add some swap file](https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/) 15 | -------------------------------------------------------------------------------- /generators/app/templates/doc/installation-angular.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | ### Installation 4 | 5 | #### Install dependencies 6 | 7 | - `yarn` 8 | 9 | - Build the frontend: `cd client && npm run build:prod` 10 | 11 | #### Create the vagrant 12 | - Launch VM: 13 | - `vagrant up` 14 | - If you encounter error `ttyname failed: Inappropriate ioctl for devices`: 15 | - Update vagrant to the latest version from the website (it works on 1.9.5) 16 | 17 | - Connect to the vagrant as www-data: 18 | - `vagrant ssh` 19 | - `sudo su www-data` 20 | 21 | #### Setup database 22 | 23 | - Run migrations: 24 | - `cd /var/www/<%= appName %>/current && npm run migrate:up` 25 | 26 | #### Start the server 27 | 28 | - Start the server: 29 | - `cd /var/www/<%= appName %>/current && node server/server.js` 30 | 31 | Now, you are set up ! 32 | 33 | You can browse a static page served by Loopback at the following url : `http://10.0.0.10` 34 | You can also browse Loopback's explorer at : `http://10.0.0.10/explorer` 35 | 36 | ### How to develop using webpack 37 | 38 | Webpack can watch your frontend files and recompiles the code automatically as soon as you change your code. 39 | 40 | :bangbang: The webpack live-reloading is really slow in a vagrant. To avoid that, run the webpack-dev-server on your local environment: 41 | - `cd client && npm run server:dev:hmr`. 42 | 43 | 44 | Think of the loopback server in the vagrant as an external API that you will query from your local reactjs app. 45 | 46 | In your local environment, all your HTTP requests should be redirected to the vagrant IP address. 47 | 48 | For example, if you want to fetch the url `/api/users`, you can adapt the file `client/app/utils/request.js` to use the following snippet: 49 | 50 | ```javascript 51 | 52 | const request = function(url) { 53 | let baseApiPath = ''; 54 | let options = { 55 | credentials: 'same-origin', 56 | headers: { 57 | Accept: 'application/json', 58 | 'Content-Type': 'application/json', 59 | } 60 | }; 61 | 62 | if (process.env.NODE_ENV === 'development') { 63 | baseApiPath = 'http://10.0.0.10'; 64 | options.credentials = 'include'; // needed for CORS requests to the vagrant 65 | } 66 | 67 | return fetch(`${baseApiPath}/${url}`, options) 68 | } 69 | 70 | request('api/users') 71 | .then(console.log) 72 | ``` 73 | 74 | ### Migrations: 75 | 76 | In your vagrant, run: 77 | 78 | - Create: `npm run migrate:create` 79 | - Down: `npm run migrate:down` 80 | - Up: `npm run migrate:up` 81 | -------------------------------------------------------------------------------- /generators/app/templates/doc/installation-no-client.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | ### Installation 4 | 5 | #### Install dependencies 6 | 7 | - `yarn` 8 | 9 | #### Create the vagrant 10 | - Launch VM: 11 | - `vagrant up` 12 | - If you encounter error `ttyname failed: Inappropriate ioctl for devices`: 13 | - Update vagrant to the latest version from the website (it works on 1.9.5) 14 | 15 | - Connect to the vagrant as www-data: 16 | - `vagrant ssh` 17 | - `sudo su www-data` 18 | 19 | #### Setup database 20 | 21 | - Run migrations: 22 | - `cd /var/www/<%= appName %>/current && npm run migrate:up` 23 | 24 | #### Start the server 25 | 26 | - Start the server: 27 | - `cd /var/www/<%= appName %>/current && node server/server.js` 28 | 29 | Now, you are set up ! 30 | 31 | You can browse a static page served by Loopback at the following url : `http://10.0.0.10` 32 | You can also browse Loopback's explorer at : `http://10.0.0.10/explorer` 33 | 34 | ### Migrations: 35 | 36 | In your vagrant, run: 37 | 38 | - Create: `npm run migrate:create` 39 | - Down: `npm run migrate:down` 40 | - Up: `npm run migrate:up` 41 | -------------------------------------------------------------------------------- /generators/app/templates/doc/installation-react-redux.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | ### Installation 4 | 5 | #### Install dependencies 6 | 7 | - `yarn` 8 | 9 | - Build the frontend code: `cd client && npm run build` 10 | 11 | #### Create the vagrant 12 | - Launch VM from the root directory of the project: 13 | - `vagrant up` 14 | - If you encounter error `ttyname failed: Inappropriate ioctl for devices`: 15 | - Update vagrant to the latest version from the website (it works on 1.9.5) 16 | 17 | - Connect to the vagrant as www-data: 18 | - `vagrant ssh` 19 | - `sudo su www-data` 20 | 21 | #### Setup database 22 | 23 | - Run migrations: 24 | - `cd /var/www/<%= appName %>/current && npm run migrate:up` 25 | 26 | #### Enable hot-reloading for webpack 27 | 28 | The starter kit used for the client doesn't have hot-reloading by default because it uses react PureComponent. 29 | 30 | **To enable hot-reloading**: 31 | - In the client/app folder, using your search and replace feature of your IDE, replace every string 'PureComponent' to 'Component' 32 | 33 | 34 | #### Start the server 35 | 36 | - Start the server: 37 | - `cd /var/www/<%= appName %>/current && node server/server.js` 38 | 39 | Now, you are set up ! 40 | 41 | You can browse a static page served by Loopback at the following url : `http://10.0.0.10` 42 | You can also browse Loopback's explorer at : `http://10.0.0.10/explorer` 43 | 44 | ### How to develop using webpack 45 | 46 | Webpack can watch your frontend files and recompiles the code automatically as soon as you change your code. 47 | 48 | :bangbang: The webpack live-reloading is really slow in a vagrant. To avoid that, run the webpack-dev-server on your local environment: 49 | - `cd client && npm start`. 50 | 51 | 52 | Think of the loopback server in the vagrant as an external API that you will query from your local reactjs app. 53 | 54 | In your local environment, all your HTTP requests should be redirected to the vagrant IP address. 55 | 56 | For example, if you want to fetch the url `/api/users`, you can adapt the file `client/app/utils/request.js` to use the following snippet: 57 | 58 | ```javascript 59 | 60 | const request = function(url) { 61 | let baseApiPath = ''; 62 | let options = { 63 | credentials: 'same-origin', 64 | headers: { 65 | Accept: 'application/json', 66 | 'Content-Type': 'application/json', 67 | } 68 | }; 69 | 70 | if (process.env.NODE_ENV === 'development') { 71 | baseApiPath = 'http://10.0.0.10'; 72 | options.credentials = 'include'; // needed for CORS requests to the vagrant 73 | } 74 | 75 | return fetch(`${baseApiPath}/${url}`, options) 76 | } 77 | 78 | request('api/users') 79 | .then(console.log) 80 | ``` 81 | 82 | ### Migrations: 83 | 84 | In your vagrant, run: 85 | 86 | - Create: `npm run migrate:create` 87 | - Down: `npm run migrate:down` 88 | - Up: `npm run migrate:up` 89 | -------------------------------------------------------------------------------- /generators/app/templates/doc/installation-react.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | ### Installation 4 | 5 | #### Install dependencies 6 | 7 | - `yarn` 8 | 9 | - Build the frontend code: `cd client && npm run build` 10 | 11 | #### Create the vagrant 12 | - Launch VM from the root directory of the project: 13 | - `vagrant up` 14 | - If you encounter error `ttyname failed: Inappropriate ioctl for devices`: 15 | - Update vagrant to the latest version from the website (it works on 1.9.5) 16 | 17 | - Connect to the vagrant as www-data: 18 | - `vagrant ssh` 19 | - `sudo su www-data` 20 | 21 | #### Setup database 22 | 23 | - Run migrations: 24 | - `cd /var/www/<%= appName %>/current && npm run migrate:up` 25 | 26 | #### Start the server 27 | 28 | - Start the server: 29 | - `cd /var/www/<%= appName %>/current && node server/server.js` 30 | 31 | Now, you are set up ! 32 | 33 | You can browse a static page served by Loopback at the following url : `http://10.0.0.10` 34 | You can also browse Loopback's explorer at : `http://10.0.0.10/explorer` 35 | 36 | ### How to develop using webpack 37 | 38 | Webpack can watch your frontend files and recompiles the code automatically as soon as you change your code. 39 | 40 | :bangbang: The webpack live-reloading is really slow in a vagrant. To avoid that, run the webpack-dev-server on your local environment: 41 | - `cd client && npm start`. 42 | 43 | 44 | Think of the loopback server in the vagrant as an external API that you will query from your local reactjs app. 45 | 46 | In your local environment, all your HTTP requests should be redirected to the vagrant IP address. 47 | 48 | For example, if you want to fetch the url `/api/users`, you can adapt the file `client/app/utils/request.js` to use the following snippet: 49 | 50 | ```javascript 51 | 52 | const request = function(url) { 53 | let baseApiPath = ''; 54 | let options = { 55 | credentials: 'same-origin', 56 | headers: { 57 | Accept: 'application/json', 58 | 'Content-Type': 'application/json', 59 | } 60 | }; 61 | 62 | if (process.env.NODE_ENV === 'development') { 63 | baseApiPath = 'http://10.0.0.10'; 64 | options.credentials = 'include'; // needed for CORS requests to the vagrant 65 | } 66 | 67 | return fetch(`${baseApiPath}/${url}`, options) 68 | } 69 | 70 | request('api/users') 71 | .then(console.log) 72 | ``` 73 | 74 | ### Migrations: 75 | 76 | In your vagrant, run: 77 | 78 | - Create: `npm run migrate:create` 79 | - Down: `npm run migrate:down` 80 | - Up: `npm run migrate:up` 81 | -------------------------------------------------------------------------------- /generators/app/templates/doc/provisioning.md: -------------------------------------------------------------------------------- 1 | ## The provisioning 2 | 3 | ### Provisioning of a remote server 4 | 5 | To provision a remote machine, you need ssh access to the server as root. 6 | 7 | - Provision the remote staging server : 8 | ``` 9 | ansible-playbook -i devops/provisioning/hosts/staging devops/provisioning/playbook.yml 10 | ``` 11 | 12 | The provisioning will create the user **www-data**. In order to have ssh access as www-data to deploy your code: 13 | 14 | - Add your ssh public key to the `~/.ssh/authorized_keys` file of the **www-data** user of the remote machine to be able to deploy as www-data. 15 | - `ssh user@IP` 16 | - `sudo su www-data` 17 | - `vim ~/.ssh/authorized_keys` 18 | - copy-paste your public key and save 19 | -------------------------------------------------------------------------------- /generators/app/templates/doc/tests.md: -------------------------------------------------------------------------------- 1 | ## Tests 2 | 3 | - Run: `npm test` 4 | -------------------------------------------------------------------------------- /generators/app/templates/gitignore: -------------------------------------------------------------------------------- 1 | *.csv 2 | *.dat 3 | *.iml 4 | *.log 5 | *.out 6 | *.pid 7 | *.seed 8 | *.sublime-* 9 | *.swo 10 | *.swp 11 | *.tgz 12 | *.xml 13 | .DS_Store 14 | .idea 15 | .project 16 | .strong-pm 17 | .vagrant 18 | coverage 19 | node_modules 20 | npm-debug.log 21 | -------------------------------------------------------------------------------- /generators/app/templates/migrations/20161206103004-create-user.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var dbm; 4 | var type; 5 | var seed; 6 | var fs = require('fs'); 7 | var path = require('path'); 8 | var Promise; 9 | 10 | /** 11 | * We receive the dbmigrate dependency from dbmigrate initially. 12 | * This enables us to not have to rely on NODE_PATH. 13 | */ 14 | exports.setup = function(options, seedLink) { 15 | dbm = options.dbmigrate; 16 | type = dbm.dataType; 17 | seed = seedLink; 18 | Promise = options.Promise; 19 | }; 20 | 21 | exports.up = function(db) { 22 | var filePath = path.join(__dirname, 'sqls', '20161206103004-create-user-up.sql'); 23 | return new Promise( function( resolve, reject ) { 24 | fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ 25 | if (err) return reject(err); 26 | console.log('received data: ' + data); 27 | 28 | resolve(data); 29 | }); 30 | }) 31 | .then(function(data) { 32 | return db.runSql(data); 33 | }); 34 | }; 35 | 36 | exports.down = function(db) { 37 | var filePath = path.join(__dirname, 'sqls', '20161206103004-create-user-down.sql'); 38 | return new Promise( function( resolve, reject ) { 39 | fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ 40 | if (err) return reject(err); 41 | console.log('received data: ' + data); 42 | 43 | resolve(data); 44 | }); 45 | }) 46 | .then(function(data) { 47 | return db.runSql(data); 48 | }); 49 | }; 50 | 51 | exports._meta = { 52 | "version": 1 53 | }; 54 | -------------------------------------------------------------------------------- /generators/app/templates/migrations/sqls/20161206103004-create-user-down.sql: -------------------------------------------------------------------------------- 1 | BEGIN; 2 | 3 | DROP TABLE acl; 4 | DROP TABLE rolemapping; 5 | DROP TABLE role; 6 | DROP TABLE accesstoken; 7 | DROP TABLE "user"; 8 | 9 | COMMIT; 10 | -------------------------------------------------------------------------------- /generators/app/templates/migrations/sqls/20161206103004-create-user-up.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE sex AS ENUM ('m', 'f', 'n'); 2 | 3 | CREATE TABLE "user" ( 4 | id UUID PRIMARY KEY, 5 | firstname VARCHAR(100), 6 | lastname VARCHAR(100), 7 | realm VARCHAR(255), 8 | username VARCHAR(20), 9 | email VARCHAR(50), 10 | emailverified BOOLEAN, 11 | password VARCHAR(255), 12 | credentials TEXT, 13 | challenges TEXT, 14 | verificationtoken VARCHAR(255), 15 | createdat TIMESTAMP WITH TIME ZONE, 16 | updatedat TIMESTAMP WITH TIME ZONE 17 | ); 18 | 19 | CREATE TABLE accesstoken ( 20 | id VARCHAR(255) PRIMARY KEY, 21 | ttl INTEGER, 22 | created TIMESTAMP WITH TIME ZONE, 23 | userid UUID REFERENCES "user"(id) 24 | ); 25 | 26 | CREATE TABLE acl ( 27 | id SERIAL PRIMARY KEY, 28 | model VARCHAR(255), 29 | property VARCHAR(255), 30 | accesstype VARCHAR(255), 31 | permission VARCHAR(255), 32 | principaltype VARCHAR(255), 33 | principalid VARCHAR(255) 34 | ); 35 | 36 | CREATE TABLE role ( 37 | id SERIAL PRIMARY KEY, 38 | name VARCHAR(255) NOT NULL, 39 | description VARCHAR(255), 40 | created TIMESTAMP WITH TIME ZONE, 41 | modified TIMESTAMP WITH TIME ZONE 42 | ); 43 | 44 | CREATE TABLE rolemapping ( 45 | id SERIAL PRIMARY KEY, 46 | principaltype VARCHAR(255), 47 | principalid VARCHAR(255), 48 | roleid INTEGER REFERENCES role(id) 49 | ); 50 | -------------------------------------------------------------------------------- /generators/app/templates/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= appName %>", 3 | "version": "1.0.0", 4 | "main": "server/server.js", 5 | "scripts": { 6 | "lint": "eslint .", 7 | "test:backend": "NODE_ENV=test istanbul cover mocha -- tests/**/*.js -R spec", 8 | "test:frontend": "cd client && npm test", 9 | "test": "npm run test:backend && npm run test:frontend", 10 | "build:client": "cd client && npm run build", 11 | "migrate:create": "db-migrate create --sql-file", 12 | "migrate:down": "db-migrate down -e $NODE_ENV", 13 | "migrate:up": "db-migrate up -e $NODE_ENV", 14 | "posttest": "npm run lint && nsp check", 15 | "start": "node .", 16 | "start:prod": "NODE_ENV=production pm2 kill && pm2 startOrRestart pm2.yml", 17 | "stop": "pm2 kill", 18 | "postinstall": "if test ./client; then cd client && yarn; fi" 19 | }, 20 | "dependencies": { 21 | "compression": "^1.0.3", 22 | "cors": "^2.8.1", 23 | "db-migrate": "^0.10.0-beta.20", 24 | "db-migrate-pg": "^0.1.11", 25 | "helmet": "^3.1.0", 26 | "jsonwebtoken": "^7.2.1", 27 | "loopback": "^3.0.0", 28 | "loopback-boot": "^2.6.5", 29 | "loopback-component-explorer": "^4.0.0", 30 | "loopback-connector-postgresql": "^2.7.0", 31 | "loopback-datasource-juggler": "^2.53.0", 32 | "loopback-ds-timestamp-mixin": "3.4.0", 33 | "pg": "^6.1.0", 34 | "pm2": "^2.4.2", 35 | "serve-favicon": "^2.0.1", 36 | "strong-error-handler": "^1.0.1" 37 | }, 38 | "devDependencies": { 39 | "chai": "^3.5.0", 40 | "eslint": "^2.13.1", 41 | "eslint-config-loopback": "^4.0.0", 42 | "istanbul": "^0.4.5", 43 | "mocha": "^3.2.0", 44 | "nsp": "^2.1.0", 45 | "shipit-cli": "^3.0.0", 46 | "shipit-deploy": "^2.5.1", 47 | "sinon": "^2.0.0", 48 | "sinon-chai": "^2.8.0" 49 | }, 50 | "repository": { 51 | "type": "", 52 | "url": "" 53 | }, 54 | "license": "UNLICENSED", 55 | "description": "<%= appName %>" 56 | } 57 | -------------------------------------------------------------------------------- /generators/app/templates/pm2.yml: -------------------------------------------------------------------------------- 1 | apps: 2 | name : <%= appName %> 3 | watch : false 4 | script : ./server/server.js 5 | instances : max 6 | exec_mode : cluster 7 | error_file : ./logs/<%= appName %>.err.log 8 | out_file : ./logs/<%= appName %>.out.log 9 | combine_logs: true 10 | -------------------------------------------------------------------------------- /generators/app/templates/server/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "loopback" 3 | } 4 | -------------------------------------------------------------------------------- /generators/app/templates/server/boot/0-security.js: -------------------------------------------------------------------------------- 1 | const helmet = require('helmet') 2 | 3 | module.exports = function (server) { 4 | server.use(helmet()) 5 | } 6 | -------------------------------------------------------------------------------- /generators/app/templates/server/boot/authentication.js: -------------------------------------------------------------------------------- 1 | module.exports = function enableAuthentication(server) { 2 | // enable authentication 3 | server.enableAuth(); 4 | }; 5 | -------------------------------------------------------------------------------- /generators/app/templates/server/boot/create-admin.js: -------------------------------------------------------------------------------- 1 | const admin = { email: 'admin@<%= appName %>.com', password: '<%= appName %>', birthDate: new Date() }; 2 | 3 | module.exports = function (server) { 4 | const models = server.models; 5 | models.user.findOrCreate( 6 | { where: { email: 'admin@<%= appName %>.com' } }, 7 | admin 8 | , function(err, user) { 9 | if (err) return console.log('%j', err); 10 | models.Role.findOrCreate( 11 | { where: { name: 'admin' } }, 12 | { name: 'admin' }, 13 | function(err, role) { 14 | if (err) return console.log('error findorcreate', err); 15 | role.principals.create({ 16 | principalType: models.RoleMapping.USER, 17 | principalId: user.id 18 | }, function(err, principal) { 19 | if (err) return console.log('error', err); 20 | console.log(principal); 21 | }); 22 | }); 23 | }); 24 | }; 25 | -------------------------------------------------------------------------------- /generators/app/templates/server/component-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "loopback-component-explorer": { 3 | "mountPath": "/explorer" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /generators/app/templates/server/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "restApiRoot": "/api", 3 | "host": "127.0.0.1", 4 | "port": 3000, 5 | "remoting": { 6 | "context": false, 7 | "rest": { 8 | "normalizeHttpPath": false, 9 | "xml": false 10 | }, 11 | "json": { 12 | "strict": false, 13 | "limit": "100kb" 14 | }, 15 | "urlencoded": { 16 | "extended": true, 17 | "limit": "100kb" 18 | }, 19 | "cors": false, 20 | "handleErrors": false 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /generators/app/templates/server/datasources.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /generators/app/templates/server/datasources.local.js: -------------------------------------------------------------------------------- 1 | 2 | const database = require('../database.json'); 3 | 4 | const datasourcesDevConfig = { 5 | db: { 6 | name: 'db', 7 | connector: 'postgresql', 8 | host: database.dev.host, 9 | port: database.dev.port, 10 | database: database.dev.database, 11 | username: database.dev.user, 12 | password: database.dev.password 13 | }, 14 | "memory": { 15 | "name": "memory", 16 | "connector": "memory" 17 | }, 18 | }; 19 | 20 | const datasourcesProdConfig = { 21 | db: { 22 | name: 'db', 23 | connector: 'postgresql', 24 | host: database.production.host, 25 | port: database.dev.port, 26 | database: database.production.database, 27 | username: database.production.user, 28 | password: database.production.password 29 | }, 30 | "memory": { 31 | "name": "memory", 32 | "connector": "memory" 33 | }, 34 | }; 35 | 36 | const config = process.env.NODE_ENV === 'production' ? datasourcesProdConfig : datasourcesDevConfig; 37 | 38 | module.exports = config; 39 | -------------------------------------------------------------------------------- /generators/app/templates/server/middleware.development.json: -------------------------------------------------------------------------------- 1 | { 2 | "final:after": { 3 | "strong-error-handler": { 4 | "params": { 5 | "debug": true, 6 | "log": true 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /generators/app/templates/server/middleware.json: -------------------------------------------------------------------------------- 1 | { 2 | "initial:before": { 3 | "loopback#favicon": {} 4 | }, 5 | "initial": { 6 | "compression": {}, 7 | "cors": { 8 | "params": { 9 | "origin": true, 10 | "credentials": true, 11 | "maxAge": 86400 12 | } 13 | }, 14 | "helmet#xssFilter": {}, 15 | "helmet#frameguard": { 16 | "params": [ 17 | "deny" 18 | ] 19 | }, 20 | "helmet#hsts": { 21 | "params": { 22 | "maxAge": 0, 23 | "includeSubdomains": true 24 | } 25 | }, 26 | "helmet#hidePoweredBy": {}, 27 | "helmet#ieNoOpen": {}, 28 | "helmet#noSniff": {}, 29 | "helmet#noCache": { 30 | "enabled": false 31 | } 32 | }, 33 | "session": {}, 34 | "auth": {}, 35 | "parse": {}, 36 | "routes": { 37 | "loopback#rest": { 38 | "paths": [ 39 | "${restApiRoot}" 40 | ] 41 | } 42 | }, 43 | "files": { 44 | "loopback#static": [{ 45 | "name": "site", 46 | "paths": ["/"], 47 | "params": "$!../<%= clientPublicDirectory %>" 48 | }] 49 | }, 50 | "final": { 51 | "loopback#urlNotFound": {} 52 | }, 53 | "final:after": { 54 | "strong-error-handler": {} 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /generators/app/templates/server/model-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "sources": [ 4 | "loopback/common/models", 5 | "loopback/server/models", 6 | "../common/models", 7 | "./models" 8 | ], 9 | "mixins": [ 10 | "loopback/common/mixins", 11 | "../node_modules/loopback-ds-timestamp-mixin", 12 | "loopback/server/mixins", 13 | "../common/mixins", 14 | "./mixins" 15 | ] 16 | }, 17 | "user": { 18 | "dataSource": "db", 19 | "public": true 20 | }, 21 | "AccessToken": { 22 | "dataSource": "memory", 23 | "public": false 24 | }, 25 | "ACL": { 26 | "dataSource": "memory", 27 | "public": false 28 | }, 29 | "RoleMapping": { 30 | "dataSource": "memory", 31 | "public": false 32 | }, 33 | "Role": { 34 | "dataSource": "memory", 35 | "public": false 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/app/templates/server/models/user.js: -------------------------------------------------------------------------------- 1 | module.exports = function (User) {}; 2 | -------------------------------------------------------------------------------- /generators/app/templates/server/models/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "user", 3 | "plural": "users", 4 | "base": "User", 5 | "strict": false, 6 | "options": { 7 | "promisify": true 8 | }, 9 | "mixins": { 10 | "TimeStamp": { 11 | "createdAt": "createdat", 12 | "updatedAt": "updatedat" 13 | } 14 | }, 15 | "properties": { 16 | "id": { 17 | "type": "String", 18 | "id": true, 19 | "defaultFn": "uuid", 20 | "postgresql": { 21 | "dataType": "uuid" 22 | } 23 | }, 24 | "firstName": { 25 | "type": "String" 26 | }, 27 | "lastName": { 28 | "type": "String" 29 | } 30 | }, 31 | "acls": [ 32 | { 33 | "principalType": "ROLE", 34 | "principalId": "$everyone", 35 | "permission": "DENY" 36 | }, 37 | { 38 | "principalType": "ROLE", 39 | "principalId": "admin", 40 | "permission": "ALLOW", 41 | "property": "*" 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /generators/app/templates/server/server.js: -------------------------------------------------------------------------------- 1 | var loopback = require('loopback'); 2 | var boot = require('loopback-boot'); 3 | var app = module.exports = loopback(); 4 | 5 | app.use(loopback.token({ 6 | model: app.models.accessToken, 7 | currentUserLiteral: 'me' 8 | })); 9 | 10 | app.start = function() { 11 | // start the web server 12 | return app.listen(function() { 13 | app.emit('started'); 14 | var baseUrl = app.get('url').replace(/\/$/, ''); 15 | console.log('Web server listening at: %s', baseUrl); 16 | if (app.get('loopback-component-explorer')) { 17 | var explorerPath = app.get('loopback-component-explorer').mountPath; 18 | console.log('Browse your REST API at %s%s', baseUrl, explorerPath); 19 | } 20 | }); 21 | }; 22 | // Bootstrap the application, configure models, datasources and middleware. 23 | // Sub-apps like REST API are mounted via boot scripts. 24 | boot(app, __dirname, function(err) { 25 | if (err) throw err; 26 | // start the server if `$ node server.js` 27 | if (require.main === module) 28 | app.start(); 29 | }); 30 | -------------------------------------------------------------------------------- /generators/app/templates/shipitfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (shipit) { 2 | require('shipit-deploy')(shipit); 3 | 4 | shipit.initConfig({ 5 | default: { 6 | workspace: '/tmp/<%= appName %>', 7 | deployTo: '~/<%= appName %>', 8 | repositoryUrl: '<%= repositoryUrl %>', 9 | ignores: ['.git', 'tests', '.gitignore', 'devops', 'client/tests', 'node_modules', 'client/node_modules'], 10 | rsync: ['--del'], 11 | keepReleases: 3, 12 | key: '~/.ssh/id_rsa', 13 | shallowClone: true, 14 | }, 15 | staging: { 16 | branch: 'master', 17 | servers: 'www-data@<%= stagingIpAddress %>', 18 | }, 19 | prod: { 20 | branch: 'master', 21 | servers: 'www-data@<%= prodIpAddress %>', 22 | }, 23 | }); 24 | 25 | const yarn = '/usr/local/lib/npm/bin/yarn'; 26 | 27 | const installDependencies = function () { 28 | shipit.log('INSTALL NODE_MODULES'); 29 | return shipit.remote(`cd ${shipit.releasePath} && ${yarn} install`); 30 | }; 31 | 32 | const npmFrontCompile = function () { 33 | shipit.log('START COMPILING FRONTEND CODE'); 34 | return shipit.remote(`cd ${shipit.releasePath} && npm run build:client &> /dev/null`); 35 | } 36 | 37 | const runMigrations = function () { 38 | shipit.log('RUNNNING MIGRATIONS'); 39 | return shipit.remote(`cd ${shipit.releasePath} && npm run migrate:up`); 40 | } 41 | 42 | const restartServer = function () { 43 | shipit.log('RESTARTING SERVER'); 44 | return shipit.remote(`cd ${shipit.releasePath} && npm run start:prod`); 45 | } 46 | 47 | shipit.on('updated', function() { 48 | return shipit.start('install'); 49 | }); 50 | 51 | // blTask will block other tasks during its execution (synchronous) 52 | shipit.blTask('install', function() { 53 | return installDependencies() 54 | .then(npmFrontCompile) 55 | .then(runMigrations) 56 | .then(restartServer) 57 | .then(() => { 58 | shipit.log('Deployment successfull!\n'); 59 | }) 60 | .catch(function (err) { 61 | shipit.log(`Deployment failed: ${err}`); 62 | }); 63 | }); 64 | }; 65 | -------------------------------------------------------------------------------- /generators/app/templates/tests/test.js: -------------------------------------------------------------------------------- 1 | const chai = require('chai') 2 | const sinon = require('sinon') 3 | const sinonChai = require('sinon-chai') 4 | const should = chai.should() 5 | chai.use(sinonChai) 6 | let sandbox = null 7 | 8 | describe('Sample test with sandbox', () => { 9 | beforeEach(() => { 10 | sandbox = sinon.sandbox.create() 11 | }) 12 | 13 | afterEach(() => { 14 | sandbox.restore() 15 | }) 16 | 17 | it('should verify that true is true', () => { 18 | true.should.equal(true) 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-loopback-ansible", 3 | "version": "3.2.1", 4 | "description": "Generates a ansible fullstack JS application", 5 | "keywords": [ 6 | "yeoman-generator" 7 | ], 8 | "files": [ 9 | "generators" 10 | ], 11 | "dependencies": { 12 | "yarn-install": "^0.2.1", 13 | "yeoman-generator": "^1.0.0" 14 | }, 15 | "main": "index.js", 16 | "repository": "git@github.com:tcheymol/generator-loopback-ansible.git", 17 | "author": "Tcheymol", 18 | "license": "MIT" 19 | } 20 | --------------------------------------------------------------------------------