├── .gitignore ├── Ansible └── roles │ ├── ANXS.mysql │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── meta │ │ ├── .galaxy_install_info │ │ └── main.yml │ ├── tasks │ │ ├── configure.yml │ │ ├── databases.yml │ │ ├── install.yml │ │ ├── main.yml │ │ ├── monit.yml │ │ ├── secure.yml │ │ └── users.yml │ ├── templates │ │ ├── etc_monit_conf.d_mysql.j2 │ │ ├── etc_mysql_my.cnf.j2 │ │ └── root_dot_my.cnf.j2 │ ├── test.yml │ └── vars │ │ └── debian.yml │ ├── ANXS.postgresql │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── meta │ │ ├── .galaxy_install_info │ │ └── main.yml │ ├── tasks │ │ ├── configure.yml │ │ ├── databases.yml │ │ ├── extensions.yml │ │ ├── extensions │ │ │ ├── contrib.yml │ │ │ ├── dev_headers.yml │ │ │ └── postgis.yml │ │ ├── install.yml │ │ ├── main.yml │ │ ├── monit.yml │ │ ├── users.yml │ │ └── users_privileges.yml │ ├── templates │ │ ├── etc_monit_conf.d_postgresql.j2 │ │ ├── pg_hba.conf.j2 │ │ └── postgresql.conf.j2 │ ├── test.yml │ └── vars │ │ └── test.yml │ ├── MaximeThoonsen.php5-xdebug │ ├── defaults │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── templates │ │ └── xdebug.ini.j2 │ ├── Stouts.nodejs │ ├── .bumpversion.cfg │ ├── .travis.yml │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── meta │ │ ├── .galaxy_install_info │ │ └── main.yml │ ├── tasks │ │ ├── install.deb.yml │ │ ├── install.yum.yml │ │ ├── main.yml │ │ └── nodejs.yml │ └── test.yml │ ├── kosssi.apache │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── meta │ │ ├── .galaxy_install_info │ │ └── main.yml │ ├── tasks │ │ ├── install.yml │ │ ├── main.yml │ │ ├── module.yml │ │ ├── site.yml │ │ └── vhost.yml │ ├── templates │ │ └── vhost.conf.j2 │ └── tests │ │ ├── Makefile │ │ ├── Vagrantfile │ │ ├── inventory │ │ └── playbook.yml │ ├── kosssi.apt │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── meta │ │ ├── .galaxy_install_info │ │ └── main.yml │ ├── tasks │ │ ├── dependencies.yml │ │ ├── install.yml │ │ ├── main.yml │ │ ├── remove.yml │ │ ├── repositories.yml │ │ ├── update.yml │ │ └── upgrade.yml │ └── tests │ │ ├── Makefile │ │ ├── Vagrantfile │ │ ├── inventory │ │ └── playbook.yml │ ├── kosssi.composer │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── meta │ │ ├── .galaxy_install_info │ │ └── main.yml │ ├── tasks │ │ ├── configure.yml │ │ ├── install.yml │ │ ├── main.yml │ │ ├── test.yml │ │ └── update.yml │ └── tests │ │ ├── Makefile │ │ ├── Vagrantfile │ │ ├── inventory │ │ ├── playbook.yml │ │ └── roles │ │ └── common │ │ └── tasks │ │ └── main.yml │ ├── kosssi.php │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── meta │ │ ├── .galaxy_install_info │ │ └── main.yml │ ├── tasks │ │ ├── configure.yml │ │ ├── install.yml │ │ └── main.yml │ └── tests │ │ ├── Makefile │ │ ├── Vagrantfile │ │ ├── inventory │ │ └── playbook.yml │ └── nginx-symfony │ ├── README.md │ ├── defaults │ └── main.yml │ ├── files │ └── etc │ │ └── nginx │ │ └── mime.types │ ├── handlers │ └── main.yml │ ├── tasks │ └── main.yml │ └── templates │ └── etc │ └── nginx │ └── conf.d │ ├── prodconf │ └── vagrantconf ├── Command └── ProvisioningGeneratorCommand.php ├── Config ├── AnsibleRolesConfig.php ├── DatabaseConfig.php ├── EnvironmentConfig.php ├── EnvironmentsConfig.php ├── ServicesConfig.php ├── VagrantConfig.php └── WebServerConfig.php ├── DependencyInjection ├── Compiler │ ├── FinderCompilerPass.php │ └── GeneratorCompilerPass.php ├── Configuration.php └── FansibleDevopsExtension.php ├── FansibleDevopsBundle.php ├── Finder ├── Helper │ ├── FinderContainer.php │ └── FinderInterface.php └── NodeFinder.php ├── Generator ├── Ansible │ ├── AnsibleCfgGenerator.php │ ├── HostsGenerator.php │ ├── PlaybookGenerator.php │ ├── RequirementsGenerator.php │ └── Roles │ │ ├── ApacheGenerator.php │ │ ├── AptGenerator.php │ │ ├── ComposerGenerator.php │ │ ├── MysqlGenerator.php │ │ ├── NginxGenerator.php │ │ ├── NodeGenerator.php │ │ ├── PhpGenerator.php │ │ ├── PostgresqlGenerator.php │ │ └── XdebugGenerator.php ├── Helper │ ├── AnsibleRoleHelper.php │ ├── GeneratorContainer.php │ ├── GeneratorInterface.php │ └── TwigHelper.php └── VagrantfileGenerator.php ├── LICENSE ├── README.md ├── Resources ├── config │ ├── config.xml │ ├── finder.xml │ └── generator.xml └── views │ ├── Ansible │ ├── Roles │ │ ├── apache.yml.twig │ │ ├── apt.yml.twig │ │ ├── composer.yml.twig │ │ ├── mysql.yml.twig │ │ ├── nginx.yml.twig │ │ ├── node.yml.twig │ │ ├── php.yml.twig │ │ ├── postgresql.yml.twig │ │ └── xdebug.yml.twig │ ├── ansible.cfg.twig │ ├── group_vars.txt.twig │ ├── hosts.txt.twig │ ├── playbook.yml.twig │ └── requirements.txt.twig │ └── Vagrant │ └── Vagrantfile.txt.twig ├── Tests ├── Config │ └── DatabaseConfigTest.php ├── Finder │ └── NodeFinderTest.php ├── Helper │ └── ServiceHelperTest.php └── ressources │ └── package.json ├── composer.json └── phpunit.xml.dist /.gitignore: -------------------------------------------------------------------------------- 1 | phpunit.xml 2 | vendor 3 | composer.lock 4 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .AppleDouble 3 | .LSOverride 4 | Icon 5 | ._* 6 | .Spotlight-V100 7 | .Trashes 8 | .vagrant 9 | test 10 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | before_install: 5 | - sudo apt-get update -qq 6 | - sudo apt-get install -qq python-apt python-pycurl 7 | install: 8 | - pip install ansible==1.5.0 9 | script: 10 | - echo localhost > inventory 11 | - ansible-playbook --syntax-check -i inventory test.yml 12 | - ansible-playbook -i inventory test.yml --connection=local --sudo 13 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/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 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/README.md: -------------------------------------------------------------------------------- 1 | ## ANXS - MySQL [![Build Status](https://travis-ci.org/ANXS/mysql.png)](https://travis-ci.org/ANXS/mysql) 2 | 3 | Ansible role that installs MySQL on (for now) Ubuntu variants. 4 | Features include: 5 | - Installation of MySQL and it's dependencies 6 | - Basic configuration 7 | - Standard hardening (root password, removal of test databases) 8 | - Add databases 9 | - Add users 10 | - Setup of monit process supervision 11 | 12 | 13 | #### Requirements & Dependencies 14 | - Tested on Ansible 1.4 or higher. 15 | - ANXS.monit if you want monit protection (in that case, you should set `monit_protection: true`) 16 | 17 | 18 | #### Variables 19 | 20 | ```yaml 21 | # Basic settings 22 | mysql_port: 3306 # The port on which mysql listens 23 | mysql_bind_address: "0.0.0.0" # The address the mysql server binds on 24 | mysql_root_password: 'pass' # The root password 25 | 26 | # Fine Tuning 27 | mysql_key_buffer: '16M' 28 | mysql_max_allowed_packet: '128M' 29 | mysql_thread_stack: '192K' 30 | mysql_cache_size: 8 31 | mysql_myisam_recover: 'BACKUP' 32 | mysql_max_connections: 100 33 | mysql_table_cache: 64 34 | mysql_thread_concurrency: 10 35 | mysql_query_cache_limit: '1M' 36 | mysql_query_cache_size: '16M' 37 | mysql_character_set_server: 'utf8' 38 | mysql_collation_server: 'utf8_general_ci' 39 | mysql_mysqldump_max_allowed_packet: '128M' 40 | mysql_isamchk_key_buffer: '16M' 41 | 42 | # InnoDB tuning 43 | mysql_innodb_file_per_table: 'innodb_file_per_table' 44 | mysql_innodb_flush_method: 'fdatasync' 45 | mysql_innodb_buffer_pool_size: '128M' 46 | mysql_innodb_flush_log_at_trx_commit: 1 47 | mysql_innodb_lock_wait_timeout: 50 48 | mysql_innodb_log_buffer_size: '1M' 49 | mysql_innodb_log_file_size: '5M' 50 | 51 | # List of databases to be created (optional) 52 | mysql_databases: 53 | - name: foobar 54 | collation: "utf8_general_ci" # optional, defaults to "utf8_general_ci" 55 | encoding: "utf8" # optional, defaults to "utf8" 56 | 57 | # List of users to be created (optional) 58 | mysql_users: 59 | - name: baz 60 | pass: pass 61 | priv: "*.*:ALL" # optional, defaults to "*.*:ALL" 62 | host: "%" # optional, defaults to "localhost" 63 | 64 | # GLOBAL Setting 65 | monit_protection: false # true or false, requires ANXS.monit 66 | ``` 67 | 68 | 69 | #### License 70 | 71 | Licensed under the MIT License. See the LICENSE file for details. 72 | 73 | 74 | #### Feedback, bug-reports, requests, ... 75 | 76 | Are [welcome](https://github.com/ANXS/mysql/issues)! 77 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/defaults/main.yml 2 | 3 | # Basic settings 4 | mysql_port: 3306 5 | mysql_bind_address: "0.0.0.0" 6 | mysql_root_password: 'pass' 7 | mysql_language: '/usr/share/mysql/' 8 | 9 | # Fine Tuning 10 | mysql_key_buffer: '16M' 11 | mysql_max_allowed_packet: '128M' 12 | mysql_thread_stack: '192K' 13 | mysql_cache_size: 8 14 | mysql_myisam_recover: 'BACKUP' 15 | mysql_max_connections: 100 16 | mysql_table_cache: 64 17 | mysql_thread_concurrency: 10 18 | mysql_query_cache_limit: '1M' 19 | mysql_query_cache_size: '16M' 20 | mysql_innodb_file_per_table: 'innodb_file_per_table' 21 | mysql_character_set_server: 'utf8' 22 | mysql_collation_server: 'utf8_general_ci' 23 | mysql_mysqldump_max_allowed_packet: '128M' 24 | mysql_isamchk_key_buffer: '16M' 25 | 26 | # InnoDB tuning 27 | mysql_innodb_file_per_table: 'innodb_file_per_table' 28 | mysql_innodb_flush_method: 'fdatasync' 29 | mysql_innodb_buffer_pool_size: '128M' 30 | mysql_innodb_flush_log_at_trx_commit: 1 31 | mysql_innodb_lock_wait_timeout: 50 32 | mysql_innodb_log_buffer_size: '1M' 33 | mysql_innodb_log_file_size: '5M' 34 | 35 | # List of databases to be created 36 | mysql_databases: [] 37 | 38 | # List of users to be created 39 | mysql_users: [] 40 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/handlers/main.yml 2 | 3 | - name: restart mysql 4 | service: 5 | name: mysql 6 | state: restarted 7 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/meta/.galaxy_install_info: -------------------------------------------------------------------------------- 1 | {install_date: 'Wed Mar 11 19:05:23 2015', version: v1.0.3} 2 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/meta/main.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/meta/main.yml 2 | 3 | galaxy_info: 4 | author: pjan vandaele 5 | company: ANXS 6 | description: "MySQL install and configuration (hardening, databases, users, ...)" 7 | min_ansible_version: 1.4 8 | license: MIT 9 | platforms: 10 | - name: Ubuntu 11 | versions: 12 | - all 13 | categories: 14 | - system 15 | 16 | dependencies: [] 17 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/tasks/configure.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/tasks/configure.yml 2 | 3 | - name: MySQL | Update the my.cnf 4 | template: 5 | src: etc_mysql_my.cnf.j2 6 | dest: /etc/mysql/my.cnf 7 | owner: root 8 | group: root 9 | mode: 0644 10 | notify: 11 | - restart mysql 12 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/tasks/databases.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/tasks/databases.yml 2 | 3 | - name: MySQL | Make sure the MySQL databases are present 4 | mysql_db: 5 | name: "{{ item.name }}" 6 | collation: "{{ item.collation | default('utf8_general_ci') }}" 7 | encoding: "{{ item.encoding | default('utf8') }}" 8 | state: present 9 | with_items: mysql_databases 10 | when: mysql_databases|length > 0 11 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/tasks/install.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/tasks/install.yml 2 | 3 | - name: MySQL | Load the os specific variables 4 | include_vars: "{{ansible_os_family | lower}}.yml" 5 | 6 | - name: MySQL | Make sure the MySql packages are installed 7 | apt: 8 | pkg: "{{item}}" 9 | update_cache: yes 10 | with_items: mysql_packages 11 | 12 | - name: MySQL | Ensure MySQL is running 13 | service: 14 | name: mysql 15 | state: started 16 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/tasks/main.yml 2 | 3 | - include: install.yml 4 | - include: configure.yml 5 | - include: secure.yml 6 | - include: databases.yml 7 | - include: users.yml 8 | - include: monit.yml 9 | when: monit_protection is defined and monit_protection == true 10 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/tasks/monit.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/tasks/monit.yml 2 | 3 | - name: MySQL | (Monit) Copy the mysql monit service file 4 | template: 5 | src: etc_monit_conf.d_mysql.j2 6 | dest: /etc/monit/conf.d/mysql 7 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/tasks/secure.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/tasks/secure.yml 2 | 3 | - name: MySQL | Set the root password. 4 | mysql_user: 5 | user: root 6 | host: "{{item}}" 7 | password: "{{mysql_root_password}}" 8 | with_items: 9 | - "{{ansible_hostname}}" 10 | - 127.0.0.1 11 | - ::1 12 | - localhost 13 | when: ansible_hostname != 'localhost' 14 | 15 | - name: MySQL | Set the root password. 16 | mysql_user: 17 | user: root 18 | host: "{{item}}" 19 | password: "{{mysql_root_password}}" 20 | with_items: 21 | - 127.0.0.1 22 | - ::1 23 | - localhost 24 | when: ansible_hostname == 'localhost' 25 | 26 | - name: MySQL | Configure MySql for easy access as root user 27 | template: 28 | src: root_dot_my.cnf.j2 29 | dest: /root/.my.cnf 30 | owner: root 31 | group: root 32 | mode: 0600 33 | 34 | - name: MySQL | Remove anonymous MySQL server user 35 | mysql_user: 36 | name: "" 37 | host: "{{item}}" 38 | state: absent 39 | with_items: 40 | - "{{ansible_hostname}}" 41 | - localhost 42 | 43 | - name: MySQL | Remove the MySQL test database 44 | mysql_db: 45 | name: test 46 | state: absent 47 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/tasks/users.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/tasks/users.yml 2 | 3 | - name: MySQL | Make sure the MySQL users are present 4 | mysql_user: 5 | name: "{{item.name}}" 6 | password: "{{item.pass | default('pass')}}" 7 | priv: "{{item.priv | default('*.*:ALL')}}" 8 | state: present 9 | host: "{{item.host | default('localhost')}}" 10 | with_items: mysql_users 11 | when: mysql_users|length > 0 12 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/templates/etc_monit_conf.d_mysql.j2: -------------------------------------------------------------------------------- 1 | check process mysqld with pidfile /var/run/mysqld/mysqld.pid 2 | group database 3 | start program = "/etc/init.d/mysql start" 4 | stop program = "/etc/init.d/mysql stop" 5 | if failed host localhost port {{ mysql_port }} protocol mysql then restart 6 | if 5 restarts within 5 cycles then timeout 7 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/templates/etc_mysql_my.cnf.j2: -------------------------------------------------------------------------------- 1 | # 2 | # The MySQL database server configuration file. 3 | # 4 | # For explanations see 5 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 6 | 7 | [client] 8 | port = {{ mysql_port }} 9 | socket = /var/run/mysqld/mysqld.sock 10 | 11 | [mysqld_safe] 12 | socket = /var/run/mysqld/mysqld.sock 13 | nice = 0 14 | 15 | [mysqld] 16 | # * Basic Settings 17 | user = mysql 18 | pid-file = /var/run/mysqld/mysqld.pid 19 | socket = /var/run/mysqld/mysqld.sock 20 | port = {{ mysql_port }} 21 | basedir = /usr 22 | datadir = /var/lib/mysql 23 | tmpdir = /tmp 24 | # language is for pre-5.5. In 5.5 it is an alias for lc_messages_dir. 25 | language = {{ mysql_language }} 26 | bind-address = {{ mysql_bind_address }} 27 | skip-external-locking 28 | 29 | 30 | # * Fine Tuning 31 | key_buffer = {{ mysql_key_buffer }} 32 | max_allowed_packet = {{ mysql_max_allowed_packet }} 33 | thread_stack = {{ mysql_thread_stack }} 34 | thread_cache_size = {{ mysql_cache_size }} 35 | myisam-recover = {{ mysql_myisam_recover }} 36 | max_connections = {{ mysql_max_connections }} 37 | table_open_cache = {{ mysql_table_cache }} 38 | thread_concurrency = {{ mysql_thread_concurrency }} 39 | 40 | # ** Query Cache Configuration 41 | query_cache_limit = {{ mysql_query_cache_limit }} 42 | query_cache_size = {{ mysql_query_cache_size }} 43 | 44 | # ** Logging and Replication 45 | #general_log_file = /var/log/mysql/mysql.log 46 | #general_log = 1 47 | # 48 | #log_slow_queries = /var/log/mysql/mysql-slow.log 49 | #long_query_time = 2 50 | #log-queries-not-using-indexes 51 | # 52 | # The following can be used as easy to replay backup logs or for replication. 53 | #server-id = 1 54 | #log_bin = /var/log/mysql/mysql-bin.log 55 | expire_logs_days = 10 56 | max_binlog_size = 100M 57 | #binlog_do_db = include_database_name 58 | #binlog_ignore_db = include_database_name 59 | 60 | # ** InnoDB 61 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 62 | # Read the manual for more InnoDB related options. There are many! 63 | innodb_flush_log_at_trx_commit = {{ mysql_innodb_flush_log_at_trx_commit }} 64 | innodb_buffer_pool_size = {{ mysql_innodb_buffer_pool_size }} 65 | {% if mysql_innodb_flush_method != 'fdatasync': %} 66 | innodb_flush_method = {{ mysql_innodb_flush_method }} 67 | {% endif %} 68 | innodb_lock_wait_timeout = {{ mysql_innodb_lock_wait_timeout }} 69 | innodb_log_buffer_size = {{ mysql_innodb_log_buffer_size }} 70 | innodb_log_file_size = {{ mysql_innodb_log_file_size }} 71 | {{ mysql_innodb_file_per_table }} 72 | 73 | # ** Security Features 74 | # Read the manual, too, if you want chroot! 75 | # chroot = /var/lib/mysql/ 76 | # 77 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 78 | # ssl-ca=/etc/mysql/cacert.pem 79 | # ssl-cert=/etc/mysql/server-cert.pem 80 | # ssl-key=/etc/mysql/server-key.pem 81 | 82 | character_set_server = {{ mysql_character_set_server }} 83 | collation_server = {{ mysql_collation_server }} 84 | 85 | [mysqldump] 86 | quick 87 | quote-names 88 | max_allowed_packet = {{ mysql_mysqldump_max_allowed_packet }} 89 | 90 | [mysql] 91 | #no-auto-rehash # faster start of mysql but no tab completition 92 | 93 | [isamchk] 94 | key_buffer = {{ mysql_isamchk_key_buffer }} 95 | 96 | # 97 | # * IMPORTANT: Additional settings that can override those from this file! 98 | # The files must end with '.cnf', otherwise they'll be ignored. 99 | # 100 | !includedir /etc/mysql/conf.d/ 101 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/templates/root_dot_my.cnf.j2: -------------------------------------------------------------------------------- 1 | [client] 2 | user=root 3 | password={{ mysql_root_password }} 4 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/test.yml: -------------------------------------------------------------------------------- 1 | - hosts: all 2 | vars_files: 3 | - 'defaults/main.yml' 4 | tasks: 5 | - include: 'tasks/main.yml' 6 | handlers: 7 | - include: 'handlers/main.yml' 8 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.mysql/vars/debian.yml: -------------------------------------------------------------------------------- 1 | # file: mysql/vars/debian.yml 2 | 3 | mysql_packages: 4 | - mysql-server 5 | - mysql-client 6 | - python-mysqldb 7 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .AppleDouble 3 | .LSOverride 4 | Icon 5 | ._* 6 | .Spotlight-V100 7 | .Trashes 8 | .vagrant 9 | test 10 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | before_install: 5 | - sudo apt-get update -qq 6 | - sudo apt-get install -qq python-apt python-pycurl 7 | install: 8 | - pip install ansible==1.5.0 9 | script: 10 | - echo localhost > inventory 11 | - ansible-playbook --syntax-check -i inventory test.yml 12 | - ansible-playbook -i inventory test.yml --connection=local --sudo 13 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.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 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/README.md: -------------------------------------------------------------------------------- 1 | ## ANXS - PostgreSQL [![Build Status](https://travis-ci.org/ANXS/postgresql.png)](https://travis-ci.org/ANXS/postgresql) 2 | 3 | Ansible role which installs and configures PostgreSQL, extensions, databases and users. 4 | 5 | 6 | #### Requirements & Dependencies 7 | - Tested on Ansible 1.4 or higher. 8 | - 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`) 9 | 10 | 11 | #### Variables 12 | 13 | ```yaml 14 | # Basic settings 15 | postgresql_version: 9.3 16 | postgresql_encoding: 'UTF-8' 17 | postgresql_locale: 'en_US.UTF-8' 18 | 19 | postgresql_admin_user: "postgres" 20 | postgresql_default_auth_method: "trust" 21 | 22 | postgresql_cluster_name: "main" 23 | postgresql_cluster_reset: false 24 | 25 | # List of databases to be created (optional) 26 | postgresql_databases: 27 | - name: foobar 28 | hstore: yes # flag to install the hstore extension on this database (yes/no) 29 | uuid_ossp: yes # flag to install the uuid-ossp extension on this database (yes/no) 30 | 31 | # List of users to be created (optional) 32 | postgresql_users: 33 | - name: baz 34 | pass: pass 35 | encrypted: no # denotes if the password is already encrypted. 36 | 37 | # List of user privileges to be applied (optional) 38 | postgresql_user_privileges: 39 | - name: baz # user name 40 | db: foobar # database 41 | priv: "ALL" # privilege string format: example: INSERT,UPDATE/table:SELECT/anothertable:ALL 42 | role_attr_flags: "CREATEDB" # role attribute flags 43 | ``` 44 | 45 | There's a lot more knobs and bolts to set, which you can find in the defaults/main.yml 46 | 47 | 48 | #### License 49 | 50 | Licensed under the MIT License. See the LICENSE file for details. 51 | 52 | #### Thanks 53 | 54 | To the contributors: 55 | - [Ralph von der Heyden](https://github.com/ralph) 56 | 57 | 58 | #### Feedback, bug-reports, requests, ... 59 | 60 | Are [welcome](https://github.com/ANXS/postgresql/issues)! 61 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/defaults/main.yml 2 | 3 | # Basic settings 4 | postgresql_version: 9.3 5 | postgresql_encoding: 'UTF-8' 6 | postgresql_locale: 'en_US.UTF-8' 7 | 8 | postgresql_admin_user: "postgres" 9 | postgresql_default_auth_method: "trust" 10 | 11 | # The user/group that will run postgresql process or service 12 | postgresql_service_user: "{{ postgresql_admin_user }}" 13 | postgresql_service_group: "{{ postgresql_admin_user }}" 14 | 15 | postgresql_cluster_name: "main" 16 | postgresql_cluster_reset: false 17 | 18 | postgresql_database_owner: "{{ postgresql_admin_user }}" 19 | # Extensions 20 | postgresql_ext_install_contrib: no 21 | postgresql_ext_install_dev_headers: no 22 | postgresql_ext_install_postgis: no 23 | 24 | postgresql_ext_postgis_version: "2.1" # be careful: check whether the postgresql/postgis versions work together 25 | 26 | # List of databases to be created (optional) 27 | postgresql_databases: [] 28 | 29 | # List of users to be created (optional) 30 | postgresql_users: [] 31 | 32 | # List of user privileges to be applied (optional) 33 | postgresql_user_privileges: [] 34 | 35 | # pg_hba.conf 36 | postgresql_pg_hba_default: 37 | - { type: local, database: all, user: '{{ postgresql_admin_user }}', address: '', method: '{{ postgresql_default_auth_method }}', comment: '' } 38 | - { type: local, database: all, user: all, address: '', method: '{{ postgresql_default_auth_method }}', comment: '"local" is for Unix domain socket connections only' } 39 | - { type: host, database: all, user: all, address: '127.0.0.1/32', method: '{{ postgresql_default_auth_method }}', comment: 'IPv4 local connections:' } 40 | - { type: host, database: all, user: all, address: '::1/128', method: '{{ postgresql_default_auth_method }}', comment: 'IPv6 local connections:' } 41 | 42 | postgresql_pg_hba_passwd_hosts: [] 43 | postgresql_pg_hba_trust_hosts: [] 44 | postgresql_pg_hba_custom: [] 45 | 46 | 47 | # postgresql.conf 48 | 49 | #------------------------------------------------------------------------------ 50 | # FILE LOCATIONS 51 | #------------------------------------------------------------------------------ 52 | 53 | # Location of postgres configuration files here 54 | postgresql_conf_directory: "/etc/postgresql/{{postgresql_version}}/{{postgresql_cluster_name}}" 55 | # HBA (Host Based Authentication) file 56 | postgresql_hba_file: "{{postgresql_conf_directory}}/pg_hba.conf" 57 | # Ident configuration file 58 | postgresql_ident_file: "{{postgresql_conf_directory}}/pg_ident.conf" 59 | # Use data in another directory 60 | postgresql_data_directory: "/var/lib/postgresql/{{postgresql_version}}/{{postgresql_cluster_name}}" 61 | # If external_pid_file is not explicitly set, on extra PID file is written 62 | postgresql_external_pid_file: "/var/run/postgresql/{{postgresql_version}}-{{postgresql_cluster_name}}.pid" 63 | 64 | #------------------------------------------------------------------------------ 65 | # CONNECTIONS AND AUTHENTICATION 66 | #------------------------------------------------------------------------------ 67 | 68 | postgresql_listen_addresses: 69 | - localhost 70 | postgresql_port: 5432 71 | 72 | postgresql_max_connections: 100 73 | postgresql_superuser_reserved_connections: 3 74 | 75 | postgresql_unix_socket_directories: 76 | - /var/run/postgresql 77 | postgresql_unix_socket_group: '' 78 | postgresql_unix_socket_permissions: '0777' # begin with 0 to use octal notation 79 | 80 | # Automatic pg_ctl configuration. Specify a list of options containing 81 | # cluster specific options to be passed to pg_ctl(1). 82 | postgresql_pg_ctl_options: [] 83 | 84 | postgresql_bonjour: off # advertise server via Bonjour 85 | postgresql_bonjour_name: '' # defaults to the computer name 86 | 87 | 88 | # - Security and Authentication - 89 | 90 | postgresql_authentication_timeout: 60s 91 | postgresql_ssl: off 92 | postgresql_ssl_ciphers: 93 | - 'DEFAULT' 94 | - '!LOW' 95 | - '!EXP' 96 | - '!MD5' 97 | - '@STRENGTH' 98 | postgresql_ssl_renegotiation_limit: 512MB # amount of data between renegotiations 99 | postgresql_ssl_cert_file: /etc/ssl/certs/ssl-cert-snakeoil.pem 100 | postgresql_ssl_key_file: /etc/ssl/private/ssl-cert-snakeoil.key 101 | postgresql_ssl_ca_file: '' 102 | postgresql_ssl_crl_file: '' 103 | postgresql_password_encryption: on 104 | postgresql_db_user_namespace: off 105 | 106 | # Kerberos and GSSAPI 107 | postgresql_krb_server_keyfile: '' 108 | postgresql_krb_srvname: postgres 109 | postgresql_krb_caseins_users: off 110 | 111 | # TCP Keepalives, 0 selects the system default (in seconds) 112 | postgresql_tcp_keepalives_idle: 0 113 | postgresql_tcp_keepalives_interval: 0 114 | postgresql_tcp_keepalives_count: 0 115 | 116 | 117 | #------------------------------------------------------------------------------ 118 | # RESOURCE USAGE (except WAL) 119 | #------------------------------------------------------------------------------ 120 | 121 | # - Memory - 122 | 123 | postgresql_shared_buffers: 128MB # min 128kB 124 | postgresql_temp_buffers: 8MB # min 800kB 125 | 126 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 127 | # per transaction slot, plus lock space (see max_locks_per_transaction). 128 | # It is not advisable to set max_prepared_transactions nonzero unless you 129 | # actively intend to use prepared transactions. 130 | postgresql_max_prepared_transactions: 0 # zero disables the feature 131 | 132 | postgresql_work_mem: 1MB # min 64kB 133 | postgresql_maintenance_work_mem: 16MB # min 1MB 134 | postgresql_max_stack_depth: 2MB # min 100kB 135 | 136 | 137 | # - Disk - 138 | 139 | # limits per-session temp file space in kB, or -1 for no limit 140 | postgresql_temp_file_limit: -1 141 | 142 | 143 | # - Kernel Resource Usage - 144 | 145 | postgresql_max_files_per_process: 1000 # min 25 146 | postgresql_shared_preload_libraries: [] 147 | 148 | 149 | # - Cost-Based Vacuum Delay - 150 | 151 | postgresql_vacuum_cost_delay: 0 # 0-100 milliseconds 152 | postgresql_vacuum_cost_page_hit: 1 # 0-10000 credits 153 | postgresql_vacuum_cost_page_miss: 10 # 0-10000 credits 154 | postgresql_vacuum_cost_page_dirty: 20 # 0-10000 credits 155 | postgresql_vacuum_cost_limit: 200 # 1-10000 credits 156 | 157 | 158 | # - Background Writer - 159 | 160 | postgresql_bgwriter_delay: 200ms # 10-10000ms between rounds 161 | postgresql_bgwriter_lru_maxpages: 100 # 0-1000 max buffers written/round 162 | postgresql_bgwriter_lru_multiplier: 2.0 # 0-10.0 multipler on buffers scanned/round 163 | 164 | 165 | # - Asynchronous Behavior - 166 | 167 | postgresql_effective_io_concurrency: 1 # 1-1000; 0 disables prefetching 168 | 169 | 170 | #------------------------------------------------------------------------------ 171 | # WRITE AHEAD LOG 172 | #------------------------------------------------------------------------------ 173 | 174 | # - Settings - 175 | 176 | postgresql_wal_level: minimal # minimal, archive, or hot_standby 177 | postgresql_fsync: on # turns forced synchronization on or off 178 | 179 | # Synchronization level: 180 | # - off 181 | # - local 182 | # - remote_write 183 | # - on 184 | postgresql_synchronous_commit: on 185 | 186 | # The default is the first option supported by the operating system: 187 | # - open_datasync 188 | # - fdatasync (default on Linux) 189 | # - fsync 190 | # - fsync_writethrough 191 | # - open_sync 192 | postgresql_wal_sync_method: fsync 193 | 194 | # recover from partial page writes 195 | postgresql_full_page_writes: on 196 | 197 | postgresql_wal_buffers: -1 # min 32kB, -1 sets based on shared_buffers 198 | postgresql_wal_writer_delay: 200ms # 1-10000 milliseconds 199 | postgresql_commit_delay: 0 # range 0-100000, in microseconds 200 | postgresql_commit_siblings: 5 # range 1-1000 201 | 202 | 203 | # - Checkpoints - 204 | 205 | postgresql_checkpoint_segments: 3 # in logfile segments, min 1, 16MB each 206 | postgresql_checkpoint_timeout: 5min # range 30s-1h 207 | postgresql_checkpoint_completion_target: 0.5 # checkpoint target duration, 0.0 - 1.0 208 | postgresql_checkpoint_warning: 30s # 0 disables 209 | 210 | 211 | # - Archiving - 212 | 213 | # allows archiving to be done 214 | postgresql_archive_mode: off 215 | 216 | # Command to use to archive a logfile segment. 217 | # Placeholders: %p = path of file to archive 218 | # %f = file name only 219 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 220 | postgresql_archive_command: '' 221 | 222 | # force a logfile segment switch after this 223 | postgresql_archive_timeout: 0 224 | 225 | 226 | #------------------------------------------------------------------------------ 227 | # REPLICATION 228 | #------------------------------------------------------------------------------ 229 | 230 | # - Sending Server(s) - 231 | 232 | # Set these on the master and on any standby that will send replication data. 233 | 234 | # max number of walsender processes 235 | postgresql_max_wal_senders: 0 236 | 237 | postgresql_wal_keep_segments: 0 # in logfile segments, 16MB each; 0 disables 238 | postgresql_wal_sender_timeout: 60s # in milliseconds; 0 disables 239 | 240 | 241 | # - Master Server - 242 | 243 | # These settings are ignored on a standby server. 244 | 245 | # Standby servers that provide sync rep. 246 | # Comma-separated list of application_name from standby(s) 247 | postgresql_synchronous_standby_names: [] # '*' means 'all' 248 | 249 | # number of xacts by which cleanup is delayed 250 | postgresql_vacuum_defer_cleanup_age: 0 251 | 252 | 253 | # - Standby Servers - 254 | 255 | # "on" allows queries during recovery 256 | postgresql_hot_standby: off 257 | # max delay before canceling queries when reading WAL from archive 258 | postgresql_max_standby_archive_delay: 30s # -1 allows indefinite delay 259 | # max delay before canceling queries when reading streaming WAL; 260 | postgresql_max_standby_streaming_delay: 30s # -1 allows indefinite delay 261 | # send replies at least this often 262 | postgresql_wal_receiver_status_interval: 10s # 0 disables 263 | # send info from standby to prevent query conflicts 264 | postgresql_hot_standby_feedback: off 265 | #time that receiver waits for communication from master in milliseconds 266 | postgresql_wal_receiver_timeout: 60s 267 | 268 | 269 | #------------------------------------------------------------------------------ 270 | # QUERY TUNING 271 | #------------------------------------------------------------------------------ 272 | 273 | # - Planner Method Configuration - 274 | 275 | postgresql_enable_bitmapscan: on 276 | postgresql_enable_hashagg: on 277 | postgresql_enable_hashjoin: on 278 | postgresql_enable_indexscan: on 279 | postgresql_enable_indexonlyscan: on 280 | postgresql_enable_material: on 281 | postgresql_enable_mergejoin: on 282 | postgresql_enable_nestloop: on 283 | postgresql_enable_seqscan: on 284 | postgresql_enable_sort: on 285 | postgresql_enable_tidscan: on 286 | 287 | 288 | # - Planner Cost Constants - 289 | 290 | postgresql_seq_page_cost: 1.0 # measured on an arbitrary scale 291 | postgresql_random_page_cost: 4.0 # same scale as above 292 | postgresql_cpu_tuple_cost: 0.01 # same scale as above 293 | postgresql_cpu_index_tuple_cost: 0.005 # same scale as above 294 | postgresql_cpu_operator_cost: 0.0025 # same scale as above 295 | postgresql_effective_cache_size: 128MB 296 | 297 | 298 | # - Genetic Query Optimizer - 299 | 300 | postgresql_geqo: on 301 | postgresql_geqo_threshold: 12 302 | postgresql_geqo_effort: 5 # range 1-10 303 | postgresql_geqo_pool_size: 0 # selects default based on effort 304 | postgresql_geqo_generations: 0 # selects default based on effort 305 | postgresql_geqo_selection_bias: 2.0 # range 1.5-2.0 306 | postgresql_geqo_seed: 0.0 # range 0.0-1.0 307 | 308 | 309 | # - Other Planner Options - 310 | 311 | postgresql_default_statistics_target: 100 # range 1-10000 312 | postgresql_constraint_exclusion: partition # on, off, or partition 313 | postgresql_cursor_tuple_fraction: 0.1 # range 0.0-1.0 314 | postgresql_from_collapse_limit: 8 315 | postgresql_join_collapse_limit: 8 # 1 disables collapsing of explicit 316 | 317 | 318 | #------------------------------------------------------------------------------ 319 | # ERROR REPORTING AND LOGGING 320 | #------------------------------------------------------------------------------ 321 | 322 | # - Where to Log - 323 | 324 | # Valid values are combinations of stderr, csvlog, syslog, and eventlog. 325 | # depending on platform. Csvlog requires logging_collector to be on. 326 | postgresql_log_destination: stderr 327 | 328 | # Enable capturing of stderr and csvlog into log files. 329 | # Required to be on for csvlogs. 330 | postgresql_logging_collector: off 331 | 332 | # These are only used if logging_collector is on: 333 | 334 | # Directory where log files are written, can be absolute or relative to PGDATA 335 | postgresql_log_directory: pg_log 336 | # Log file name pattern, can include strftime() escapes 337 | postgresql_log_filename: postgresql-%Y-%m-%d_%H%M%S.log 338 | postgresql_log_file_mode: '0600' # begin with 0 to use octal notation 339 | # If on, an existing log file with the same name as the new log file will be 340 | # truncated rather than appended to. But such truncation only occurs on 341 | # time-driven rotation, not on restarts or size-driven rotation. Default is 342 | # off, meaning append to existing files in all cases. 343 | postgresql_log_truncate_on_rotation: off 344 | # Automatic rotation of logfiles will happen after that time. 345 | postgresql_log_rotation_age: 1d 346 | # Automatic rotation of logfiles will happen after that much log output. 347 | postgresql_log_rotation_size: 10MB 348 | 349 | # These are relevant when logging to syslog: 350 | postgresql_syslog_facility: LOCAL0 351 | postgresql_syslog_ident: postgres 352 | # This is only relevant when logging to eventlog (win32): 353 | postgresql_event_source: PostgreSQL 354 | 355 | 356 | # - When to Log - 357 | 358 | # Values in order of decreasing detail: 359 | # - debug5 360 | # - debug4 361 | # - debug3 362 | # - debug2 363 | # - debug1 364 | # - log 365 | # - notice 366 | # - warning 367 | # - error 368 | postgresql_client_min_messages: notice 369 | 370 | # Values in order of decreasing detail: 371 | # - debug5 372 | # - debug4 373 | # - debug3 374 | # - debug2 375 | # - debug1 376 | # - info 377 | # - notice 378 | # - warning 379 | # - error 380 | # - log 381 | # - fatal 382 | # - panic 383 | postgresql_log_min_messages: warning 384 | 385 | # Values in order of decreasing detail: 386 | # - debug5 387 | # - debug4 388 | # - debug3 389 | # - debug2 390 | # - debug1 391 | # - info 392 | # - notice 393 | # - warning 394 | # - error 395 | # - log 396 | # - fatal 397 | # - panic (effectively off) 398 | postgresql_log_min_error_statement: error 399 | 400 | # -1 is disabled, 0 logs all statements and their durations, > 0 logs only 401 | # statements running at least this number of milliseconds 402 | postgresql_log_min_duration_statement: -1 403 | 404 | 405 | # - What to Log - 406 | 407 | postgresql_debug_print_parse: off 408 | postgresql_debug_print_rewritten: off 409 | postgresql_debug_print_plan: off 410 | postgresql_debug_pretty_print: on 411 | postgresql_log_checkpoints: off 412 | postgresql_log_connections: off 413 | postgresql_log_disconnections: off 414 | postgresql_log_duration: off 415 | postgresql_log_error_verbosity: default # terse, default, or verbose messages 416 | postgresql_log_hostname: off 417 | 418 | # Special values: 419 | # %a = application name 420 | # %u = user name 421 | # %d = database name 422 | # %r = remote host and port 423 | # %h = remote host 424 | # %p = process ID 425 | # %t = timestamp without milliseconds 426 | # %m = timestamp with milliseconds 427 | # %i = command tag 428 | # %e = SQL state 429 | # %c = session ID 430 | # %l = session line number 431 | # %s = sessioan start timestamp 432 | # %v = virtual transaction ID 433 | # %x = transaction ID (0 if none) 434 | # %q = stop here in non-session 435 | # processes 436 | # %% = '%' 437 | postgresql_log_line_prefix: '%t ' 438 | 439 | # log lock waits >= deadlock_timeout 440 | postgresql_log_lock_waits: off 441 | postgresql_log_statement: none # none, ddl, mod, all 442 | # log temporary files equal or larger 443 | postgresql_log_temp_files: -1 444 | postgresql_log_timezone: UTC 445 | 446 | 447 | #------------------------------------------------------------------------------ 448 | # RUNTIME STATISTICS 449 | #------------------------------------------------------------------------------ 450 | 451 | # - Query/Index Statistics Collector - 452 | 453 | postgresql_track_activities: on 454 | postgresql_track_counts: on 455 | postgresql_track_io_timing: off 456 | postgresql_track_functions: none # none, pl, all 457 | postgresql_track_activity_query_size: 1024 458 | postgresql_update_process_title: on 459 | postgresql_stats_temp_directory: pg_stat_tmp 460 | 461 | 462 | # - Statistics Monitoring - 463 | 464 | postgresql_log_parser_stats: off 465 | postgresql_log_planner_stats: off 466 | postgresql_log_executor_stats: off 467 | postgresql_log_statement_stats: off 468 | 469 | 470 | #------------------------------------------------------------------------------ 471 | # AUTOVACUUM PARAMETERS 472 | #------------------------------------------------------------------------------ 473 | 474 | # Enable autovacuum subprocess? 'on' requires track_counts to also be on. 475 | postgresql_autovacuum: on 476 | # -1 disables, 0 logs all actions and their durations, > 0 logs only 477 | # actions running at least this number of milliseconds. 478 | postgresql_log_autovacuum_min_duration: -1 479 | # max number of autovacuum subprocesses 480 | postgresql_autovacuum_max_workers: 3 481 | # time between autovacuum runs 482 | postgresql_autovacuum_naptime: 1min 483 | # min number of row updates before vacuum 484 | postgresql_autovacuum_vacuum_threshold: 50 485 | # min number of row updates before analyze 486 | postgresql_autovacuum_analyze_threshold: 50 487 | # fraction of table size before vacuum 488 | postgresql_autovacuum_vacuum_scale_factor: 0.2 489 | # fraction of table size before analyze 490 | postgresql_autovacuum_analyze_scale_factor: 0.1 491 | # maximum XID age before forced vacuum 492 | postgresql_autovacuum_freeze_max_age: 200000000 493 | # default vacuum cost delay for autovacuum, in milliseconds 494 | postgresql_autovacuum_vacuum_cost_delay: 20ms 495 | # default vacuum cost limit for autovacuum, 496 | postgresql_autovacuum_vacuum_cost_limit: -1 497 | 498 | 499 | #------------------------------------------------------------------------------ 500 | # CLIENT CONNECTION DEFAULTS 501 | #------------------------------------------------------------------------------ 502 | 503 | # - Statement Behavior - 504 | 505 | postgresql_search_path: # schema names 506 | - '"$user"' 507 | - public 508 | postgresql_default_tablespace: '' # a tablespace name, '' uses the default 509 | postgresql_temp_tablespaces: [] # a list of tablespace names 510 | 511 | postgresql_check_function_bodies: on 512 | postgresql_default_transaction_isolation: read committed 513 | postgresql_default_transaction_read_only: off 514 | postgresql_default_transaction_deferrable: off 515 | postgresql_session_replication_role: origin 516 | 517 | postgresql_statement_timeout: 0 # in milliseconds, 0 is disabled 518 | postgresql_lock_timeout: 0 # in milliseconds, 0 is disabled 519 | postgresql_vacuum_freeze_min_age: 50000000 520 | postgresql_vacuum_freeze_table_age: 150000000 521 | 522 | postgresql_bytea_output: hex # hex, escape 523 | postgresql_xmlbinary: base64 524 | postgresql_xmloption: content 525 | 526 | 527 | # - Locale and Formatting - 528 | 529 | postgresql_datestyle: 530 | - iso 531 | - mdy 532 | postgresql_intervalstyle: postgres 533 | postgresql_timezone: UTC 534 | 535 | # Select the set of available time zone abbreviations. Currently, there are: 536 | # Default 537 | # Australia 538 | # India 539 | # You can create your own file in `share/timezonesets/`. 540 | postgresql_timezone_abbreviations: Default 541 | 542 | postgresql_extra_float_digits: 0 # min -15, max 3 543 | postgresql_client_encoding: sql_ascii # 'sql_ascii' actually defaults to database encoding 544 | 545 | # These settings are initialized by initdb, but they can be changed. 546 | 547 | # locale for system error message 548 | postgresql_lc_messages: en_US.UTF-8 549 | # locale for monetary formatting 550 | postgresql_lc_monetary: en_US.UTF-8 551 | # locale for number formatting 552 | postgresql_lc_numeric: en_US.UTF-8 553 | # locale for time formatting 554 | postgresql_lc_time: en_US.UTF-8 555 | 556 | postgresql_default_text_search_config: pg_catalog.english 557 | 558 | postgresql_dynamic_library_path: '$libdir' 559 | postgresql_local_preload_libraries: [] 560 | 561 | 562 | #------------------------------------------------------------------------------ 563 | # LOCK MANAGEMENT 564 | #------------------------------------------------------------------------------ 565 | 566 | postgresql_deadlock_timeout: 1s 567 | postgresql_max_locks_per_transaction: 64 # min 10 568 | 569 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 570 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 571 | # lock table slots. 572 | postgresql_max_pred_locks_per_transaction: 64 # min 10 573 | 574 | 575 | #------------------------------------------------------------------------------ 576 | # VERSION/PLATFORM COMPATIBILITY 577 | #------------------------------------------------------------------------------ 578 | 579 | # - Previous PostgreSQL Versions - 580 | 581 | postgresql_array_nulls: on 582 | postgresql_backslash_quote: safe_encoding # on, off, or safe_encoding 583 | postgresql_default_with_oids: off 584 | postgresql_escape_string_warning: on 585 | postgresql_lo_compat_privileges: off 586 | postgresql_quote_all_identifiers: off 587 | postgresql_sql_inheritance: on 588 | postgresql_standard_conforming_strings: on 589 | postgresql_synchronize_seqscans: on 590 | 591 | 592 | # - Other Platforms and Clients - 593 | 594 | postgresql_transform_null_equals: off 595 | 596 | 597 | #------------------------------------------------------------------------------ 598 | # ERROR HANDLING 599 | #------------------------------------------------------------------------------ 600 | 601 | # Terminate session on any error? 602 | postgresql_exit_on_error: off 603 | # Reinitialize after backend crash? 604 | postgresql_restart_after_crash: on 605 | 606 | 607 | 608 | 609 | postgresql_env: 610 | LC_ALL: "{{ postgresql_locale }}" 611 | LC_LCTYPE: "{{ postgresql_locale }}" 612 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/handlers/main.yml 2 | 3 | - name: restart postgresql 4 | service: 5 | name: postgresql 6 | state: restarted 7 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/meta/.galaxy_install_info: -------------------------------------------------------------------------------- 1 | {install_date: 'Fri Apr 3 11:01:04 2015', version: v1.1.0} 2 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.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.4 8 | license: MIT 9 | platforms: 10 | - name: Ubuntu 11 | versions: 12 | - all 13 | categories: 14 | - database 15 | - database:sql 16 | 17 | dependencies: [] 18 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/tasks/configure.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/configure.yml 2 | 3 | - name: PostgreSQL | Make sure the postgres data directory exists 4 | file: 5 | path: "{{postgresql_data_directory}}" 6 | owner: "{{ postgresql_service_user }}" 7 | group: "{{ postgresql_service_group }}" 8 | state: directory 9 | mode: 0700 10 | register: pgdata_dir_exist 11 | 12 | - name: PostgreSQL | Reset the cluster - drop the existing one 13 | shell: pg_dropcluster --stop {{postgresql_version}} {{postgresql_cluster_name}} 14 | sudo: yes 15 | sudo_user: "{{ postgresql_service_user }}" 16 | when: postgresql_cluster_reset and pgdata_dir_exist.changed 17 | 18 | - name: PostgreSQL | Reset the cluster - create a new one (with specified encoding and locale) 19 | shell: pg_createcluster --start --locale {{postgresql_locale}} -e {{postgresql_encoding}} -d {{postgresql_data_directory}} {{postgresql_version}} {{postgresql_cluster_name}} 20 | sudo: yes 21 | sudo_user: "{{ postgresql_service_user }}" 22 | when: postgresql_cluster_reset and pgdata_dir_exist.changed 23 | 24 | - name: PostgreSQL | Update configuration - pt. 1 (pg_hba.conf) 25 | template: 26 | src: pg_hba.conf.j2 27 | dest: "{{postgresql_conf_directory}}/pg_hba.conf" 28 | owner: "{{ postgresql_service_user }}" 29 | group: "{{ postgresql_service_group }}" 30 | mode: 0640 31 | register: postgresql_configuration_pt1 32 | 33 | - name: PostgreSQL | Update configuration - pt. 2 (postgresql.conf) 34 | template: 35 | src: postgresql.conf.j2 36 | dest: "{{postgresql_conf_directory}}/postgresql.conf" 37 | owner: "{{ postgresql_service_user }}" 38 | group: "{{ postgresql_service_group }}" 39 | mode: 0640 40 | register: postgresql_configuration_pt2 41 | 42 | - name: PostgreSQL | Create folder for additional configuration files 43 | file: 44 | name: "{{postgresql_conf_directory}}/conf.d" 45 | state: directory 46 | owner: "{{ postgresql_service_user }}" 47 | group: "{{ postgresql_service_group }}" 48 | mode: 0755 49 | 50 | - name: PostgreSQL | Restart PostgreSQL 51 | service: 52 | name: postgresql 53 | state: restarted 54 | when: postgresql_configuration_pt1.changed or postgresql_configuration_pt2.changed 55 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/tasks/databases.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/databases.yml 2 | 3 | - name: PostgreSQL | Ensure PostgreSQL is running 4 | service: 5 | name: postgresql 6 | state: started 7 | 8 | - name: PostgreSQL | Make sure the PostgreSQL databases are present 9 | postgresql_db: 10 | name: "{{item.name}}" 11 | owner: "{{postgresql_database_owner}}" 12 | encoding: "{{postgresql_encoding}}" 13 | lc_collate: "{{postgresql_locale}}" 14 | lc_ctype: "{{postgresql_locale}}" 15 | port: "{{postgresql_port}}" 16 | template: "template0" 17 | state: present 18 | login_user: "{{postgresql_admin_user}}" 19 | sudo: yes 20 | sudo_user: "{{postgresql_admin_user}}" 21 | with_items: postgresql_databases 22 | when: postgresql_databases|length > 0 23 | 24 | - name: PostgreSQL | Add hstore to the databases with the requirement 25 | sudo: yes 26 | sudo_user: "{{ postgresql_service_user }}" 27 | shell: "psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS hstore;'" 28 | with_items: postgresql_databases 29 | when: item.hstore is defined and item.hstore 30 | 31 | - name: PostgreSQL | Add uuid-ossp to the database with the requirement 32 | sudo: yes 33 | sudo_user: "{{ postgresql_service_user }}" 34 | shell: "psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'" 35 | with_items: postgresql_databases 36 | register: uuid_ext_result 37 | failed_when: uuid_ext_result.rc != 0 and ("already exists, skipping" not in uuid_ext_result.stderr) 38 | changed_when: uuid_ext_result.rc == 0 and ("already exists, skipping" not in uuid_ext_result.stderr) 39 | when: item.uuid_ossp is defined and item.uuid_ossp 40 | 41 | - name: PostgreSQL | Add postgis to the databases with the requirement 42 | sudo: yes 43 | sudo_user: "{{ postgresql_service_user }}" 44 | shell: "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;'" 45 | with_items: postgresql_databases 46 | when: item.gis is defined and item.gis 47 | 48 | - name: postgresql | add cube to the database with the requirement 49 | sudo: yes 50 | sudo_user: "{{ postgresql_service_user }}" 51 | shell: "psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists cube;'" 52 | with_items: postgresql_databases 53 | when: item.cube is defined and item.cube 54 | 55 | - name: PostgreSQL | Add plpgsql to the database with the requirement 56 | sudo: yes 57 | sudo_user: "{{ postgresql_service_user }}" 58 | shell: "psql {{item.name}} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS plpgsql;'" 59 | with_items: postgresql_databases 60 | when: item.plpgsql is defined and item.plpgsql 61 | 62 | - name: postgresql | add earthdistance to the database with the requirement 63 | sudo: yes 64 | sudo_user: "{{ postgresql_service_user }}" 65 | shell: "psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists earthdistance;'" 66 | with_items: postgresql_databases 67 | when: item.earthdistance is defined and item.earthdistance 68 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.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 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.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 4 | apt: 5 | name: "postgresql-contrib-{{postgresql_version}}" 6 | state: present 7 | notify: 8 | - restart postgresql 9 | 10 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.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 4 | apt: 5 | name: libpq-dev 6 | state: present 7 | notify: 8 | - restart postgresql 9 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.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 | with_items: 8 | - libgeos-c1 9 | - "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}" 10 | - "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}-scripts" 11 | notify: 12 | - restart postgresql 13 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/tasks/install.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/install.yml 2 | 3 | - name: PostgreSQL | Make sure the dependencies are installed 4 | apt: 5 | pkg: "{{item}}" 6 | state: present 7 | with_items: ["python-psycopg2", "python-pycurl"] 8 | 9 | - name: PostgreSQL | Add PostgreSQL repository apt-key 10 | apt_key: 11 | id: ACCC4CF8 12 | url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" 13 | state: present 14 | 15 | - name: PostgreSQL | Add PostgreSQL repository 16 | apt_repository: 17 | repo: 'deb http://apt.postgresql.org/pub/repos/apt/ {{ansible_distribution_release}}-pgdg main' 18 | state: present 19 | 20 | - name: PostgreSQL | Install PostgreSQL 21 | apt: 22 | name: "{{item}}" 23 | state: present 24 | environment: postgresql_env 25 | with_items: 26 | - "postgresql-{{postgresql_version}}" 27 | - "postgresql-client-{{postgresql_version}}" 28 | - "postgresql-contrib-{{postgresql_version}}" 29 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/main.yml 2 | 3 | - include: install.yml 4 | tags: [postgresql, postgresql-install] 5 | 6 | - include: extensions.yml 7 | tags: [postgresql, postgresql-extensions] 8 | 9 | - include: configure.yml 10 | tags: [postgresql, postgresql-configure] 11 | 12 | - include: users.yml 13 | tags: [postgresql, postgresql-users] 14 | 15 | - include: databases.yml 16 | tags: [postgresql, postgresql-databases] 17 | 18 | - include: users_privileges.yml 19 | tags: [postgresql, postgresql-users] 20 | 21 | - include: monit.yml 22 | when: monit_protection is defined and monit_protection == true 23 | tags: [postgresql, postgresql-monit] 24 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.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 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/tasks/users.yml: -------------------------------------------------------------------------------- 1 | # file: postgresql/tasks/users.yml 2 | 3 | - name: PostgreSQL | Ensure PostgreSQL is running 4 | service: 5 | name: postgresql 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('pass')}}" 12 | port: "{{postgresql_port}}" 13 | state: present 14 | login_user: "{{postgresql_admin_user}}" 15 | sudo: yes 16 | sudo_user: "{{postgresql_admin_user}}" 17 | with_items: postgresql_users 18 | when: postgresql_users|length > 0 19 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.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}}" 7 | port: "{{postgresql_port}}" 8 | priv: "{{item.priv | default('ALL')}}" 9 | state: present 10 | login_host: "{{item.host | default('localhost')}}" 11 | login_user: "{{postgresql_admin_user}}" 12 | role_attr_flags: "{{item.role_attr_flags | default('')}}" 13 | sudo: yes 14 | sudo_user: "{{postgresql_admin_user}}" 15 | with_items: postgresql_user_privileges 16 | when: postgresql_users|length > 0 17 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/templates/etc_monit_conf.d_postgresql.j2: -------------------------------------------------------------------------------- 1 | check process postgresql with pidfile /var/run/postgresql/{{postgresql_version}}-{{postgresql_cluster_name}}.pid 2 | group database 3 | start program = "/etc/init.d/postgresql start" 4 | stop program = "/etc/init.d/postgresql stop" 5 | if failed host localhost port 5432 protocol pgsql then restart 6 | if 5 restarts within 5 cycles then timeout 7 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/templates/pg_hba.conf.j2: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # =================================================== 3 | # 4 | # Refer to the "Client Authentication" section in the PostgreSQL 5 | # documentation for a complete description of this file. A short 6 | # synopsis follows. 7 | # 8 | # This file controls: which hosts are allowed to connect, how clients 9 | # are authenticated, which PostgreSQL user names they can use, which 10 | # databases they can access. Records take one of these forms: 11 | # 12 | # local DATABASE USER METHOD [OPTIONS] 13 | # host DATABASE USER ADDRESS METHOD [OPTIONS] 14 | # hostssl DATABASE USER ADDRESS METHOD [OPTIONS] 15 | # hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] 16 | # 17 | # TYPE DATABASE USER ADDRESS METHOD 18 | 19 | # Default: 20 | {% for connection in postgresql_pg_hba_default %} 21 | # {{connection.comment}} 22 | {{connection.type}} {{connection.database}} {{connection.user}} {{connection.address}} {{connection.method}} 23 | {% endfor %} 24 | 25 | # Password hosts 26 | {% for host in postgresql_pg_hba_passwd_hosts %} 27 | host all all {{host}} password 28 | {% endfor %} 29 | 30 | # Trusted hosts 31 | {% for host in postgresql_pg_hba_trust_hosts %} 32 | host all all {{host}} trust 33 | {% endfor %} 34 | 35 | # User custom 36 | {% for connection in postgresql_pg_hba_custom %} 37 | # {{connection.comment}} 38 | {{connection.type}} {{connection.database}} {{connection.user}} {{connection.address}} {{connection.method}} 39 | {% endfor %} 40 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/templates/postgresql.conf.j2: -------------------------------------------------------------------------------- 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 | data_directory = '{{postgresql_data_directory}}' 39 | 40 | hba_file = '{{postgresql_hba_file}}' 41 | 42 | ident_file = '{{postgresql_ident_file}}' 43 | 44 | external_pid_file = '{{postgresql_external_pid_file}}' 45 | 46 | 47 | #------------------------------------------------------------------------------ 48 | # CONNECTIONS AND AUTHENTICATION 49 | #------------------------------------------------------------------------------ 50 | 51 | listen_addresses = '{{postgresql_listen_addresses|join(',')}}' 52 | port = {{postgresql_port}} 53 | 54 | max_connections = {{postgresql_max_connections}} 55 | superuser_reserved_connections = {{postgresql_superuser_reserved_connections}} 56 | 57 | unix_socket_directories = '{{postgresql_unix_socket_directories|join(',')}}' 58 | unix_socket_group = '{{postgresql_unix_socket_group}}' 59 | unix_socket_permissions = {{postgresql_unix_socket_permissions}} 60 | 61 | bonjour = {{'on' if postgresql_bonjour else 'off'}} 62 | bonjour_name = '{{postgresql_bonjour_name}}' 63 | 64 | 65 | # - Security and Authentication - 66 | 67 | authentication_timeout = {{postgresql_authentication_timeout}} 68 | ssl = {{'on' if postgresql_ssl else 'off'}} 69 | ssl_ciphers = '{{postgresql_ssl_ciphers|join(':')}}' 70 | ssl_renegotiation_limit = {{postgresql_ssl_renegotiation_limit}} 71 | ssl_cert_file = '{{postgresql_ssl_cert_file}}' 72 | ssl_key_file = '{{postgresql_ssl_key_file}}' 73 | ssl_ca_file = '{{postgresql_ssl_ca_file}}' 74 | ssl_crl_file = '{{postgresql_ssl_crl_file}}' 75 | password_encryption = {{'on' if postgresql_password_encryption else 'off'}} 76 | db_user_namespace = {{'on' if postgresql_db_user_namespace else 'off'}} 77 | 78 | # Kerberos and GSSAPI 79 | krb_server_keyfile = '{{postgresql_krb_server_keyfile}}' 80 | krb_srvname = '{{postgresql_krb_srvname}}' 81 | krb_caseins_users = {{'on' if postgresql_db_user_namespace else 'off'}} 82 | 83 | # TCP Keepalives, 0 selects the system default 84 | tcp_keepalives_idle = {{postgresql_tcp_keepalives_idle}} 85 | tcp_keepalives_interval = {{postgresql_tcp_keepalives_interval}} 86 | tcp_keepalives_count = {{postgresql_tcp_keepalives_count}} 87 | 88 | 89 | #------------------------------------------------------------------------------ 90 | # RESOURCE USAGE (except WAL) 91 | #------------------------------------------------------------------------------ 92 | 93 | # - Memory - 94 | 95 | shared_buffers = {{postgresql_shared_buffers}} 96 | temp_buffers = {{postgresql_temp_buffers}} 97 | 98 | max_prepared_transactions = {{postgresql_max_prepared_transactions}} 99 | 100 | work_mem = {{postgresql_work_mem}} 101 | maintenance_work_mem = {{postgresql_maintenance_work_mem}} 102 | max_stack_depth = {{postgresql_max_stack_depth}} 103 | 104 | 105 | # - Disk - 106 | 107 | temp_file_limit = {{postgresql_temp_file_limit}} 108 | 109 | 110 | # - Kernel Resource Usage - 111 | 112 | max_files_per_process = {{postgresql_max_files_per_process}} 113 | shared_preload_libraries = '{{postgresql_shared_preload_libraries|join(',')}}' 114 | 115 | 116 | # - Cost-Based Vacuum Delay - 117 | 118 | vacuum_cost_delay = {{postgresql_vacuum_cost_delay}} 119 | vacuum_cost_page_hit = {{postgresql_vacuum_cost_page_hit}} 120 | vacuum_cost_page_miss = {{postgresql_vacuum_cost_page_miss}} 121 | vacuum_cost_page_dirty = {{postgresql_vacuum_cost_page_dirty}} 122 | vacuum_cost_limit = {{postgresql_vacuum_cost_limit}} 123 | 124 | 125 | # - Background Writer - 126 | 127 | bgwriter_delay = {{postgresql_bgwriter_delay}} 128 | bgwriter_lru_maxpages = {{postgresql_bgwriter_lru_maxpages}} 129 | bgwriter_lru_multiplier = {{postgresql_bgwriter_lru_multiplier}} 130 | 131 | 132 | # - Asynchronous Behavior - 133 | 134 | effective_io_concurrency = {{postgresql_effective_io_concurrency}} 135 | 136 | 137 | #------------------------------------------------------------------------------ 138 | # WRITE AHEAD LOG 139 | #------------------------------------------------------------------------------ 140 | 141 | # - Settings - 142 | 143 | wal_level = {{postgresql_wal_level}} 144 | fsync = {{'on' if postgresql_fsync else 'off'}} 145 | 146 | synchronous_commit = {{postgresql_synchronous_commit}} 147 | 148 | wal_sync_method = {{postgresql_wal_sync_method}} 149 | 150 | full_page_writes = {{'on' if postgresql_full_page_writes else 'off'}} 151 | 152 | wal_buffers = {{postgresql_wal_buffers}} 153 | wal_writer_delay = {{postgresql_wal_writer_delay}} 154 | commit_delay = {{postgresql_commit_delay}} 155 | commit_siblings = {{postgresql_commit_siblings}} 156 | 157 | 158 | # - Checkpoints - 159 | 160 | checkpoint_segments = {{postgresql_checkpoint_segments}} 161 | checkpoint_timeout = {{postgresql_checkpoint_timeout}} 162 | checkpoint_completion_target = {{postgresql_checkpoint_completion_target}} 163 | checkpoint_warning = {{postgresql_checkpoint_warning}} 164 | 165 | 166 | # - Archiving - 167 | 168 | archive_mode = {{'on' if postgresql_archive_mode else 'off'}} 169 | archive_command = '{{postgresql_archive_command}}' 170 | archive_timeout = {{postgresql_archive_timeout}} 171 | 172 | 173 | #------------------------------------------------------------------------------ 174 | # REPLICATION 175 | #------------------------------------------------------------------------------ 176 | 177 | # - Sending Server(s) - 178 | 179 | max_wal_senders = {{postgresql_max_wal_senders}} 180 | wal_keep_segments = {{postgresql_wal_keep_segments}} 181 | wal_sender_timeout = {{postgresql_wal_sender_timeout}} 182 | 183 | 184 | # - Master Server - 185 | 186 | synchronous_standby_names = '{{postgresql_synchronous_standby_names|join(',')}}' 187 | 188 | vacuum_defer_cleanup_age = {{postgresql_vacuum_defer_cleanup_age}} 189 | 190 | 191 | # - Standby Servers - 192 | 193 | hot_standby = {{'on' if postgresql_hot_standby else 'off'}} 194 | max_standby_archive_delay = {{postgresql_max_standby_archive_delay}} 195 | max_standby_streaming_delay = {{postgresql_max_standby_streaming_delay}} 196 | wal_receiver_status_interval = {{postgresql_wal_receiver_status_interval}} 197 | hot_standby_feedback = {{'on' if postgresql_hot_standby_feedback or 'off'}} 198 | wal_receiver_timeout = {{postgresql_wal_receiver_timeout}} 199 | 200 | 201 | #------------------------------------------------------------------------------ 202 | # QUERY TUNING 203 | #------------------------------------------------------------------------------ 204 | 205 | # - Planner Method Configuration - 206 | 207 | enable_bitmapscan = {{'on' if postgresql_enable_bitmapscan else 'off'}} 208 | enable_hashagg = {{'on' if postgresql_enable_hashagg else 'off'}} 209 | enable_hashjoin = {{'on' if postgresql_enable_hashjoin else 'off'}} 210 | enable_indexscan = {{'on' if postgresql_enable_indexscan else 'off'}} 211 | enable_indexonlyscan = {{'on' if postgresql_enable_indexonlyscan else 'off'}} 212 | enable_material = {{'on' if postgresql_enable_material else 'off'}} 213 | enable_mergejoin = {{'on' if postgresql_enable_mergejoin else 'off'}} 214 | enable_nestloop = {{'on' if postgresql_enable_nestloop else 'off'}} 215 | enable_seqscan = {{'on' if postgresql_enable_seqscan else 'off'}} 216 | enable_sort = {{'on' if postgresql_enable_sort else 'off'}} 217 | enable_tidscan = {{'on' if postgresql_enable_tidscan else 'off'}} 218 | 219 | 220 | # - Planner Cost Constants - 221 | 222 | seq_page_cost = {{postgresql_seq_page_cost}} 223 | random_page_cost = {{postgresql_random_page_cost}} 224 | cpu_tuple_cost = {{postgresql_cpu_tuple_cost}} 225 | cpu_index_tuple_cost = {{postgresql_cpu_index_tuple_cost}} 226 | cpu_operator_cost = {{postgresql_cpu_operator_cost}} 227 | effective_cache_size = {{postgresql_effective_cache_size}} 228 | 229 | 230 | # - Genetic Query Optimizer - 231 | 232 | geqo = {{'on' if postgresql_enable_tidscan else 'off'}} 233 | geqo_threshold = {{postgresql_geqo_threshold}} 234 | geqo_effort = {{postgresql_geqo_effort}} 235 | geqo_pool_size = {{postgresql_geqo_pool_size}} 236 | geqo_generations = {{postgresql_geqo_generations}} 237 | geqo_selection_bias = {{postgresql_geqo_selection_bias}} 238 | geqo_seed = {{postgresql_geqo_seed}} 239 | 240 | 241 | # - Other Planner Options - 242 | 243 | default_statistics_target = {{postgresql_default_statistics_target}} 244 | constraint_exclusion = {{postgresql_constraint_exclusion}} 245 | cursor_tuple_fraction = {{postgresql_cursor_tuple_fraction}} 246 | from_collapse_limit = {{postgresql_from_collapse_limit}} 247 | join_collapse_limit = {{postgresql_join_collapse_limit}} 248 | 249 | 250 | #------------------------------------------------------------------------------ 251 | # ERROR REPORTING AND LOGGING 252 | #------------------------------------------------------------------------------ 253 | 254 | # - Where to Log - 255 | 256 | log_destination = '{{postgresql_log_destination}}' 257 | 258 | logging_collector = {{'on' if postgresql_logging_collector else 'off'}} 259 | 260 | log_directory = '{{postgresql_log_directory}}' 261 | log_filename = '{{postgresql_log_filename}}' 262 | log_file_mode = {{postgresql_log_file_mode}} 263 | log_truncate_on_rotation = {{'on' if postgresql_log_truncate_on_rotation else 'off'}} 264 | log_rotation_age = {{postgresql_log_rotation_age}} 265 | log_rotation_size = {{postgresql_log_rotation_size}} 266 | 267 | syslog_facility = '{{postgresql_syslog_facility}}' 268 | syslog_ident = '{{postgresql_syslog_ident}}' 269 | 270 | event_source = '{{postgresql_event_source}}' 271 | 272 | 273 | # - When to Log - 274 | 275 | client_min_messages = {{postgresql_client_min_messages}} 276 | 277 | log_min_messages = {{postgresql_log_min_messages}} 278 | log_min_error_statement = {{postgresql_log_min_error_statement}} 279 | log_min_duration_statement = {{postgresql_log_min_duration_statement}} 280 | 281 | 282 | # - What to Log - 283 | 284 | debug_print_parse = {{'on' if postgresql_debug_print_parse else 'off'}} 285 | debug_print_rewritten = {{'on' if postgresql_debug_print_rewritten else 'off'}} 286 | debug_print_plan = {{'on' if postgresql_debug_print_plan else 'off'}} 287 | debug_pretty_print = {{'on' if postgresql_debug_pretty_print else 'off'}} 288 | log_checkpoints = {{'on' if postgresql_log_checkpoints else 'off'}} 289 | log_connections = {{'on' if postgresql_log_connections else 'off'}} 290 | log_disconnections = {{'on' if postgresql_log_disconnections else 'off'}} 291 | log_duration = {{'on' if postgresql_log_duration else 'off'}} 292 | log_error_verbosity = {{postgresql_log_error_verbosity}} # terse, default, or verbose messages 293 | log_hostname = {{'on' if postgresql_log_duration else 'off'}} 294 | log_line_prefix = '{{postgresql_log_line_prefix}}' 295 | log_lock_waits = {{'on' if postgresql_log_lock_waits else 'off'}} 296 | log_statement = '{{postgresql_log_statement}}' 297 | log_temp_files = {{postgresql_log_temp_files}} 298 | log_timezone = '{{postgresql_log_timezone}}' 299 | 300 | 301 | #------------------------------------------------------------------------------ 302 | # RUNTIME STATISTICS 303 | #------------------------------------------------------------------------------ 304 | 305 | # - Query/Index Statistics Collector - 306 | 307 | track_activities = {{'on' if postgresql_track_activities else 'off'}} 308 | track_counts = {{'on' if postgresql_track_counts else 'off'}} 309 | track_io_timing = {{'on' if postgresql_track_io_timing else 'off'}} 310 | track_functions = {{postgresql_track_functions}} # none, pl, all 311 | track_activity_query_size = {{postgresql_track_activity_query_size}} 312 | update_process_title = {{'on' if postgresql_update_process_title else 'off'}} 313 | stats_temp_directory = '{{postgresql_stats_temp_directory}}' 314 | 315 | 316 | # - Statistics Monitoring - 317 | 318 | log_parser_stats = {{'on' if postgresql_log_parser_stats else 'off'}} 319 | log_planner_stats = {{'on' if postgresql_log_planner_stats else 'off'}} 320 | log_executor_stats = {{'on' if postgresql_log_executor_stats else 'off'}} 321 | log_statement_stats = {{'on' if postgresql_log_statement_stats else 'off'}} 322 | 323 | 324 | #------------------------------------------------------------------------------ 325 | # AUTOVACUUM PARAMETERS 326 | #------------------------------------------------------------------------------ 327 | 328 | autovacuum = {{'on' if postgresql_autovacuum else 'off'}} 329 | log_autovacuum_min_duration = {{postgresql_log_autovacuum_min_duration}} 330 | autovacuum_max_workers = {{postgresql_autovacuum_max_workers}} 331 | autovacuum_naptime = {{postgresql_autovacuum_naptime}} 332 | autovacuum_vacuum_threshold = {{postgresql_autovacuum_vacuum_threshold}} 333 | autovacuum_analyze_threshold = {{postgresql_autovacuum_analyze_threshold}} 334 | autovacuum_vacuum_scale_factor = {{postgresql_autovacuum_vacuum_scale_factor}} 335 | autovacuum_analyze_scale_factor = {{postgresql_autovacuum_analyze_scale_factor}} 336 | autovacuum_freeze_max_age = {{postgresql_autovacuum_freeze_max_age}} 337 | autovacuum_vacuum_cost_delay = {{postgresql_autovacuum_vacuum_cost_delay}} 338 | autovacuum_vacuum_cost_limit = {{postgresql_autovacuum_vacuum_cost_limit}} 339 | 340 | 341 | #------------------------------------------------------------------------------ 342 | # CLIENT CONNECTION DEFAULTS 343 | #------------------------------------------------------------------------------ 344 | 345 | # - Statement Behavior - 346 | 347 | search_path = '{{postgresql_search_path|join(',')}}' 348 | default_tablespace = '{{postgresql_default_tablespace}}' 349 | temp_tablespaces = '{{postgresql_temp_tablespaces|join(',')}}' 350 | 351 | check_function_bodies = {{'on' if postgresql_check_function_bodies else 'off'}} 352 | default_transaction_isolation = '{{postgresql_default_transaction_isolation}}' 353 | default_transaction_read_only = {{'on' if postgresql_default_transaction_read_only else 'off'}} 354 | default_transaction_deferrable = {{'on' if postgresql_default_transaction_deferrable else 'off'}} 355 | session_replication_role = '{{postgresql_session_replication_role}}' 356 | 357 | statement_timeout = {{postgresql_statement_timeout}} 358 | lock_timeout = {{postgresql_lock_timeout}} 359 | vacuum_freeze_min_age = {{postgresql_vacuum_freeze_min_age}} 360 | vacuum_freeze_table_age = {{postgresql_vacuum_freeze_table_age}} 361 | 362 | bytea_output = '{{postgresql_bytea_output}}' 363 | xmlbinary = '{{postgresql_xmlbinary}}' 364 | xmloption = '{{postgresql_xmloption}}' 365 | 366 | 367 | # - Locale and Formatting - 368 | 369 | datestyle = '{{postgresql_datestyle|join(',')}}' 370 | intervalstyle = '{{postgresql_intervalstyle}}' 371 | timezone = '{{postgresql_timezone}}' 372 | 373 | timezone_abbreviations = '{{postgresql_timezone_abbreviations}}' 374 | 375 | extra_float_digits = {{postgresql_extra_float_digits}} 376 | client_encoding = {{postgresql_client_encoding}} 377 | 378 | lc_messages = '{{postgresql_lc_messages}}' 379 | lc_monetary = '{{postgresql_lc_monetary}}' 380 | lc_numeric = '{{postgresql_lc_numeric}}' 381 | lc_time = '{{postgresql_lc_time}}' 382 | 383 | default_text_search_config = '{{postgresql_default_text_search_config}}' 384 | 385 | dynamic_library_path = '{{postgresql_dynamic_library_path}}' 386 | local_preload_libraries = '{{postgresql_local_preload_libraries|join(',')}}' 387 | 388 | 389 | #------------------------------------------------------------------------------ 390 | # LOCK MANAGEMENT 391 | #------------------------------------------------------------------------------ 392 | 393 | deadlock_timeout = {{postgresql_deadlock_timeout}} 394 | max_locks_per_transaction = {{postgresql_max_locks_per_transaction}} 395 | 396 | max_pred_locks_per_transaction = {{postgresql_max_pred_locks_per_transaction}} 397 | 398 | 399 | #------------------------------------------------------------------------------ 400 | # VERSION/PLATFORM COMPATIBILITY 401 | #------------------------------------------------------------------------------ 402 | 403 | # - Previous PostgreSQL Versions - 404 | 405 | array_nulls = {{'on' if postgresql_array_nulls else 'off'}} 406 | backslash_quote = {{postgresql_backslash_quote}} # on, off, or safe_encoding 407 | default_with_oids = {{'on' if postgresql_default_with_oids else 'off'}} 408 | escape_string_warning = {{'on' if postgresql_escape_string_warning else 'off'}} 409 | lo_compat_privileges = {{'on' if postgresql_lo_compat_privileges else 'off'}} 410 | quote_all_identifiers = {{'on' if postgresql_quote_all_identifiers else 'off'}} 411 | sql_inheritance = {{'on' if postgresql_sql_inheritance else 'off'}} 412 | standard_conforming_strings = {{'on' if postgresql_standard_conforming_strings else 'off'}} 413 | synchronize_seqscans = {{'on' if postgresql_synchronize_seqscans else 'off'}} 414 | 415 | 416 | # - Other Platforms and Clients - 417 | 418 | transform_null_equals = {{'on' if postgresql_transform_null_equals else 'off'}} 419 | 420 | 421 | #------------------------------------------------------------------------------ 422 | # ERROR HANDLING 423 | #------------------------------------------------------------------------------ 424 | 425 | exit_on_error = {{'on' if postgresql_exit_on_error else 'off'}} 426 | restart_after_crash = {{'on' if postgresql_restart_after_crash else 'off'}} 427 | 428 | 429 | #------------------------------------------------------------------------------ 430 | # CONFIG FILE INCLUDES 431 | #------------------------------------------------------------------------------ 432 | 433 | # These options allow settings to be loaded from files other than the 434 | # default postgresql.conf. 435 | 436 | include_dir = 'conf.d' # include files ending in '.conf' from 437 | # directory 'conf.d' 438 | #include_if_exists = 'exists.conf' # include file only if it exists 439 | #include = 'special.conf' # include file 440 | 441 | 442 | #------------------------------------------------------------------------------ 443 | # CUSTOMIZED OPTIONS 444 | #------------------------------------------------------------------------------ 445 | 446 | # Add settings for extensions here 447 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/test.yml: -------------------------------------------------------------------------------- 1 | - hosts: all 2 | vars_files: 3 | - defaults/main.yml 4 | - vars/test.yml 5 | tasks: 6 | - include: tasks/main.yml 7 | handlers: 8 | - include: handlers/main.yml 9 | -------------------------------------------------------------------------------- /Ansible/roles/ANXS.postgresql/vars/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | blah: one 3 | postgresql_databases: 4 | - name: foobar 5 | postgresql_users: 6 | - name: baz 7 | pass: pass 8 | postgresql_user_privileges: 9 | - name: baz 10 | db: foobar 11 | -------------------------------------------------------------------------------- /Ansible/roles/MaximeThoonsen.php5-xdebug/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | php_xdebug_remote_enable: "false" 3 | php_xdebug_remote_connect_back: "false" 4 | php_xdebug_remote_host: localhost 5 | php_xdebug_remote_port: "9000" 6 | php_xdebug_remote_log: /tmp/xdebug.log 7 | php_xdebug_idekey: XDEBUG 8 | php_max_nesting_level: 200 9 | -------------------------------------------------------------------------------- /Ansible/roles/MaximeThoonsen.php5-xdebug/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: php5 - install xdebug 3 | apt: pkg=php5-xdebug state=latest update_cache=yes 4 | 5 | - name: Copy xdebug INI into mods-available folder. 6 | template: > 7 | src=xdebug.ini.j2 8 | dest=/etc/php5/mods-available/xdebug.ini 9 | owner=root group=root mode=644 10 | when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty' 11 | 12 | - name: Copy xdebug INI into conf.d folder. 13 | template: > 14 | src=xdebug.ini.j2 15 | dest=/etc/php5/conf.d/xdebug.ini 16 | owner=root group=root mode=644 17 | when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'precise' -------------------------------------------------------------------------------- /Ansible/roles/MaximeThoonsen.php5-xdebug/templates/xdebug.ini.j2: -------------------------------------------------------------------------------- 1 | [XDebug] 2 | zend_extension="xdebug.so" 3 | xdebug.remote_enable={{ php_xdebug_remote_enable }} 4 | xdebug.remote_connect_back={{ php_xdebug_remote_connect_back }} 5 | xdebug.remote_host={{ php_xdebug_remote_host }} 6 | xdebug.remote_port={{ php_xdebug_remote_port }} 7 | xdebug.remote_handler="dbgp" 8 | xdebug.remote_log={{ php_xdebug_remote_log }} 9 | xdebug.idekey="{{ php_xdebug_idekey }}" 10 | xdebug.max_nesting_level = {{ php_max_nesting_level }} 11 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | commit = True 3 | current_version = 1.1.2 4 | tag = True 5 | tag_name = {new_version} 6 | 7 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | before_install: 5 | - sudo apt-get update -qq 6 | - sudo apt-get install -qq python-apt python-pycurl 7 | install: 8 | - pip install ansible>=1.6.0 9 | script: 10 | # Prepare tests 11 | - echo localhost > inventory 12 | 13 | # Check syntax 14 | - ansible-playbook --syntax-check -i inventory test.yml 15 | 16 | # First run 17 | - ansible-playbook -i inventory test.yml --connection=local --sudo 18 | 19 | # Second run Idempotence test 20 | - > 21 | ansible-playbook -i inventory test.yml --connection=local --sudo 22 | | grep -q 'changed=0.*failed=0' 23 | && (echo 'Idempotence test: pass' && exit 0) 24 | || (echo 'Idempotence test: fail' && exit 1) 25 | 26 | - command -v nodejs || exit 1 27 | - command -v npm || exit 1 28 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Stouts 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. -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: release major minor patch 2 | 3 | VERSION?=minor 4 | release: 5 | @bumpversion $(VERSION) 6 | @git checkout master 7 | @git merge develop 8 | @git checkout develop 9 | @git push --all 10 | @git push --tags 11 | @git checkout develop 12 | 13 | major: 14 | make release VERSION=major 15 | 16 | minor: 17 | make release VERSION=minor 18 | 19 | patch: 20 | make release VERSION=patch 21 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/README.md: -------------------------------------------------------------------------------- 1 | Stouts.nodejs 2 | ============= 3 | 4 | [![Build Status](http://img.shields.io/travis/Stouts/Stouts.nodejs.svg?style=flat-square)](https://travis-ci.org/Stouts/Stouts.nodejs) 5 | [![Galaxy](http://img.shields.io/badge/galaxy-Stouts.nodejs-blue.svg?style=flat-square)](https://galaxy.ansible.com/list#/roles/983) 6 | 7 | Ansible role which manage nodejs and npm packages. 8 | 9 | #### Requirements 10 | 11 | Only tested on ubuntu for now. 12 | 13 | #### Variables 14 | 15 | ```yaml 16 | nodejs_enabled: yes # The role is enabled 17 | 18 | nodejs_repository: ppa:chris-lea/node.js # NodeJS PPA 19 | nodejs_npm_modules: [] # List modules which will be installed 20 | ``` 21 | 22 | #### Usage 23 | 24 | Add `Stouts.nodejs` to your roles and set vars in your playbook file. 25 | 26 | Example: 27 | 28 | ```yaml 29 | 30 | - hosts: all 31 | 32 | roles: 33 | - Stouts.nodejs 34 | 35 | vars: 36 | nodejs_npm_modules: 37 | - bower 38 | - jshint 39 | ``` 40 | 41 | #### License 42 | 43 | Licensed under the MIT License. See the LICENSE file for details. 44 | 45 | #### Feedback, bug-reports, requests, ... 46 | 47 | Are [welcome](https://github.com/Stouts/Stouts.nodejs/issues)! 48 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | nodejs_enabled: yes # The role is enabled 4 | 5 | nodejs_repository: ppa:chris-lea/node.js # NodeJS PPA (Set empty for skip) 6 | nodejs_npm_modules: [] # List modules which will be installed 7 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/meta/.galaxy_install_info: -------------------------------------------------------------------------------- 1 | {install_date: 'Fri Apr 3 11:01:01 2015', version: 1.1.2} 2 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | dependencies: [] 4 | 5 | galaxy_info: 6 | author: klen 7 | company: Stouts 8 | description: Install nodejs, npm and npm modules 9 | license: MIT 10 | platforms: 11 | - name: Ubuntu 12 | versions: 13 | - all 14 | - name: Debian 15 | versions: 16 | - all 17 | - name: Fedora 18 | versions: 19 | - all 20 | categories: 21 | - development 22 | - system 23 | - web 24 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/tasks/install.deb.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install Ansible dependencies 4 | apt: pkg=python-pycurl 5 | 6 | - name: Add APT repository 7 | apt_repository: repo={{nodejs_repository}} 8 | when: nodejs_repository is defined 9 | 10 | - name: Install nodejs 11 | apt: pkg=nodejs 12 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/tasks/install.yum.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install nodejs 4 | yum: name=nodejs 5 | 6 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include: nodejs.yml 4 | when: nodejs_enabled 5 | tags: [nodejs] 6 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/tasks/nodejs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include: install.deb.yml 4 | when: ansible_pkg_mgr == 'apt' 5 | 6 | - include: install.yum.yml 7 | when: ansible_pkg_mgr == 'yum' 8 | 9 | - name: Install NPM modules 10 | npm: name={{item}} global=yes 11 | with_items: nodejs_npm_modules 12 | -------------------------------------------------------------------------------- /Ansible/roles/Stouts.nodejs/test.yml: -------------------------------------------------------------------------------- 1 | - hosts: all 2 | tasks: 3 | - include: tasks/main.yml 4 | vars_files: 5 | - defaults/main.yml 6 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/.gitignore: -------------------------------------------------------------------------------- 1 | tests/.vagrant 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | language: python 4 | 5 | python: 6 | - 2.7 7 | 8 | install: 9 | - pip install ansible==1.4.0 10 | 11 | script: 12 | - cd tests 13 | - ansible-playbook -i inventory playbook.yml --syntax-check 14 | - ansible-playbook -i inventory playbook.yml --sudo -vvvv 15 | - > 16 | ansible-playbook -i inventory playbook.yml --sudo 17 | | grep -q 'changed=0.*unreachable=0.*failed=0' 18 | && (echo 'Idempotence test: pass' && exit 0) 19 | || (echo 'Idempotence test: fail' && exit 1) 20 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Simon Constans 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 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/README.md: -------------------------------------------------------------------------------- 1 | # ansible-role-apache 2 | 3 | [![Build Status](https://travis-ci.org/kosssi/ansible-role-apache.svg?branch=master)](https://travis-ci.org/kosssi/ansible-role-apache) 4 | 5 | Install and configure apache. 6 | 7 | ## Role Defaults Variables 8 | 9 | apache_repository: ppa:ptn107/apache 10 | 11 | apache_install: 12 | - apache2 13 | 14 | apache_module_disable: false 15 | apache_module_enable: 16 | - rewrite 17 | 18 | apache_site_disable: 19 | - 000-default 20 | - default-ssl 21 | apache_site_enable: 22 | - test.dev 23 | 24 | apache_vhosts: 25 | - servername: test.dev 26 | index: index.php 27 | documentroot: /var/www/test 28 | directory_extra: 29 | - RewriteEngine On 30 | 31 | ## Example Playbook 32 | 33 | roles: 34 | - { role: kosssi.apache, tags: apache } 35 | 36 | ## License 37 | 38 | Licensed under the MIT License. See the [LICENSE](LICENSE) file for details. 39 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | apache_repository: ppa:ptn107/apache 4 | 5 | apache_install: 6 | - apache2 7 | 8 | apache_module_disable: false 9 | apache_module_enable: 10 | - rewrite 11 | 12 | apache_site_disable: 13 | - 000-default 14 | - default-ssl 15 | apache_site_enable: 16 | - test.dev 17 | 18 | apache_vhosts: 19 | - servername: test.dev 20 | index: index.php 21 | documentroot: /var/www/test 22 | directory_extra: 23 | - RewriteEngine On 24 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Restart apache 4 | service: 5 | name=apache2 6 | state=restarted 7 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/meta/.galaxy_install_info: -------------------------------------------------------------------------------- 1 | {install_date: 'Fri Apr 3 11:01:06 2015', version: v1.0.3} 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | galaxy_info: 4 | author: kosssi 5 | description: Install and Configure Apache 6 | license: license MIT 7 | min_ansible_version: 1.4 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - all 12 | - name: Debian 13 | versions: 14 | - all 15 | categories: 16 | - web 17 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Add repository to install last Apache version 4 | apt_repository: 5 | repo="{{ apache_repository }}" 6 | update_cache=yes 7 | when: apache_repository != false 8 | 9 | - name: Install packages. 10 | apt: 11 | pkg="{{ item }}" 12 | state=present 13 | with_items: apache_install 14 | when: apache_install != false 15 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include: install.yml 4 | - include: vhost.yml 5 | - include: module.yml 6 | - include: site.yml 7 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tasks/module.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Disable apache module 4 | shell: 5 | a2dismod {{ item }} 6 | register: apache_cmd 7 | changed_when: apache_cmd.stdout.endswith(' already disabled') == false 8 | notify: Restart apache 9 | with_items: apache_module_disable 10 | when: apache_module_disable != false 11 | 12 | - name: Enable apache module 13 | shell: 14 | a2enmod {{ item }} 15 | register: apache_cmd 16 | changed_when: apache_cmd.stdout.endswith(' already enabled') == false 17 | notify: Restart apache 18 | with_items: apache_module_enable 19 | when: apache_module_enable != false 20 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tasks/site.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Disable apache site 4 | shell: 5 | a2dissite {{ item }} 6 | register: apache_cmd 7 | changed_when: apache_cmd.stdout.endswith(' already disabled') == false 8 | notify: Restart apache 9 | with_items: apache_site_disable 10 | when: apache_site_disable != false 11 | 12 | - name: Enable apache site 13 | shell: 14 | a2ensite {{ item }} 15 | register: apache_cmd 16 | changed_when: apache_cmd.stdout.endswith(' already enabled') == false 17 | notify: Restart apache 18 | with_items: apache_site_enable 19 | when: apache_site_enable != false 20 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tasks/vhost.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Add apache vhosts configurations 4 | template: 5 | src=vhost.conf.j2 6 | dest=/etc/apache2/sites-available/{{ item.servername }}.conf 7 | owner=root group=root mode=644 8 | notify: Restart apache 9 | with_items: apache_vhosts 10 | when: apache_vhosts != false 11 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/templates/vhost.conf.j2: -------------------------------------------------------------------------------- 1 | DirectoryIndex {{ item.index | default('index.html') }} 2 | {% if item.extra is defined %}{% for extra in item.extra %} 3 | {{ extra }} 4 | {% endfor %}{% endif %} 5 | 6 | 7 | ServerName {{ item.servername }} 8 | DocumentRoot {{ item.documentroot }} 9 | ErrorLog {{ item.logDir | default('${APACHE_LOG_DIR}') }}/error.log 10 | CustomLog {{ item.logDir | default('${APACHE_LOG_DIR}') }}/access.log combined 11 | {% if item.serveradmin is defined %}ServerAdmin {{ item.serveradmin }}{% endif %} 12 | 13 | {% if item.virtualhost_extra is defined %}{% for extra in item.virtualhost_extra %} 14 | {{ extra }} 15 | {% endfor %}{% endif %} 16 | 17 | 18 | AllowOverride All 19 | Options -Indexes +FollowSymLinks 20 | Order allow,deny 21 | Allow from all 22 | Require all granted 23 | 24 | {% if item.directory_extra is defined %}{% for extra in item.directory_extra %} 25 | {{ extra }} 26 | {% endfor %}{% endif %} 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tests/Makefile: -------------------------------------------------------------------------------- 1 | test_ubuntu-14.04: 2 | VM_BOX='ubuntu/trusty64' vagrant up --provision 3 | VM_BOX='ubuntu/trusty64' vagrant provision 4 | VM_BOX='ubuntu/trusty64' vagrant destroy -f 5 | 6 | test_ubuntu-12.04: 7 | VM_BOX='hashicorp/precise64' vagrant up --provision 8 | VM_BOX='hashicorp/precise64' vagrant provision 9 | VM_BOX='hashicorp/precise64' vagrant destroy -f 10 | 11 | test_debian-7.5: 12 | VM_BOX='puphpet/debian75-x64' vagrant up --provision 13 | VM_BOX='puphpet/debian75-x64' vagrant provision 14 | VM_BOX='puphpet/debian75-x64' vagrant destroy -f 15 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tests/Vagrantfile: -------------------------------------------------------------------------------- 1 | $VM_BOX = ENV.has_key?('VM_BOX') ? ENV['VM_BOX'] : 'ubuntu/trusty64' 2 | 3 | Vagrant.configure('2') do |config| 4 | config.vm.box = $VM_BOX 5 | 6 | config.vm.provision :ansible do |ansible| 7 | ansible.playbook = 'playbook.yml' 8 | ansible.extra_vars = { ansible_ssh_user: 'vagrant', vagrant: true } 9 | 10 | ansible.verbose = 'v' 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost ansible_connection=local 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apache/tests/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | sudo: true 5 | roles: 6 | - { role: ../../ansible-role-apache, tags: apache } 7 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/.gitignore: -------------------------------------------------------------------------------- 1 | tests/.vagrant 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | language: python 4 | 5 | python: 6 | - 2.7 7 | 8 | install: 9 | - pip install ansible==1.4.0 10 | 11 | script: 12 | - cd tests 13 | - ansible-playbook -i inventory playbook.yml --syntax-check 14 | - ansible-playbook -i inventory playbook.yml --connection=local --sudo 15 | - > 16 | ansible-playbook -i inventory playbook.yml --connection=local --sudo 17 | | grep -q 'changed=0.*unreachable=0.*failed=0' 18 | && (echo 'Idempotence test: pass' && exit 0) 19 | || (echo 'Idempotence test: fail' && exit 1) 20 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Simon Constans 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 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/README.md: -------------------------------------------------------------------------------- 1 | kosssi.apt 2 | ========== 3 | 4 | [![Build Status](https://travis-ci.org/kosssi/ansible-role-apt.svg?branch=master)](https://travis-ci.org/kosssi/ansible-role-apt) 5 | 6 | Ansible role for execute apt-get update and install apt-repositories and apt-packages. 7 | 8 | Role Defaults Variables 9 | ----------------------- 10 | 11 | See [defaults/main.yml](defaults/main.yml) for more information. 12 | 13 | apt_cache_valid_time: 3600 14 | apt_upgrade: true 15 | apt_upgrade_type: safe # safe, full or dist 16 | apt_install: 17 | - python-apt 18 | - unattended-upgrades 19 | apt_install_repositories: false 20 | apt_remove_repositories: false 21 | 22 | Example Playbook 23 | ---------------- 24 | 25 | - hosts: localhost 26 | vars: 27 | apt_install: [cowsay, cowthink, sl, figlet] 28 | roles: 29 | - { role: kosssi.apt, tags: apt } 30 | 31 | License 32 | ------- 33 | 34 | Licensed under the MIT License. See the [LICENSE](LICENSE) file for details. 35 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.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_install: false 14 | # apt_install: 15 | # - python-apt 16 | # - unattended-upgrades 17 | 18 | apt_install_repositories: false 19 | # apt_install_repositories: 20 | # - ppa:ondrej/php5 21 | 22 | apt_remove_repositories: false 23 | # apt_remove_repositories: 24 | # - ppa:ondrej/php5 25 | 26 | apt_remove: false 27 | # apt_remove: 28 | # - python-apt 29 | # - unattended-upgrades 30 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/meta/.galaxy_install_info: -------------------------------------------------------------------------------- 1 | {install_date: 'Fri Apr 3 11:00:54 2015', version: v2.0.0} 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | galaxy_info: 4 | author: kosssi 5 | description: Manages apt and executes apt-get update to ensure the local APT package cache is up to date. 6 | min_ansible_version: 1.4 7 | license: MIT 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - all 12 | categories: 13 | - system 14 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/tasks/dependencies.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install dependencies. 4 | apt: 5 | pkg="{{ item }}" 6 | state=present 7 | with_items: apt_dependencies 8 | when: apt_dependencies 9 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install packages. 4 | apt: 5 | pkg="{{ item }}" 6 | state=present 7 | with_items: apt_install 8 | when: apt_install 9 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.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 9 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/tasks/remove.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Remove packages. 4 | apt: 5 | pkg="{{ item }}" 6 | state=absent 7 | with_items: apt_remove 8 | when: apt_remove 9 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.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 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 16 | when: apt_remove_repositories 17 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.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 -------------------------------------------------------------------------------- /Ansible/roles/kosssi.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 8 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/tests/Makefile: -------------------------------------------------------------------------------- 1 | test_ubuntu-14.04: 2 | VM_BOX='ubuntu/trusty64' vagrant up --provision 3 | VM_BOX='ubuntu/trusty64' vagrant provision 4 | VM_BOX='ubuntu/trusty64' vagrant destroy -f 5 | 6 | test_ubuntu-12.04: 7 | VM_BOX='hashicorp/precise64' vagrant up --provision 8 | VM_BOX='hashicorp/precise64' vagrant provision 9 | VM_BOX='hashicorp/precise64' vagrant destroy -f 10 | 11 | test_debian-7.5: 12 | VM_BOX='puphpet/debian75-x64' vagrant up --provision 13 | VM_BOX='puphpet/debian75-x64' vagrant provision 14 | VM_BOX='puphpet/debian75-x64' vagrant destroy -f 15 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/tests/Vagrantfile: -------------------------------------------------------------------------------- 1 | $VM_BOX = ENV.has_key?('VM_BOX') ? ENV['VM_BOX'] : 'ubuntu/trusty64' 2 | 3 | Vagrant.configure('2') do |config| 4 | config.vm.box = $VM_BOX 5 | 6 | config.vm.provision :ansible do |ansible| 7 | ansible.playbook = 'playbook.yml' 8 | ansible.extra_vars = { ansible_ssh_user: 'vagrant', vagrant: true } 9 | 10 | ansible.verbose = 'v' 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost ansible_connection=local 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.apt/tests/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | sudo: true 5 | vars: 6 | apt_install: [cowsay] 7 | roles: 8 | - { role: ../../ansible-role-apt, tags: apt } 9 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/.gitignore: -------------------------------------------------------------------------------- 1 | tests/.vagrant 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | language: python 4 | 5 | python: 6 | - 2.7 7 | 8 | install: 9 | - pip install ansible==1.5.0 10 | 11 | script: 12 | - cd tests 13 | - ansible-playbook -i inventory playbook.yml --syntax-check 14 | - ansible-playbook -i inventory playbook.yml --connection=local --sudo 15 | - > 16 | ansible-playbook -i inventory playbook.yml --connection=local --sudo 17 | | grep -q 'changed=0.*unreachable=0.*failed=0' 18 | && (echo 'Idempotence test: pass' && exit 0) 19 | || (echo 'Idempotence test: fail' && exit 1) 20 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Simon Constans 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 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/README.md: -------------------------------------------------------------------------------- 1 | # ansible-role-composer 2 | 3 | [![Build Status](https://travis-ci.org/kosssi/ansible-role-composer.svg?branch=master)](https://travis-ci.org/kosssi/ansible-role-composer) 4 | 5 | Installs Composer, the PHP Dependency Manager. 6 | 7 | ## Requirements 8 | 9 | - php (version 5.3+) should be installed. 10 | 11 | ## Role Defaults Variables 12 | 13 | composer_path: /usr/local/bin/composer 14 | composer_update: true 15 | composer_update_day: 20 16 | env_proxy: {} 17 | 18 | The path where composer will be installed and available to your system. Should be in your user's `$PATH` so you can run 19 | commands simply with `composer` instead of the full path. 20 | 21 | You can specify where is php with `env_proxy` variable. For example : 22 | 23 | env_proxy: 24 | PATH: "/usr/local/zend/bin" 25 | 26 | You can also setup a global composer directory and make the bin directory available in the `$PATH` automatically by: 27 | 28 | composer_path_env: true 29 | composer_home_path: /opt/composer 30 | composer_home_owner: root 31 | composer_home_group: root 32 | composer_global_packages: 33 | phpunit/phpunit: "@stable" 34 | 35 | ## Example Playbook 36 | 37 | roles: 38 | - { role: kosssi.composer } 39 | 40 | ## Vagrant 41 | 42 | If you have vagrant, you can test this role: 43 | 44 | cd tests 45 | vagrant up 46 | 47 | ## Special thanks to contributors 48 | 49 | * [jnakatsui](https://github.com/jnakatsui) 50 | * [yoshz](https://github.com/yoshz) 51 | 52 | ## License 53 | 54 | Licensed under the MIT License. See the [LICENSE](LICENSE) file for details. 55 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | composer_path: /usr/local/bin/composer 4 | composer_update: true 5 | composer_update_day: 20 6 | composer_path_env: False 7 | #composer_home_path: /opt/composer 8 | composer_home_owner: root 9 | composer_home_group: root 10 | composer_global_packages: {} 11 | proxy_env: {} 12 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/meta/.galaxy_install_info: -------------------------------------------------------------------------------- 1 | {install_date: 'Fri Apr 3 11:00:59 2015', version: v1.2.0} 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | galaxy_info: 4 | author: kosssi 5 | description: Install and Update Composer PHP Dependency Manager 6 | license: license MIT 7 | min_ansible_version: 1.5 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - all 12 | - name: Debian 13 | versions: 14 | - all 15 | - name: Fedora 16 | versions: 17 | - all 18 | - name: CentOS 19 | versions: 20 | - all 21 | - name: Redhat 22 | versions: 23 | - all 24 | categories: 25 | - packaging 26 | - web 27 | - php 28 | - composer 29 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tasks/configure.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Create composer home path 4 | file: path={{ composer_home_path }} state=directory owner={{ composer_home_owner }} group={{ composer_home_group }} 5 | when: composer_home_path is defined 6 | 7 | - name: Configure composer home path 8 | copy: dest=/etc/profile.d/composer-home.sh mode=0755 9 | content="export COMPOSER_HOME={{ composer_home_path}}\n" 10 | when: composer_home_path is defined 11 | 12 | - name: Configure composer path environment 13 | copy: dest=/etc/profile.d/composer-path.sh mode=0755 14 | content="export PATH=${PATH}:{{ composer_home_path|default('~/.composer') }}/vendor/bin\n" 15 | when: composer_path_env 16 | 17 | - name: Global require packages 18 | shell: COMPOSER_HOME={{ composer_home_path|default('~/.composer') }} 19 | composer global require {{ item.key }}:{{ item.value }} --no-progress 20 | creates={{ composer_home_path|default('~/.composer') }}/vendor/{{ item.key }} 21 | with_dict: composer_global_packages 22 | when: composer_global_packages|length > 0 23 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Download and install Composer into the target directory. 4 | shell: 5 | php -r "readfile('https://getcomposer.org/installer');" | 6 | php -- --install-dir={{ composer_path|dirname }} --filename={{ composer_path|basename }} 7 | creates={{ composer_path }} 8 | environment: proxy_env 9 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include: install.yml 4 | - include: test.yml 5 | - include: configure.yml 6 | - include: update.yml 7 | when: composer_update == true 8 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tasks/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Get stat of composer file 4 | stat: 5 | path="{{ composer_path }}" 6 | register: composer_stat 7 | 8 | - name: Test if composer file exist 9 | fail: 10 | msg="{{ composer_path }} isn't exist" 11 | when: composer_stat.stat.exists == false 12 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tasks/update.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Get date for composer update 4 | shell: 5 | date --date='{{ composer_update_day }} days ago' +'%s' 6 | register: composer_date 7 | changed_when: False 8 | 9 | - name: Update composer if necessary 10 | shell: 11 | "{{ composer_path }} selfupdate" 12 | when: composer_date.stdout|int > composer_stat.stat.mtime|int 13 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tests/Makefile: -------------------------------------------------------------------------------- 1 | test_ubuntu-14.04: 2 | VM_BOX='ubuntu/trusty64' vagrant up --provision 3 | VM_BOX='ubuntu/trusty64' vagrant provision 4 | VM_BOX='ubuntu/trusty64' vagrant destroy -f 5 | 6 | test_ubuntu-12.04: 7 | VM_BOX='hashicorp/precise64' vagrant up --provision 8 | VM_BOX='hashicorp/precise64' vagrant provision 9 | VM_BOX='hashicorp/precise64' vagrant destroy -f 10 | 11 | test_debian-7.5: 12 | VM_BOX='puphpet/debian75-x64' vagrant up --provision 13 | VM_BOX='puphpet/debian75-x64' vagrant provision 14 | VM_BOX='puphpet/debian75-x64' vagrant destroy -f 15 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tests/Vagrantfile: -------------------------------------------------------------------------------- 1 | $VM_BOX = ENV.has_key?('VM_BOX') ? ENV['VM_BOX'] : 'ubuntu/trusty64' 2 | 3 | Vagrant.configure('2') do |config| 4 | config.vm.box = $VM_BOX 5 | 6 | config.vm.provision :ansible do |ansible| 7 | ansible.playbook = 'playbook.yml' 8 | ansible.extra_vars = { ansible_ssh_user: 'vagrant', vagrant: true } 9 | 10 | ansible.verbose = 'v' 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tests/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | sudo: true 5 | roles: 6 | - { role: common, tags: apt } 7 | - { role: ../../ansible-role-composer, tags: composer } 8 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.composer/tests/roles/common/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Update Apt cache 4 | apt: 5 | update_cache=yes 6 | cache_valid_time=3600 7 | 8 | - name: Install php packages 9 | apt: 10 | pkg=php5 11 | state=present 12 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/.gitignore: -------------------------------------------------------------------------------- 1 | tests/.vagrant 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | language: python 4 | 5 | python: 6 | - 2.7 7 | 8 | install: 9 | - pip install ansible==1.4.0 10 | 11 | script: 12 | - cd tests 13 | - ansible-playbook -i inventory playbook.yml --syntax-check 14 | - ansible-playbook -i inventory playbook.yml --sudo -vvvv 15 | - > 16 | ansible-playbook -i inventory playbook.yml --sudo 17 | | grep -q 'changed=0.*unreachable=0.*failed=0' 18 | && (echo 'Idempotence test: pass' && exit 0) 19 | || (echo 'Idempotence test: fail' && exit 1) 20 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Simon Constans 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 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/README.md: -------------------------------------------------------------------------------- 1 | # ansible-role-php 2 | 3 | [![Build Status](https://travis-ci.org/kosssi/ansible-role-php.svg?branch=master)](https://travis-ci.org/kosssi/ansible-role-php) 4 | 5 | Install and configure PHP 6 | 7 | ## Role Defaults Variables 8 | 9 | php_repository: false 10 | php_timezone: Europe/Paris 11 | 12 | php_install: 13 | - php5 14 | 15 | php_configure: 16 | - file: /etc/php5/cli/php.ini 17 | values: 18 | - { section: date, key: date.timezone, value: '{{ php_timezone }}' } 19 | - file: /etc/php5/apache2/php.ini 20 | values: 21 | - { section: date, key: date.timezone, value: '{{ php_timezone }}' } 22 | 23 | ## Exemple of configuration role 24 | 25 | php_repository: ppa:ondrej/php5 26 | php_install: 27 | - php5 28 | - php5-xdebug 29 | php_configure: 30 | - file: /etc/php5/cli/php.ini 31 | values: 32 | - { section: date, key: date.timezone, value: '{{ php_timezone }}' } 33 | - file: /etc/php5/mods-available/xdebug.ini 34 | values: 35 | - { section: date, key: date.timezone, value: '{{ php_timezone }}' } 36 | - { section: xdebug, key: xdebug.idekey, value: my-idekey } 37 | 38 | ## Example Playbook 39 | 40 | roles: 41 | - { role: kosssi.php, tags: php } 42 | 43 | ## License 44 | 45 | Licensed under the MIT License. See the [LICENSE](LICENSE) file for details. 46 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | php_repository: false 4 | php_timezone: Europe/Paris 5 | 6 | php_install: 7 | - php5 8 | 9 | php_configure: 10 | - file: /etc/php5/cli/php.ini 11 | values: 12 | - { section: date, key: date.timezone, value: '{{ php_timezone }}' } 13 | - file: /etc/php5/apache2/php.ini 14 | values: 15 | - { section: date, key: date.timezone, value: '{{ php_timezone }}' } 16 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/meta/.galaxy_install_info: -------------------------------------------------------------------------------- 1 | {install_date: 'Fri Apr 3 11:00:57 2015', version: v1.1.0} 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | galaxy_info: 4 | author: kosssi 5 | description: Install and Configure PHP 6 | license: license MIT 7 | min_ansible_version: 1.4 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - all 12 | - name: Debian 13 | versions: 14 | - all 15 | categories: 16 | - system 17 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/tasks/configure.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Add section for compatibility ini_file 4 | lineinfile: 5 | dest={{ item.0.file }} 6 | state=present 7 | regexp="(?i)^\[{{ item.1.section }}\]$" 8 | insertbefore="BOF" 9 | line="[{{ item.1.section }}]" 10 | with_subelements: 11 | - php_configure 12 | - values 13 | 14 | - name: Configure PHP ini 15 | ini_file: 16 | dest="{{ item.0.file }}" 17 | section="{{ item.1.section }}" 18 | option="{{ item.1.key }}" 19 | value="{{ item.1.value }}" 20 | backup=yes 21 | with_subelements: 22 | - php_configure 23 | - values 24 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Add repository to install last PHP version 4 | apt_repository: 5 | repo="{{ php_repository }}" 6 | update_cache=yes 7 | when: php_repository != false 8 | 9 | - name: Install packages. 10 | apt: 11 | pkg="{{ item }}" 12 | state=present 13 | with_items: php_install 14 | when: php_install != false 15 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include: install.yml 4 | - include: configure.yml 5 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/tests/Makefile: -------------------------------------------------------------------------------- 1 | test_ubuntu-14.04: 2 | VM_BOX='ubuntu/trusty64' vagrant up --provision 3 | VM_BOX='ubuntu/trusty64' vagrant provision 4 | VM_BOX='ubuntu/trusty64' vagrant destroy -f 5 | 6 | test_ubuntu-12.04: 7 | VM_BOX='hashicorp/precise64' vagrant up --provision 8 | VM_BOX='hashicorp/precise64' vagrant provision 9 | VM_BOX='hashicorp/precise64' vagrant destroy -f 10 | 11 | test_debian-7.5: 12 | VM_BOX='puphpet/debian75-x64' vagrant up --provision 13 | VM_BOX='puphpet/debian75-x64' vagrant provision 14 | VM_BOX='puphpet/debian75-x64' vagrant destroy -f 15 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/tests/Vagrantfile: -------------------------------------------------------------------------------- 1 | $VM_BOX = ENV.has_key?('VM_BOX') ? ENV['VM_BOX'] : 'ubuntu/trusty64' 2 | 3 | Vagrant.configure('2') do |config| 4 | config.vm.box = $VM_BOX 5 | 6 | config.vm.provision :ansible do |ansible| 7 | ansible.playbook = 'playbook.yml' 8 | ansible.extra_vars = { ansible_ssh_user: 'vagrant', vagrant: true } 9 | 10 | ansible.verbose = 'v' 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost ansible_connection=local 2 | -------------------------------------------------------------------------------- /Ansible/roles/kosssi.php/tests/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | sudo: true 5 | pre_tasks: 6 | - apt: update_cache=yes 7 | when: ansible_ssh_user == 'vagrant' 8 | roles: 9 | - { role: ../../ansible-role-php, tags: php } 10 | -------------------------------------------------------------------------------- /Ansible/roles/nginx-symfony/README.md: -------------------------------------------------------------------------------- 1 | # nginx-main-conf role for Ansible 2 | Install a main conf file taht listen to *.subconf files for partial configurations 3 | 4 | ## Set up 5 | - Add this role and eventually it's dependencies in your `roles` folder as git submodule: 6 | `git submodule add git://github.com/davinov/ansible-nginx-main-conf [path-to-roles]/nginx-main-conf` 7 | - Add it to your playbook's roles if it's not required by another one 8 | 9 | ## Variables 10 | `domain` default to `_` 11 | -------------------------------------------------------------------------------- /Ansible/roles/nginx-symfony/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | domain: _ 3 | -------------------------------------------------------------------------------- /Ansible/roles/nginx-symfony/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 | -------------------------------------------------------------------------------- /Ansible/roles/nginx-symfony/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 | -------------------------------------------------------------------------------- /Ansible/roles/nginx-symfony/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install 3 | apt: name=nginx state=latest update_cache=true cache_valid_time=3600 4 | tags: 5 | - packages 6 | 7 | - name: remove default site conf 8 | file: path=/etc/nginx/conf.d/default state=absent 9 | notify: reload-nginx 10 | 11 | - name: remove default site conf 12 | file: path=/etc/nginx/sites-available/default state=absent 13 | notify: reload-nginx 14 | 15 | - name: add server main listener 16 | template: src=etc/nginx/conf.d/vagrantconf dest=/etc/nginx/conf.d/main.conf 17 | notify: restart-nginx 18 | when: dev_env 19 | 20 | - name: add server main listener 21 | template: src=etc/nginx/conf.d/prodconf dest=/etc/nginx/conf.d/main.conf 22 | notify: restart-nginx 23 | when: not dev_env 24 | 25 | - name: nginx - update mime types 26 | copy: src=etc/nginx/mime.types dest=/etc/nginx/mime.types owner=root group=root mode=0644 27 | notify: restart-nginx 28 | 29 | - name: enable service 30 | service: name=nginx enabled=yes state=started 31 | -------------------------------------------------------------------------------- /Ansible/roles/nginx-symfony/templates/etc/nginx/conf.d/prodconf: -------------------------------------------------------------------------------- 1 | server { 2 | listen {{web.port}}; 3 | 4 | server_name {{ inventory_hostname }}; 5 | root /var/www/{{ project_name }}/current/web; 6 | 7 | error_log /var/www/{{ project_name }}/current/app/logs/nginx.error.log; 8 | access_log /var/www/{{ project_name }}/current/app/logs/nginx.access.log; 9 | 10 | index app_dev.php; 11 | try_files $uri @rewrite; 12 | 13 | gzip on; 14 | gzip_min_length 1000; 15 | gzip_comp_level 9; 16 | gzip_proxied any; 17 | gzip_types application/javascript application/x-javascript application/json text/css; 18 | 19 | add_header X-Robots-Tag "noindex, nofollow"; 20 | 21 | location @rewrite { 22 | rewrite ^/?(.*)$ /app.php/$1 last; 23 | } 24 | 25 | location ~ ^/(app|app_dev)\.php { 26 | fastcgi_index $1.php; 27 | fastcgi_pass unix:/var/run/php5-fpm.sock; 28 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 29 | include fastcgi_params; 30 | 31 | # Added to avoid 502 Bad Gateway errors 32 | fastcgi_buffer_size 512k; 33 | fastcgi_buffers 16 512k; 34 | } 35 | 36 | location ~* \.(css|txt|xml|js|gif|jpe?g|png|ico)$ { 37 | expires 1y; 38 | log_not_found off; 39 | } 40 | } -------------------------------------------------------------------------------- /Ansible/roles/nginx-symfony/templates/etc/nginx/conf.d/vagrantconf: -------------------------------------------------------------------------------- 1 | server { 2 | listen {{web.port}}; 3 | 4 | server_name {{ inventory_hostname }}; 5 | root /var/www/{{ project_name }}/current/web; 6 | 7 | error_log /var/www/{{ project_name }}/current/app/logs/nginx.error.log; 8 | access_log /var/www/{{ project_name }}/current/app/logs/nginx.access.log; 9 | 10 | index app_dev.php; 11 | try_files $uri @rewrite; 12 | 13 | gzip on; 14 | gzip_min_length 1000; 15 | gzip_comp_level 9; 16 | gzip_proxied any; 17 | gzip_types application/javascript application/x-javascript application/json text/css; 18 | 19 | 20 | add_header X-Robots-Tag "noindex, nofollow"; 21 | 22 | location @rewrite { 23 | rewrite ^/?(.*)$ /app_dev.php/$1 last; 24 | } 25 | 26 | location ~ ^/(app_dev|app_dev_dev)\.php { 27 | fastcgi_index $1.php; 28 | fastcgi_pass unix:/var/run/php5-fpm.sock; 29 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 30 | include fastcgi_params; 31 | 32 | # Added to avoid 502 Bad Gateway errors 33 | fastcgi_buffer_size 512k; 34 | fastcgi_buffers 16 512k; 35 | } 36 | 37 | location ~* \.(css|txt|xml|js|gif|jpe?g|png|ico)$ { 38 | expires 1y; 39 | log_not_found off; 40 | } 41 | } -------------------------------------------------------------------------------- /Command/ProvisioningGeneratorCommand.php: -------------------------------------------------------------------------------- 1 | setName('generate:provisioning') 18 | ->setDescription('Generate Symfony provisioning') 19 | ; 20 | } 21 | 22 | /** 23 | * @param InputInterface $input 24 | * @param OutputInterface $output 25 | * 26 | * @return int|null|void 27 | */ 28 | protected function execute(InputInterface $input, OutputInterface $output) 29 | { 30 | $output->writeln('Generate start'); 31 | $this->getContainer()->get('fansible_devops.generator.container')->generate(); 32 | $output->writeln('Generate end'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Config/AnsibleRolesConfig.php: -------------------------------------------------------------------------------- 1 | ['name' => 'kosssi.apt', 'version' => 'v2.0.0'], 24 | ServicesConfig::PHP => ['name' => 'kosssi.php', 'version' => 'v1.1.0'], 25 | ServicesConfig::COMPOSER => ['name' => 'kosssi.composer', 'version' => 'v1.2.0'], 26 | // database 27 | ServicesConfig::MYSQL => ['name' => 'ANXS.mysql', 'version' => 'v1.0.3'], 28 | ServicesConfig::POSTGRESQL => ['name' => 'ANXS.postgresql', 'version' => 'v1.1.0'], 29 | // webserver 30 | ServicesConfig::APACHE => ['name' => 'kosssi.apache', 'version' => 'v1.0.3'], 31 | ServicesConfig::NGINX => ['name' => 'nginx-symfony', 'version' => 'none'], 32 | 33 | ServicesConfig::NODE => ['name' => 'Stouts.nodejs', 'version' => '1.1.2'], 34 | ServicesConfig::XDEBUG => ['name' => 'MaximeThoonsen.php5-xdebug', 'version' => 'v1.0.5'], 35 | ]; 36 | 37 | /** 38 | * @param array $config 39 | */ 40 | public function __construct(array $config) 41 | { 42 | foreach ($config as $service => $role) { 43 | if (in_array($service, $this->rolesSupported)) { 44 | foreach ($role as $key => $value) { 45 | $this->roles[$service][$key] = $value; 46 | } 47 | } 48 | } 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getRoles() 55 | { 56 | return $this->roles; 57 | } 58 | 59 | /** 60 | * @param string $service 61 | * 62 | * @return array 63 | */ 64 | public function getRole($service) 65 | { 66 | return $this->roles[$service]; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Config/DatabaseConfig.php: -------------------------------------------------------------------------------- 1 | ServicesConfig::POSTGRESQL, 11 | 'pdo_mysql' => ServicesConfig::MYSQL, 12 | ); 13 | 14 | /** 15 | * @var string 16 | */ 17 | private $service; 18 | 19 | /** 20 | * @var string 21 | **/ 22 | private $name; 23 | 24 | /** 25 | * @var string 26 | */ 27 | private $user; 28 | 29 | /** 30 | * @var string 31 | */ 32 | private $password; 33 | 34 | /** 35 | * @param ServicesConfig $servicesConfig 36 | * @param array $config 37 | */ 38 | public function __construct($servicesConfig, array $config) 39 | { 40 | $driver = $config['driver']; 41 | if (isset($this->driverToService[$driver])) { 42 | $this->service = $this->driverToService[$driver]; 43 | $servicesConfig->addService($this->service); 44 | } 45 | $this->name = $config['name']; 46 | $this->user = $config['user']; 47 | $this->password = $config['password']; 48 | } 49 | 50 | /** 51 | * @return string 52 | */ 53 | public function getName() 54 | { 55 | return $this->name; 56 | } 57 | 58 | /** 59 | * @return string 60 | */ 61 | public function getPassword() 62 | { 63 | return $this->password; 64 | } 65 | 66 | /** 67 | * @return string 68 | */ 69 | public function getUser() 70 | { 71 | return $this->user; 72 | } 73 | 74 | /** 75 | * @return string 76 | */ 77 | public function getService() 78 | { 79 | return $this->service; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Config/EnvironmentConfig.php: -------------------------------------------------------------------------------- 1 | name = $name; 18 | $this->host = $config['host']; 19 | $this->ip = $config['ip']; 20 | } 21 | 22 | /** 23 | * @return string 24 | */ 25 | public function getName() 26 | { 27 | return $this->name; 28 | } 29 | 30 | /** 31 | * @return string 32 | */ 33 | public function getHost() 34 | { 35 | return $this->host; 36 | } 37 | 38 | /** 39 | * @return string 40 | */ 41 | public function getIp() 42 | { 43 | return $this->ip; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Config/EnvironmentsConfig.php: -------------------------------------------------------------------------------- 1 | $config) { 15 | $this->environments[] = new EnvironmentConfig($name, $config); 16 | } 17 | } 18 | 19 | /** 20 | * @return array 21 | */ 22 | public function getEnvironments() 23 | { 24 | return $this->environments; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Config/ServicesConfig.php: -------------------------------------------------------------------------------- 1 | services = [ 54 | self::APT, 55 | self::PHP, 56 | self::COMPOSER, 57 | ]; 58 | $this->addService($provisioning); 59 | if (null !== $services = $finderContainer->getServices()) { 60 | foreach ($services as $service) { 61 | $this->addService($service); 62 | } 63 | } 64 | } 65 | 66 | /** 67 | * @return array 68 | */ 69 | public function getServices() 70 | { 71 | return $this->services; 72 | } 73 | 74 | /** 75 | * @param string $service 76 | * 77 | * @return $this 78 | */ 79 | public function addService($service) 80 | { 81 | if (in_array($service, $this->allServices)) { 82 | $this->services[] = $service; 83 | } 84 | 85 | return $this; 86 | } 87 | 88 | /** 89 | * @param string $service 90 | * 91 | * @return bool 92 | */ 93 | public function isPresent($service) 94 | { 95 | return in_array($service, $this->services); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Config/VagrantConfig.php: -------------------------------------------------------------------------------- 1 | projectName = $projectName; 35 | $this->box = $config['box']; 36 | $this->ip = $config['ip']; 37 | $this->memory = $config['memory']; 38 | $this->cpus = $config['cpus']; 39 | $this->exec = $config['exec']; 40 | $this->src = $config['src']; 41 | $this->dest = $config['dest'] ? $config['dest'] : '/var/www/' . $projectName . '/current'; 42 | $this->hostfile = $config['hostfile']; 43 | } 44 | 45 | /** 46 | * @return string 47 | */ 48 | public function getBox() 49 | { 50 | return $this->box; 51 | } 52 | 53 | /** 54 | * @return string 55 | */ 56 | public function getCpus() 57 | { 58 | return $this->cpus; 59 | } 60 | 61 | /** 62 | * @return string 63 | */ 64 | public function getDest() 65 | { 66 | return $this->dest; 67 | } 68 | 69 | /** 70 | * @return string 71 | */ 72 | public function getExec() 73 | { 74 | return $this->exec; 75 | } 76 | 77 | /** 78 | * @return string 79 | */ 80 | public function getHostfile() 81 | { 82 | return $this->hostfile; 83 | } 84 | 85 | /** 86 | * @return string 87 | */ 88 | public function getIp() 89 | { 90 | return $this->ip; 91 | } 92 | 93 | /** 94 | * @return string 95 | */ 96 | public function getMemory() 97 | { 98 | return $this->memory; 99 | } 100 | 101 | /** 102 | * @return string 103 | */ 104 | public function getProjectName() 105 | { 106 | return $this->projectName; 107 | } 108 | 109 | /** 110 | * @return string 111 | */ 112 | public function getSrc() 113 | { 114 | return $this->src; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Config/WebServerConfig.php: -------------------------------------------------------------------------------- 1 | services)) { 30 | $servicesConfig->addService($service); 31 | $this->service = $service; 32 | } 33 | $this->port = $config['port']; 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getPort() 40 | { 41 | return $this->port; 42 | } 43 | 44 | /** 45 | * @return string 46 | */ 47 | public function getService() 48 | { 49 | return $this->service; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /DependencyInjection/Compiler/FinderCompilerPass.php: -------------------------------------------------------------------------------- 1 | hasDefinition('fansible_devops.finder.container')) { 20 | return; 21 | } 22 | 23 | $definition = $container->getDefinition('fansible_devops.finder.container'); 24 | $taggedServices = $container->findTaggedServiceIds('fansible_devops.finder'); 25 | 26 | foreach ($taggedServices as $id => $tagAttributes) { 27 | $definition->addMethodCall( 28 | 'addFinder', 29 | [new Reference($id)] 30 | ); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /DependencyInjection/Compiler/GeneratorCompilerPass.php: -------------------------------------------------------------------------------- 1 | hasDefinition('fansible_devops.generator.container')) { 20 | return; 21 | } 22 | 23 | $definition = $container->getDefinition('fansible_devops.generator.container'); 24 | $taggedServices = $container->findTaggedServiceIds('fansible_devops.generator'); 25 | 26 | foreach ($taggedServices as $id => $tagAttributes) { 27 | $definition->addMethodCall( 28 | 'addGenerator', 29 | [new Reference($id)] 30 | ); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /DependencyInjection/Configuration.php: -------------------------------------------------------------------------------- 1 | root('fansible_devops'); 23 | $rootNode 24 | ->children() 25 | ->scalarNode('name')->isRequired()->cannotBeEmpty()->end() 26 | ->scalarNode('timezone')->defaultValue('Europe/Paris')->end() 27 | ->scalarNode('provisioning') 28 | ->defaultValue(ServicesConfig::ANSIBLE) 29 | ->validate() 30 | ->ifNotInArray(array(ServicesConfig::ANSIBLE, ServicesConfig::DOCKER)) 31 | ->thenInvalid('Invalid webserver %s') 32 | ->end() 33 | ->end() 34 | ->scalarNode('provisioning_path')->defaultValue('devops/provisioning/')->end() 35 | ->arrayNode('webserver') 36 | ->addDefaultsIfNotSet() 37 | ->children() 38 | ->scalarNode('service') 39 | ->defaultValue(ServicesConfig::APACHE) 40 | ->validate() 41 | ->ifNotInArray(array(ServicesConfig::APACHE, ServicesConfig::NGINX)) 42 | ->thenInvalid('Invalid webserver service %s') 43 | ->end() 44 | ->end() 45 | ->integerNode('port')->defaultValue(80)->min(0)->max(65535)->end() 46 | ->end() 47 | ->end() 48 | ->arrayNode('database') 49 | ->children() 50 | ->scalarNode('driver')->defaultNull()->end() 51 | ->scalarNode('name')->defaultNull()->end() 52 | ->scalarNode('user')->defaultNull()->end() 53 | ->scalarNode('password')->defaultNull()->end() 54 | ->end() 55 | ->end() 56 | ->arrayNode('environments') 57 | ->isRequired() 58 | ->requiresAtLeastOneElement() 59 | ->useAttributeAsKey('name') 60 | ->prototype('array') 61 | ->children() 62 | ->scalarNode('ip')->defaultValue('8.0.0.8')->end() 63 | ->scalarNode('host')->end() 64 | ->scalarNode('hostfile')->defaultValue('devops/provisioning/inventory/vagrant')->end() 65 | //Specific part for the vagrant 66 | ->scalarNode('box')->defaultValue('ubuntu/trusty64')->end() 67 | ->scalarNode('memory')->defaultValue('1024')->end() 68 | ->scalarNode('cpus')->defaultValue('1')->end() 69 | ->scalarNode('exec')->defaultValue('100')->end() 70 | ->scalarNode('src')->defaultValue('.')->end() 71 | ->scalarNode('dest')->defaultNull()->end() 72 | ->end() 73 | ->end() 74 | ->end() 75 | ->arrayNode('ansible_roles') 76 | ->prototype('array') 77 | ->children() 78 | ->scalarNode('name')->end() 79 | ->scalarNode('version')->end() 80 | ->scalarNode('template')->end() 81 | ->end() 82 | ->end() 83 | ->end() 84 | ->end() 85 | ; 86 | 87 | return $treeBuilder; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /DependencyInjection/FansibleDevopsExtension.php: -------------------------------------------------------------------------------- 1 | processConfiguration($configuration, $configs); 25 | 26 | $container->setParameter('fansible_devops.data.name', $config['name']); 27 | $container->setParameter('fansible_devops.data.timezone', $config['timezone']); 28 | $container->setParameter('fansible_devops.data.provisioning', $config['provisioning']); 29 | $container->setParameter('fansible_devops.data.provisioning_path', $config['provisioning_path']); 30 | $container->setParameter('fansible_devops.data.database', $config['database']); 31 | $container->setParameter('fansible_devops.data.webserver', $config['webserver']); 32 | $container->setParameter('fansible_devops.data.vagrant', $config['environments']['vagrant']); 33 | $container->setParameter('fansible_devops.data.environments', $config['environments']); 34 | $container->setParameter('fansible_devops.data.ansible_roles', $config['ansible_roles']); 35 | 36 | $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 37 | $loader->load('config.xml'); 38 | $loader->load('finder.xml'); 39 | $loader->load('generator.xml'); 40 | } 41 | 42 | public function prepend(ContainerBuilder $container) 43 | { 44 | // get all bundles 45 | $bundles = $container->getParameter('kernel.bundles'); 46 | // determine if DoctrineBundle is registered 47 | if (isset($bundles['DoctrineBundle'])) { 48 | $doctrineConfigs = $container->getExtensionConfig('doctrine'); 49 | // check if entity_manager_name is set in the "acme_hello" configuration 50 | if (isset($doctrineConfigs[0]['dbal'])) { 51 | // prepend the acme_something settings with the entity_manager_name 52 | $config = array('database' => $this->databaseFilter($doctrineConfigs[0]['dbal'])); 53 | $container->prependExtensionConfig($this->getAlias(), $config); 54 | } 55 | } 56 | } 57 | 58 | /** 59 | * @param array $config 60 | * 61 | * @return array 62 | */ 63 | private function databaseFilter(array $config) 64 | { 65 | return [ 66 | 'driver' => isset($config['driver']) ? $config['driver'] : '', 67 | 'name' => isset($config['dbname']) ? $config['dbname'] : '', 68 | 'user' => isset($config['user']) ? $config['user'] : '', 69 | 'password' => isset($config['password']) ? $config['password'] : '', 70 | ]; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /FansibleDevopsBundle.php: -------------------------------------------------------------------------------- 1 | addCompilerPass(new FinderCompilerPass()); 19 | $container->addCompilerPass(new GeneratorCompilerPass()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Finder/Helper/FinderContainer.php: -------------------------------------------------------------------------------- 1 | finders[] = $finder; 23 | } 24 | 25 | /** 26 | * @return array 27 | */ 28 | public function getServices() 29 | { 30 | if (empty($this->services)) { 31 | /** @var FinderInterface $finder */ 32 | foreach ($this->finders as $finder) { 33 | if ($finder->isPresent()) { 34 | $this->services[] = $finder->getServiceName(); 35 | } 36 | } 37 | } 38 | 39 | return $this->services; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Finder/Helper/FinderInterface.php: -------------------------------------------------------------------------------- 1 | rootDir = $rootDir; 21 | } 22 | 23 | /** 24 | * @inheritdoc 25 | */ 26 | public function getServiceName() 27 | { 28 | return ServicesConfig::NODE; 29 | } 30 | 31 | /** 32 | * @inheritdoc 33 | */ 34 | public function isPresent() 35 | { 36 | return file_exists(dirname($this->rootDir) . '/package.json'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Generator/Ansible/AnsibleCfgGenerator.php: -------------------------------------------------------------------------------- 1 | twigHelper = $twigHelper; 27 | $this->servicesConfig = $servicesConfig; 28 | } 29 | 30 | /** 31 | * @inheritdoc 32 | */ 33 | public function generate() 34 | { 35 | if ($this->servicesConfig->isPresent(ServicesConfig::ANSIBLE)) { 36 | $this->twigHelper->render( 37 | 'ansible.cfg', 38 | 'Ansible:ansible.cfg.twig' 39 | ); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Generator/Ansible/HostsGenerator.php: -------------------------------------------------------------------------------- 1 | twigHelper = $twigHelper; 34 | $this->servicesConfig = $servicesConfig; 35 | $this->environmentsConfig = $environmentsConfig; 36 | } 37 | 38 | /** 39 | * @inheritdoc 40 | */ 41 | public function generate() 42 | { 43 | if ($this->servicesConfig->isPresent(ServicesConfig::ANSIBLE)) { 44 | /** @var \Fansible\DevopsBundle\Config\EnvironmentConfig $environment */ 45 | foreach ($this->environmentsConfig->getEnvironments() as $environment) { 46 | $this->twigHelper->renderProvisioningFile( 47 | 'inventory/' . $environment->getName(), 48 | 'Ansible:hosts.txt.twig', 49 | [ 50 | 'environment' => $environment, 51 | ] 52 | ); 53 | $this->twigHelper->renderProvisioningFile( 54 | 'inventory/group_vars/' . $environment->getName(), 55 | 'Ansible:group_vars.txt.twig', 56 | [ 57 | 'dev_env' => $environment->getName() == VagrantConfig::VAGRANT_NAME ? "true" : "false", 58 | ] 59 | ); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Generator/Ansible/PlaybookGenerator.php: -------------------------------------------------------------------------------- 1 | twigHelper = $twigHelper; 45 | $this->servicesConfig = $servicesConfig; 46 | $this->ansibleRolesConfig = $ansibleRolesConfig; 47 | $this->projectName = $projectName; 48 | $this->timezone = $timezone; 49 | } 50 | 51 | /** 52 | * @inheritdoc 53 | */ 54 | public function generate() 55 | { 56 | if ($this->servicesConfig->isPresent(ServicesConfig::ANSIBLE)) { 57 | $this->twigHelper->renderProvisioningFile( 58 | 'playbook.yml', 59 | 'Ansible:playbook.yml.twig', 60 | [ 61 | 'project_name' => $this->projectName, 62 | 'hosts' => 'all', 63 | 'sudo' => 'yes', 64 | 'roles' => $this->ansibleRolesConfig->getRoles(), 65 | 'services' => $this->servicesConfig->getServices(), 66 | 'timezone' => $this->timezone, 67 | ] 68 | ); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Generator/Ansible/RequirementsGenerator.php: -------------------------------------------------------------------------------- 1 | twigHelper = $twigHelper; 33 | $this->servicesConfig = $servicesConfig; 34 | $this->ansibleRolesConfig = $ansibleRolesConfig; 35 | } 36 | 37 | /** 38 | * @inheritdoc 39 | */ 40 | public function generate() 41 | { 42 | if ($this->servicesConfig->isPresent(ServicesConfig::ANSIBLE)) { 43 | $this->twigHelper->render( 44 | 'requirements.txt', 45 | 'Ansible:requirements.txt.twig', 46 | [ 47 | 'roles' => $this->ansibleRolesConfig->getRoles(), 48 | 'services' => $this->servicesConfig->getServices(), 49 | ] 50 | ); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Generator/Ansible/Roles/ApacheGenerator.php: -------------------------------------------------------------------------------- 1 | twigHelper = $twigHelper; 33 | $this->servicesConfig = $servicesConfig; 34 | $this->webServerConfig = $webServerConfig; 35 | } 36 | 37 | /** 38 | * @inheritdoc 39 | */ 40 | public function generate() 41 | { 42 | if ($this->servicesConfig->isPresent(ServicesConfig::ANSIBLE) 43 | && $this->servicesConfig->isPresent(ServicesConfig::APACHE) 44 | ) { 45 | $this->twigHelper->renderProvisioningFile( 46 | 'vars/apache.yml', 47 | 'Ansible/Roles:apache.yml.twig', 48 | [ 49 | 'port' => $this->webServerConfig->getPort(), 50 | ] 51 | ); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Generator/Ansible/Roles/AptGenerator.php: -------------------------------------------------------------------------------- 1 | databaseConfig = $databaseConfig; 24 | } 25 | 26 | /** 27 | * @inheritdoc 28 | */ 29 | public function getService() 30 | { 31 | return ServicesConfig::MYSQL; 32 | } 33 | 34 | /** 35 | * @inheritdoc 36 | */ 37 | public function getParameters() 38 | { 39 | return [ 40 | 'database' => $this->databaseConfig, 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Generator/Ansible/Roles/NginxGenerator.php: -------------------------------------------------------------------------------- 1 | twigHelper = $twigHelper; 33 | $this->servicesConfig = $servicesConfig; 34 | $this->webServerConfig = $webServerConfig; 35 | } 36 | 37 | /** 38 | * @inheritdoc 39 | */ 40 | public function generate() 41 | { 42 | if ($this->servicesConfig->isPresent(ServicesConfig::ANSIBLE) 43 | && $this->servicesConfig->isPresent(ServicesConfig::NGINX) 44 | ) { 45 | $this->twigHelper->renderProvisioningFile( 46 | 'vars/nginx.yml', 47 | 'Ansible/Roles:nginx.yml.twig', 48 | [ 49 | 'port' => $this->webServerConfig->getPort(), 50 | ] 51 | ); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Generator/Ansible/Roles/NodeGenerator.php: -------------------------------------------------------------------------------- 1 | $this->servicesConfig 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Generator/Ansible/Roles/PostgresqlGenerator.php: -------------------------------------------------------------------------------- 1 | databaseConfig = $databaseConfig; 24 | } 25 | 26 | /** 27 | * @inheritdoc 28 | */ 29 | public function getService() 30 | { 31 | return ServicesConfig::POSTGRESQL; 32 | } 33 | 34 | /** 35 | * @inheritdoc 36 | */ 37 | public function getParameters() 38 | { 39 | return [ 40 | 'database' => $this->databaseConfig, 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Generator/Ansible/Roles/XdebugGenerator.php: -------------------------------------------------------------------------------- 1 | twigHelper = $twigHelper; 26 | $this->servicesConfig = $servicesConfig; 27 | } 28 | 29 | /** 30 | * @return string 31 | */ 32 | abstract public function getService(); 33 | 34 | /** 35 | * @return array 36 | */ 37 | public function getParameters() 38 | { 39 | return []; 40 | } 41 | 42 | /** 43 | * @inheritdoc 44 | */ 45 | public function generate() 46 | { 47 | if ($this->servicesConfig->isPresent(ServicesConfig::ANSIBLE) 48 | && $this->servicesConfig->isPresent($this->getService()) 49 | ) { 50 | $this->twigHelper->renderProvisioningFile( 51 | 'vars/' . $this->getService() . '.yml', 52 | 'Ansible/Roles:' . $this->getService() . '.yml.twig', 53 | $this->getParameters() 54 | ); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Generator/Helper/GeneratorContainer.php: -------------------------------------------------------------------------------- 1 | generators[] = $generator; 18 | } 19 | 20 | /** 21 | * @inheritdoc 22 | */ 23 | public function generate() 24 | { 25 | /** @var GeneratorInterface $generator */ 26 | foreach ($this->generators as $generator) { 27 | $generator->generate(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Generator/Helper/GeneratorInterface.php: -------------------------------------------------------------------------------- 1 | twig = $twig; 30 | $this->rootDir = $rootDir; 31 | $this->provisioningPath = $provisioningPath; 32 | } 33 | 34 | /** 35 | * @param string $path 36 | * 37 | * @return string 38 | */ 39 | private function getTwigPath($path) 40 | { 41 | return 'FansibleDevopsBundle:' . $path; 42 | } 43 | 44 | /** 45 | * @param string $fileName 46 | * @param string $twigFile 47 | * @param array $parameters 48 | */ 49 | public function render($fileName, $twigFile, $parameters = []) 50 | { 51 | if (!is_dir(dirname($fileName))) { 52 | mkdir(dirname($fileName), 0777, true); 53 | } 54 | 55 | file_put_contents($fileName ,$this->twig->render($this->getTwigPath($twigFile), $parameters)); 56 | } 57 | 58 | /** 59 | * @param string $fileName 60 | * @param string $twigFile 61 | * @param array $parameters 62 | */ 63 | public function renderProvisioningFile($fileName, $twigFile, $parameters = []) 64 | { 65 | $this->render($this->provisioningPath . $fileName, $twigFile, $parameters); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Generator/VagrantfileGenerator.php: -------------------------------------------------------------------------------- 1 | vagrantConfig = $vagrantConfig; 26 | $this->twigHelper = $twigHelper; 27 | } 28 | 29 | public function generate() 30 | { 31 | $this->twigHelper->render( 32 | 'Vagrantfile', 33 | 'Vagrant:Vagrantfile.txt.twig', 34 | [ 35 | 'config' => $this->vagrantConfig, 36 | ] 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Fansible 2 | Permission is hereby granted, free of charge, to any person obtaining a copy 3 | of this software and associated documentation files (the "Software"), to deal 4 | in the Software without restriction, including without limitation the rights 5 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | copies of the Software, and to permit persons to whom the Software is 7 | furnished to do so, subject to the following conditions: 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16 | THE SOFTWARE. 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # /!\ Deprecated /!\ 2 | See https://github.com/fansible/tywin for the newer version. 3 | 4 | # FansibleDevopsBundle 5 | 6 | This will help you to generate a Ansible provisioning to run your Symfony apps. 7 | 8 | ##Requirements 9 | This have been tested with the Ubuntu OS. It should work with many other various Linux distribution. Feel free to share your advice for the other OS.. 10 | You will need to install if you haven't done yet: 11 | 12 | * [Ansible](http://docs.ansible.com/intro_installation.html) 13 | * [Composer](https://getcomposer.org/download/) 14 | * [Vagrant](http://www.vagrantup.com/downloads.html) 15 | * [VirtualBox](https://www.virtualbox.org/wiki/Downloads). 16 | * nfs `sudo apt-get install nfs-kernel-server` 17 | 18 | 1) Install the bundle 19 | 20 | composer require fansible/devops-bundle *@dev --dev 21 | 22 | 2) Enable the bundle in the `app/AppKernel.php` file, for development environment only. 23 | 24 | ``` 25 | if (in_array($this->getEnvironment(), array('dev', 'test'))) { 26 | /* After other dev dependencies... */ 27 | $bundles[] = new \Fansible\DevopsBundle\FansibleDevopsBundle(); 28 | } 29 | ``` 30 | 31 | 3) Add the following in your configuration in `app/config/config_dev.yml` 32 | 33 | fansible_devops: 34 | #Name of your project 35 | name: fansible-devops 36 | environments: 37 | vagrant: 38 | ip: 10.0.0.10 39 | host: fansible-devops.dev 40 | #Those vars will be used to generate the VagrantFile 41 | #box: ubuntu/trusty64 42 | #memory: 1024 43 | #cpus: 1 44 | #exec: 100 45 | #src: . 46 | #dest: /var/www/fansible-devops/current 47 | prod: 48 | ip: x.x.x.x 49 | host: fansible-devops.prod 50 | #Specific role you want to use 51 | ansible_roles: 52 | # apache: 53 | # name: THEROLEYOUWANT #you can found many roles on ansible galaxy 54 | # version: v24 55 | 56 | 4) Add your host in your hostfile: `sudo /bin/bash -c "echo '10.0.0.10 fansible-devops.dev' >> /etc/hosts"` 57 | 58 | 5) Now you can use our command to generate all the files you need to your provisioning. 59 | `app/console generate:provisioning` 60 | 61 | 6) To be able to correctly provision your server, ansible needs some role that are describe in the requirements.txt file. 62 | You need to download them by running 63 | `ansible-galaxy install -r requirements.txt`. 64 | 65 | 7) Now you can run `vagrant up` to start your vagrant. It is lunched using the Vagrantfile that we have just generated. 66 | -------------------------------------------------------------------------------- /Resources/config/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Fansible\DevopsBundle\Config\ServicesConfig 9 | Fansible\DevopsBundle\Config\WebServerConfig 10 | Fansible\DevopsBundle\Config\DatabaseConfig 11 | Fansible\DevopsBundle\Config\EnvironmentsConfig 12 | Fansible\DevopsBundle\Config\AnsibleRolesConfig 13 | Fansible\DevopsBundle\Config\VagrantConfig 14 | 15 | 16 | 17 | 18 | 19 | %fansible_devops.data.provisioning% 20 | 21 | 22 | 23 | 24 | 25 | %fansible_devops.data.webserver% 26 | 27 | 28 | 29 | 30 | %fansible_devops.data.database% 31 | 32 | 33 | 34 | %fansible_devops.data.environments% 35 | 36 | 37 | 38 | %fansible_devops.data.ansible_roles% 39 | 40 | 41 | 42 | %fansible_devops.data.name% 43 | %fansible_devops.data.vagrant% 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Resources/config/finder.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Fansible\DevopsBundle\Finder\Helper\FinderContainer 9 | Fansible\DevopsBundle\Finder\NodeFinder 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | %kernel.root_dir% 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Resources/config/generator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Fansible\DevopsBundle\Generator\Helper\GeneratorContainer 9 | Fansible\DevopsBundle\Generator\Helper\TwigHelper 10 | Fansible\DevopsBundle\Generator\VagrantfileGenerator 11 | Fansible\DevopsBundle\Generator\Ansible\AnsibleCfgGenerator 12 | Fansible\DevopsBundle\Generator\Ansible\HostsGenerator 13 | Fansible\DevopsBundle\Generator\Ansible\PlaybookGenerator 14 | Fansible\DevopsBundle\Generator\Ansible\RequirementsGenerator 15 | Fansible\DevopsBundle\Generator\Ansible\Roles\MysqlGenerator 16 | Fansible\DevopsBundle\Generator\Ansible\Roles\PostgresqlGenerator 17 | Fansible\DevopsBundle\Generator\Ansible\Roles\ApacheGenerator 18 | Fansible\DevopsBundle\Generator\Ansible\Roles\NginxGenerator 19 | Fansible\DevopsBundle\Generator\Ansible\Roles\PhpGenerator 20 | Fansible\DevopsBundle\Generator\Ansible\Roles\ComposerGenerator 21 | Fansible\DevopsBundle\Generator\Ansible\Roles\NodeGenerator 22 | Fansible\DevopsBundle\Generator\Ansible\Roles\XdebugGenerator 23 | Fansible\DevopsBundle\Generator\Ansible\Roles\AptGenerator 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | %kernel.root_dir% 37 | %fansible_devops.data.provisioning_path% 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | %fansible_devops.data.name% 66 | %fansible_devops.data.timezone% 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/apache.yml.twig: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | apache_repository: false 4 | 5 | apache_site_enable: 6 | - "{{ "{{ inventory_hostname }}" }}" 7 | 8 | apache_vhosts: 9 | - servername: "{{ "{{ inventory_hostname }}" }}" 10 | index: app.php 11 | port: {{ port }} 12 | documentroot: "/var/www/{{ "{{ project_name }}" }}/current/web" 13 | directory_extra: 14 | - "RewriteEngine On" 15 | - "RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\\2$" 16 | - "RewriteRule ^(.*) - [E=BASE:%1]" 17 | - "RewriteCond %{ENV:REDIRECT_STATUS} ^$" 18 | - "RewriteRule ^app\\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]" 19 | - "RewriteCond %{REQUEST_FILENAME} -f" 20 | - "RewriteRule .? - [L]" 21 | - "RewriteRule .? %{ENV:BASE}/app.php [L]" 22 | -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/apt.yml.twig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fansible/DevopsBundle/5ef83f3a2bb976e756e492eefd2117c7ffa8e4ad/Resources/views/Ansible/Roles/apt.yml.twig -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/composer.yml.twig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fansible/DevopsBundle/5ef83f3a2bb976e756e492eefd2117c7ffa8e4ad/Resources/views/Ansible/Roles/composer.yml.twig -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/mysql.yml.twig: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # List of databases to be created 4 | mysql_databases: 5 | - name: "{{ database.name }}" 6 | 7 | # List of users to be created 8 | mysql_users: 9 | - name: "{{ database.user }}" 10 | pass: "{{ database.password }}" 11 | priv: "*.*:ALL" 12 | -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/nginx.yml.twig: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | web: 4 | port: {{ port }} 5 | -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/node.yml.twig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fansible/DevopsBundle/5ef83f3a2bb976e756e492eefd2117c7ffa8e4ad/Resources/views/Ansible/Roles/node.yml.twig -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/php.yml.twig: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | php_install: 4 | - php5 5 | - php5-intl 6 | - php5-curl 7 | - php5-gd 8 | {% if services.isPresent(constant('Fansible\\DevopsBundle\\Config\\ServicesConfig::MYSQL')) %} 9 | - php5-mysql 10 | {% endif %} 11 | {% if services.isPresent(constant('Fansible\\DevopsBundle\\Config\\ServicesConfig::POSTGRESQL')) %} 12 | - php5-pgsql 13 | {% endif %} 14 | 15 | php_configure: 16 | - file: /etc/php5/cli/php.ini 17 | values: 18 | - { section: PHP, key: upload_max_filesize, value: '20M' } 19 | - { section: PHP, key: post_max_size, value: '20M' } 20 | - { section: date, key: date.timezone, value: '{{ '{{ timezone }}' }}' } 21 | - file: /etc/php5/apache2/php.ini 22 | values: 23 | - { section: PHP, key: upload_max_filesize, value: '20M' } 24 | - { section: PHP, key: post_max_size, value: '20M' } 25 | - { section: date, key: date.timezone, value: '{{ '{{ timezone }}' }}' } 26 | -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/postgresql.yml.twig: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # List of databases to be created 4 | postgresql_databases: 5 | - name: "{{ database.name }}" 6 | 7 | # List of users to be created 8 | postgresql_users: 9 | - name: "{{ database.user }}" 10 | pass: "{{ database.password }}" 11 | 12 | postgresql_user_privileges: 13 | - name: "{{ database.user }}" # user name 14 | db: "{{ database.name }}" # database 15 | priv: "ALL" # privilege string format: example: INSERT,UPDATE/table:SELECT/anothertable:ALL 16 | role_attr_flags: "SUPERUSER" # role attribute flags 17 | -------------------------------------------------------------------------------- /Resources/views/Ansible/Roles/xdebug.yml.twig: -------------------------------------------------------------------------------- 1 | --- 2 | php_xdebug_remote_enable: "false" 3 | php_xdebug_remote_connect_back: "false" 4 | php_xdebug_remote_host: localhost 5 | php_xdebug_remote_port: "9000" 6 | php_xdebug_remote_log: /tmp/xdebug.log 7 | php_xdebug_idekey: XDEBUG 8 | php_max_nesting_level: 200 9 | -------------------------------------------------------------------------------- /Resources/views/Ansible/ansible.cfg.twig: -------------------------------------------------------------------------------- 1 | [defaults] 2 | hostfile = inventory 3 | roles_path = vendor/ansible/roles:vendor/fansible/devops-bundle/Ansible/roles 4 | -------------------------------------------------------------------------------- /Resources/views/Ansible/group_vars.txt.twig: -------------------------------------------------------------------------------- 1 | --- 2 | dev_env: {{ dev_env }} 3 | -------------------------------------------------------------------------------- /Resources/views/Ansible/hosts.txt.twig: -------------------------------------------------------------------------------- 1 | [{{ environment.name }}] 2 | {{ environment.host }} 3 | -------------------------------------------------------------------------------- /Resources/views/Ansible/playbook.yml.twig: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Provision {{ project_name }} 4 | hosts: {{ hosts }} 5 | sudo: {{ sudo }} 6 | vars: 7 | timezone: {{ timezone }} 8 | project_name: {{ project_name }} 9 | vars_files: 10 | {% if services is not empty %}{% for service in services %}{% if roles[service] is defined %} 11 | - vars/{{ service }}.yml 12 | {% endif %}{% endfor %}{% endif %} 13 | {% if vars_files is defined %} 14 | {% for vars_file in vars_files %} 15 | - vars/{{ vars_file }}.yml 16 | {% endfor %} 17 | {% endif %} 18 | roles: 19 | {% for service in services %}{% if roles[service] is defined %} 20 | - { role: {{ roles[service].name }}, tags: {{ service }} } 21 | {% endif %}{% endfor %} 22 | {% if includes is defined %} 23 | 24 | {% for include in includes %} 25 | - include : {{ include.include }}.yml 26 | {% endfor %} 27 | {% endif %} 28 | 29 | - name: Vagrant provisioning 30 | hosts: vagrant 31 | sudo: yes 32 | gather_facts: true 33 | roles: 34 | - MaximeThoonsen.php5-xdebug 35 | -------------------------------------------------------------------------------- /Resources/views/Ansible/requirements.txt.twig: -------------------------------------------------------------------------------- 1 | {% if services is not empty %}{% for service in services %}{% if roles[service] is defined %}{% if roles[service].version !='none' %} 2 | {{ roles[service].name }},{{ roles[service].version }} 3 | {% endif %}{% endif %}{% endfor %}{% endif %} 4 | -------------------------------------------------------------------------------- /Resources/views/Vagrant/Vagrantfile.txt.twig: -------------------------------------------------------------------------------- 1 | $HOSTNAME = "{{ config.projectName }}.dev" 2 | $BOX = "{{ config.box }}" 3 | $IP = "{{ config.ip }}" 4 | $MEMORY = ENV.has_key?('VM_MEMORY') ? ENV['VM_MEMORY'] : "{{ config.memory }}" 5 | $CPUS = ENV.has_key?('VM_CPUS') ? ENV['VM_CPUS'] : "{{ config.cpus }}" 6 | $EXEC_CAP = ENV.has_key?('VM_EXEC_CAP') ? ENV['VM_EXEC_CAP'] : "{{ config.exec }}" 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 | 14 | config.vm.synced_folder "{{ config.src }}", "{{ config.dest }}", type: "nfs" 15 | 16 | config.vm.provider "virtualbox" do |v| 17 | v.name = "{{ config.projectName }}" 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.sudo = true 25 | ansible.playbook = "devops/provisioning/playbook.yml" 26 | ansible.limit = "vagrant" 27 | ansible.inventory_path = "{{ config.hostfile }}" 28 | ansible.verbose = "v" 29 | #ansible.tags = "config" 30 | #ansible.raw_arguments = "--vault-password-file=password.txt" 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /Tests/Config/DatabaseConfigTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('name', $databaseConfig->getName()); 15 | $this->assertEquals('user', $databaseConfig->getUser()); 16 | $this->assertEquals('password', $databaseConfig->getPassword()); 17 | } 18 | 19 | public function testDriverNotSupported() 20 | { 21 | $databaseConfig = new DatabaseConfig('notSupported'); 22 | 23 | $this->assertNull($databaseConfig->getService()); 24 | } 25 | 26 | public function testMysqlDriver() 27 | { 28 | $databaseConfig = new DatabaseConfig('pdo_mysql'); 29 | 30 | $this->assertEquals(ServicesConfig::MYSQL, $databaseConfig->getService()); 31 | } 32 | 33 | public function testPostgresqlDriver() 34 | { 35 | $databaseConfig = new DatabaseConfig('pdo_pgsql'); 36 | 37 | $this->assertEquals(ServicesConfig::POSTGRESQL, $databaseConfig->getService()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Tests/Finder/NodeFinderTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('node', $nodeFinder->getServiceName()); 14 | } 15 | 16 | public function testServiceIsNotPresent() 17 | { 18 | $nodeFinder = new NodeFinder(__DIR__ . '/test'); 19 | 20 | $this->assertFalse($nodeFinder->isPresent()); 21 | } 22 | 23 | public function testServiceIsPresent() 24 | { 25 | $nodeFinder = new NodeFinder(__DIR__ . '/../ressources/test'); 26 | 27 | $this->assertTrue($nodeFinder->isPresent()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Tests/Helper/ServiceHelperTest.php: -------------------------------------------------------------------------------- 1 | addService('notSupported'); 16 | 17 | $this->assertEmpty($servicesConfig->getServices()); 18 | } 19 | 20 | public function testAddDatabaseService() 21 | { 22 | $databaseConfig = Phake::mock(DatabaseConfig::class); 23 | Phake::when($databaseConfig)->getService()->thenReturn(ServicesConfig::MYSQL); 24 | $servicesConfig = new ServicesConfig($databaseConfig); 25 | $servicesConfig->addService('notSupported'); 26 | 27 | $this->assertNotEmpty($servicesConfig->getServices()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Tests/ressources/package.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fansible/DevopsBundle/5ef83f3a2bb976e756e492eefd2117c7ffa8e4ad/Tests/ressources/package.json -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fansible/devops-bundle", 3 | "license": "MIT", 4 | "type": "Devops", 5 | "description": "This will help you to generate a provisioning to run your Symfony apps", 6 | "keywords": ["Generate Provisioning Server Ansible Security"], 7 | "authors": [ 8 | { 9 | "name": "Simon Constans", 10 | "email": "simonc@linux.com" 11 | } 12 | ], 13 | "autoload": { 14 | "psr-4": { "Fansible\\DevopsBundle\\": "" } 15 | }, 16 | "require": { 17 | "symfony/symfony": ">=2.3.1" 18 | }, 19 | "minimum-stability": "stable", 20 | "require-dev": { 21 | "phpunit/phpunit": "~4.5", 22 | "phake/phake": "1.0.5" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ./Tests/ 7 | 8 | 9 | 10 | 11 | 12 | ./ 13 | 14 | ./Resources 15 | ./Tests 16 | ./vendor 17 | 18 | 19 | 20 | 21 | --------------------------------------------------------------------------------