├── .gitignore ├── .kitchen.yml ├── .rubocop.yml ├── .travis.yml ├── Berksfile ├── CHANGELOG.md ├── LICENSE ├── README.md ├── attributes ├── agent.rb ├── default.rb └── server.rb ├── chefignore ├── libraries └── env.rb ├── metadata.rb ├── recipes ├── agent.rb ├── server.rb ├── standalone_agent.rb └── standalone_server.rb ├── spec ├── agent_spec.rb ├── server_spec.rb ├── spec_helper.rb └── support │ └── matchers.rb └── test ├── cookbooks ├── fake │ ├── metadata.rb │ └── recipes │ │ └── gogs.rb └── gogs │ ├── .editorconfig │ ├── .gitignore │ ├── .kitchen.yml │ ├── .travis.yml │ ├── Berksfile │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── Gemfile │ ├── README.md │ ├── Rakefile │ ├── attributes │ └── default.rb │ ├── chefignore │ ├── metadata.rb │ ├── recipes │ └── default.rb │ ├── spec │ ├── spec_helper.rb │ └── unit │ │ └── recipes │ │ └── default_spec.rb │ ├── templates │ └── default │ │ └── app.ini.erb │ └── test │ └── integration │ └── default │ └── serverspec │ ├── default_spec.rb │ └── spec_helper.rb └── integration ├── data_bags └── vault_drone │ └── drone_secret.json ├── drone-custom └── default_spec.rb ├── drone-docker-overrides └── default_spec.rb └── drone └── default_spec.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | *~ 4 | *# 5 | .#* 6 | \#*# 7 | .*.sw[a-z] 8 | *.un~ 9 | /cookbooks 10 | 11 | # Bundler 12 | Gemfile.lock 13 | bin/* 14 | .bundle/* 15 | 16 | .kitchen/ 17 | .kitchen.local.yml 18 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: vagrant 4 | customize: 5 | memory: 1024 6 | require_chef_omnibus: true 7 | 8 | verifier: 9 | name: inspec 10 | 11 | provisioner: 12 | name: chef_zero 13 | 14 | platforms: 15 | - name: ubuntu-16.04 16 | driver: 17 | box: bento/ubuntu-16.04 18 | run_list: 19 | - recipe[ubuntu::default] 20 | - recipe[chef-apt-docker::default] 21 | - name: centos 22 | driver: 23 | box: bento/centos-7.2 24 | run_list: 25 | - recipe[yum-epel::default] 26 | - recipe[chef-yum-docker::default] 27 | attributes: 28 | jmccann-docker-host: 29 | docker: 30 | service: 31 | storage_opts: overlay2.override_kernel_check=1 32 | 33 | suites: 34 | - name: drone 35 | run_list: 36 | - recipe[drone::standalone_server] 37 | - recipe[drone::agent] 38 | attributes: 39 | drone: 40 | agent: 41 | config: 42 | drone_server: 10.0.2.15:9000 43 | server: 44 | config: 45 | drone_host: http://10.0.2.15 46 | drone_github: true 47 | drone_github_client: GH_CLIENT 48 | drone_github_secret: GH_SECRET 49 | 50 | - name: drone-docker-overrides 51 | run_list: 52 | - recipe[drone::standalone_server] 53 | - recipe[drone::agent] 54 | attributes: 55 | drone: 56 | agent: 57 | config: 58 | drone_server: 10.0.2.15:9000 59 | network_mode: host 60 | docker: 61 | log_driver: syslog 62 | server: 63 | config: 64 | drone_host: http://10.0.2.15 65 | drone_github: true 66 | drone_github_client: GH_CLIENT 67 | drone_github_secret: GH_SECRET 68 | drone_server_addr: :80 69 | network_mode: host 70 | 71 | - name: drone-custom 72 | excludes: 73 | - centos 74 | driver: 75 | network: 76 | - ["forwarded_port", {guest: 8080, host: 8080}] 77 | - ["forwarded_port", {guest: 9080, host: 9080}] 78 | run_list: 79 | - recipe[gogs::default] 80 | - recipe[fake::gogs] 81 | - recipe[drone::standalone_server] 82 | - recipe[drone::agent] 83 | attributes: 84 | drone: 85 | agent: 86 | config: 87 | drone_server: 10.0.2.15:9000 88 | server: 89 | config: 90 | drone_host: http://10.0.2.15:9080 91 | drone_debug: true 92 | drone_gogs: true 93 | drone_gogs_url: http://10.0.2.15:8080 94 | drone_open: true 95 | port: ['9080:8000','9000:9000'] 96 | gogs: 97 | config: 98 | server: 99 | DOMAIN: 10.0.2.15 100 | HTTP_ADDR: 10.0.2.15 101 | version: '0.9.97' 102 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - 'test/cookbooks/**/*' 4 | 5 | LineLength: 6 | Max: 150 7 | 8 | AlignParameters: 9 | Enabled: false 10 | 11 | Encoding: 12 | Enabled: false 13 | 14 | StringLiterals: 15 | Enabled: false 16 | 17 | Style/SpaceBeforeFirstArg: 18 | Exclude: 19 | - metadata.rb 20 | 21 | WordArray: 22 | Enabled: false 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | addons: 4 | apt: 5 | sources: 6 | - chef-current-precise 7 | packages: 8 | - chefdk 9 | 10 | before_install: 11 | - eval "$(/opt/chefdk/bin/chef shell-init bash)" 12 | 13 | install: echo "Using ChefDK gems" 14 | 15 | before_script: 16 | - berks install 17 | - gem install docker-api -v 1.28.0 18 | 19 | script: 20 | - cookstyle 21 | - foodcritic . 22 | - rspec 23 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source "https://supermarket.chef.io" 2 | 3 | metadata 4 | 5 | cookbook 'chef-apt-docker', '~> 1.1' 6 | cookbook 'chef-yum-docker', '~> 2.1' 7 | cookbook 'ubuntu', '~> 2.0' 8 | cookbook 'yum-epel', '~> 1.0' 9 | cookbook 'gogs', path: 'test/cookbooks/gogs' 10 | 11 | cookbook 'fake', path: 'test/cookbooks/fake' 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Drone Cookbook Changelog 2 | ========================= 3 | 4 | v6.0.0 5 | ------ 6 | * **BREAKING**: Does not support versions of Drone older then 0.8.0 now. 7 | * **BREAKING**: `recipe[drone::default]` renamed to `recipe[drone::server]` 8 | * **BREAKING**: Does not manage docker install by default anymore. New *standalone* recipes 9 | included for that functionality now. 10 | * **BREAKING**: `node['drone']['repo']` seperated for agent (`node['drone']['agent']['repo']`) and server (`node['drone']['server']['repo']`). 11 | * **BREAKING**: Probably other breaking changes. Be sure to test this in a new environment. 12 | * Supports Drone 0.8.0 13 | 14 | v5.2.0 15 | ------ 16 | * Allow specifying `bip` for docker service 17 | 18 | v5.1.1 19 | ------ 20 | * Properly load defined storage driver by restarting Docker if currently not loaded 21 | 22 | v5.1.0 23 | ------ 24 | * Parameterize volumes for agent 25 | 26 | v5.0.0 27 | ------ 28 | * **BREAKING**: The behavior of `node['drone']['server']['port']` has changed slightly. 29 | Before it was the host port to NAT to the container port. Now it is the port 30 | value to pass to `docker_container('drone')` directly. 31 | * Added ability to set `network_mode` for server and agent. Default will remain `bridge`. 32 | 33 | v4.1.0 34 | ------ 35 | * Attributize items to load from vault 36 | 37 | v4.0.3 38 | ------ 39 | * Allow using `drone_database_config` as a secret 40 | 41 | v4.0.2 42 | ------ 43 | * Allow using `drone_database_config` as a secret 44 | 45 | v4.0.1 46 | ------ 47 | * Remove `chef_nginx` and `ssl_certificate` cookbook dependencies. 48 | 49 | v4.0.0 50 | ------ 51 | * **BREAKING**: Remove support for Drone 0.4 52 | * **BREAKING**: Remove support for old platforms (Ubuntu 14.x, Centos 6.x) 53 | * This allows control docker version on RHEL platforms too now! 54 | * May actually still work on older platforms, just not testing for it anymore. 55 | * **BREAKING**: Remove support for reverse proxy 56 | * Can still [configure HTTPS](README.md#https-config) 57 | * **BREAKING**: Remove SSL cert generation for docker 58 | * **BREAKING**: Move `node['drone']['config']` -> `node['drone']['server']['config']` 59 | * Install docker via packages 60 | 61 | v3.6.1 62 | ------ 63 | * Updates to work properly in Chef 13 64 | 65 | v3.6.0 66 | ------ 67 | * Allow specifying volumes to mount into Drone from host with `node['drone']['server']['volumes']` 68 | * Minor Breaking: specifying host port to bind Drone to with `node['drone']['server']['port']` 69 | * Decided to do this since 3.5.0 has been released for 30min now and this makes more sense and don't wanna major version bump. Sorry! 70 | 71 | v3.5.0 72 | ------ 73 | * Allow specifying host port to bind Drone to with `node['drone']['port']` 74 | 75 | v3.4.0 76 | ------ 77 | * Allow setting drone container to use with `node['drone']['repo']`. Default is `drone/drone` which is what was previously hardcoded. 78 | 79 | v3.3.0 80 | ------ 81 | * Allow setting node attributes `node['drone']['repo_activation_org_whitelist']` to whitelist orgs for repo activation when `node['drone']['disable_repo_activation']` is set to `true` 82 | 83 | v3.2.0 84 | ------ 85 | * Allow setting node attribute `node['drone']['disable_repo_activation']` to disable ability to activate new repos 86 | 87 | v3.1.3 88 | ------ 89 | * Update to work with Drone 0.5 new server <> agent commication protocol 90 | * http://readme.drone.io/0.5/installation/agents 91 | 92 | v3.1.2 93 | ------ 94 | * For newer version of Docker need to use new resource in docker cookbook for installing while specifying a version 95 | 96 | v3.1.1 97 | ------ 98 | * Fix reverse proxy for Drone 0.5 99 | 100 | v3.1.0 101 | ------ 102 | * Add ability to set docker daemon logging level 103 | 104 | v3.0.2 105 | ------ 106 | * Allow bypassing loading secrets on chef-vault failure (permissions) 107 | 108 | v3.0.1 109 | ------ 110 | * Fix allowing user to specify docker version 111 | 112 | v3.0.0 113 | ------ 114 | * BREAKING CHANGE (maybe): No longer pin version of docker to install by default. 115 | You still can do it if you want manually though. 116 | 117 | v2.5.0 118 | ------ 119 | * Support for CentOS 7.x 120 | 121 | v2.4.0 122 | ------ 123 | * Remove DEPRECATED drone token secrets management items 124 | * Added drone_secret support 125 | 126 | v2.3.0 127 | ------ 128 | * Allow drone_github_client to be in a Vault 129 | 130 | v2.2.0 131 | ------ 132 | * Attributize logging for Drone containers 133 | 134 | v2.1.0 135 | ------ 136 | * Allow specifying version of drone to use 137 | * Added `drone::agent` recipe for installing Drone 0.5 agent 138 | * Added ability to apply secrets `drone_agent_secret`, `drone_token`, `drone_github_secret` and `database_config` from vault 139 | 140 | v2.0.0 141 | ------ 142 | * BREAKING CHANGE: Move Drone app config items to `node['drone']['config']` 143 | * BREAKING CHANGE: Removed package install method as it's not supported 144 | * Added `drone::reverse_proxy` recipe to be able to front Drone with HTTPS via a reverse proxy 145 | * Added `drone::worker` recipe to be able to create additional systems to run drone builds on 146 | * Version bump on docker community cookbook 147 | * Make `docker_container` resource sensitive to prevent displaying secrets passed through ENV to drone 148 | 149 | v1.0.0 150 | ------ 151 | * BREAKING CHANGE: Use drone containers rather then installing drone package by default 152 | * Add ability to deploy drone using drone docker container 153 | 154 | v0.7.7 155 | ------ 156 | * Uses docker version from attributes (default 1.8.3) 157 | * Specify docker tls certs or use self-generated 158 | 159 | v0.7.0 160 | ------ 161 | * Deploy Drone v0.4.0 (a dev branch) 162 | * Add dronerc template 163 | * Add docker recipe to install docker from cookbook 164 | * Add update recipe to update docker images 165 | * For integrations generates docker self-signed certs 166 | 167 | v0.6.0 168 | ------ 169 | * Docker can now be disabled (Graham Weldon) 170 | * Fix `registration` option - moving to each VCS config (Graham Weldon) 171 | * Extend / improve README documentation 172 | 173 | v0.5.0 174 | ------ 175 | * Configure Drone with TOML (Graham Weldon) 176 | * Use new Drone package URL (Ke Zhu) 177 | 178 | v0.4.0 179 | ------ 180 | 181 | * Add Apache 2.0 license 182 | * Fix options being passed to droned (Ross Timson) 183 | * Numerous development/test improvements (Ross Timson) 184 | 185 | v0.3.1 186 | ------ 187 | 188 | * Settable drone_tmp (Eric Buth) 189 | 190 | v0.2.0 191 | ------ 192 | 193 | * Add ability to specify custom drone options (Brint O'Hearn) 194 | 195 | v0.1.0 196 | ------ 197 | 198 | * Initial Drone cookbook (Justin Campbell) 199 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Drone Cookbook 2 | [![Build Status](https://travis-ci.org/jmccann/chef-drone.svg?branch=master)](https://travis-ci.org/jmccann/chef-drone) 3 | 4 | Installs [Drone](https://github.com/drone/drone), a CI server built on [Docker](https://www.docker.io). 5 | 6 | More information also @ http://docs.drone.io. 7 | 8 | # Requirements 9 | 10 | ## Chef 11 | 12 | * Chef 12+ 13 | 14 | ## Platforms 15 | 16 | This cookbook is tested against: 17 | 18 | * Ubuntu 16.04 19 | * CentOS 7.x 20 | 21 | ...but it might work on other platforms. 22 | 23 | # Usage 24 | ## Recipes 25 | 26 | ### drone::agent 27 | Installs and sets up the drone agent. Assumes you have already setup and configured docker. 28 | 29 | Include `recipe[drone::agent]` in your run list. 30 | 31 | ### drone::server 32 | Installs the drone server. Assumes you have already setup and configured docker. 33 | 34 | Include `recipe[drone::server]` in your run list. 35 | 36 | ### drone::standalone_agent 37 | Installs the drone agent. 38 | Also will install and configure docker with [jmccann-docker-host cookbook](https://github.com/jmccann/jmccann-docker-host-cookbook). 39 | 40 | Include `recipe[drone::standalone_agent]` in your run list. 41 | 42 | ### drone::standalone_server 43 | Installs the drone server. 44 | Also will install and configure docker with [jmccann-docker-host cookbook](https://github.com/jmccann/jmccann-docker-host-cookbook). 45 | 46 | Include `recipe[drone::standalone_server]` in your run list. 47 | 48 | ## Attributes 49 | 50 | Attribute | Description | Type | Default 51 | ----------|-------------|------|-------- 52 | `node['drone']['agent']['config']` | Hash of configuration envvars for Drone Agent | Hash | See [Configuration](#configuration) section below. 53 | `node['drone']['agent']['repo']` | Docker repo to pull Drone Agent from | String | `'drone/agent'` 54 | `node['drone']['agent']['network_mode']` | What network mode to start Drone agent with. Default from Docker is `bridge`. | String | `nil` 55 | `node['drone']['agent']['vault']['items']` | Array of vault items to load from bag for agents | Array | `['drone_secret']` 56 | `node['drone']['agent']['volumes']` | Volumes to mount to drone from host for agent | Array | `['/var/run/docker.sock:/var/run/docker.sock']` 57 | `node['drone']['server']['config']` | Hash of configuration envvars for Drone Server | Hash | See [Configuration](#configuration) section below. 58 | `node['drone']['server']['network_mode']` | What network mode to start Drone server with. Default from Docker is `bridge`. | String | `nil` 59 | `node['drone']['server']['port']` | Docker port configuration for server. Binds container 8000 to host 80 and exposes port 9000 by default. | Array | `['80:8000', '9000:9000']` 60 | `node['drone']['server']['repo']` | Docker repo to pull Drone Server from | String | `'drone/drone'` 61 | `node['drone']['server']['vault']['items']` | Array of vault items to load from bag for server | Array | `['database_config' 'drone_database_datasource' 'drone_github_client' 'drone_github_secret' 'drone_license' 'drone_secret']` 62 | `node['drone']['server']['volumes']` | Volumes to mount to drone from host for server | Array | `['/var/lib/drone:/var/lib/drone', '/var/run/docker.sock:/var/run/docker.sock']` 63 | `node['drone']['vault']['bag']` | Name of vault with secrets | String | `'vault_drone'`. See [Vault](#vault) section below. 64 | `node['drone']['version']` | Version of Drone | String | `'0.8'` 65 | 66 | ## Configuration 67 | 68 | Drone is configured by setting certain ENV variables in the agent/server containers. 69 | 70 | For Drone ENV config settings see: 71 | * http://docs.drone.io/installation/ - Drone 0.8 72 | 73 | With this cookbook you can inject ENV variables to your Drone agent/server 74 | containers by using `node['drone']['agent']['config']` 75 | and `node['drone']['server']['config']`. The keys after `config` are the 76 | ENV variable names and the value you set is the value to assign the 77 | ENV variable. 78 | 79 | You can find examples of this in use in the [.kitchen.yml](.kitchen.yml) 80 | 81 | ## Secrets With Chef-Vault 82 | 83 | This cookbook supports using secrets from chef-vault. The vault bag to use 84 | is controlled by `node['drone']['vault']['bag']`. Vault items that are loaded 85 | are controlled by the `default['drone']['agent']['vault']['items']` 86 | and `default['drone']['server']['vault']['items']` attributes. 87 | 88 | ## HTTPS Config 89 | 90 | Drone has the ability to terminate SSL connections. This cookbook doesn't do 91 | this for you but supports being able to do it. 92 | 93 | 1. Add your cert and private key to the host 94 | * https://github.com/zuazo/ssl_certificate-cookbook 95 | 2. Expose the certificates to the Drone container using `node['drone']['server']['volumes']` 96 | ```ruby 97 | node['drone']['server']['volumes'] = [ 98 | "/var/lib/drone:/var/lib/drone", 99 | "/var/run/docker.sock:/var/run/docker.sock", 100 | "/etc/ssl/certs/drone.pem:/etc/ssl/certs/drone.pem", 101 | "/etc/ssl/private/drone.key:/etc/ssl/private/drone.key" 102 | ] 103 | ``` 104 | 3. Configure Drone to use the cert/key pair 105 | ```ruby 106 | node['drone']['config']['drone_server_cert'] = '/etc/ssl/certs/drone.pem' 107 | node['drone']['config']['drone_server_key'] = '/etc/ssl/private/drone.key' 108 | ``` 109 | 4. Expose Drone service via host port 443 110 | ```ruby 111 | node['drone']['server']['port'] = '443:8000' 112 | ``` 113 | 114 | ## Docker 115 | 116 | See `attributes/docker.rb` for more options. 117 | 118 | ## Testing 119 | 120 | * Linting - Rubocop and Foodcritic 121 | * Spec - ChefSpec 122 | * Integration - Test Kitchen 123 | 124 | Testing requires [ChefDK](https://downloads.chef.io/chef-dk/) be installed using it's native gems. 125 | 126 | ``` 127 | gem install docker-api 128 | foodcritic -f any -X spec . 129 | rubocop 130 | rspec --color --format progress 131 | ``` 132 | 133 | If you run into issues testing please first remove any additional gems you may 134 | have installed into your ChefDK environment. Extra gems can be found and removed 135 | at `~/.chefdk/gem`. 136 | -------------------------------------------------------------------------------- /attributes/agent.rb: -------------------------------------------------------------------------------- 1 | default['drone']['agent']['config']['drone_server'] = 'localhost:9000' 2 | default['drone']['agent']['repo'] = 'drone/agent' 3 | default['drone']['agent']['vault']['items'] = %w(drone_secret) 4 | default['drone']['agent']['volumes'] = ['/var/run/docker.sock:/var/run/docker.sock'] 5 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['drone']['version'] = '0.8' 2 | default['drone']['vault']['bag'] = 'vault_drone' 3 | -------------------------------------------------------------------------------- /attributes/server.rb: -------------------------------------------------------------------------------- 1 | default['drone']['server']['port'] = ['80:8000', '9000:9000'] 2 | default['drone']['server']['repo'] = 'drone/drone' 3 | default['drone']['server']['vault']['items'] = %w(database_config drone_database_datasource drone_github_client drone_github_secret drone_license drone_secret) 4 | default['drone']['server']['volumes'] = ['/var/lib/drone:/var/lib/drone', '/var/run/docker.sock:/var/run/docker.sock'] 5 | 6 | # server configuration 7 | # 8 | default['drone']['server']['config']['drone_database_driver'] = 'sqlite3' 9 | default['drone']['server']['config']['drone_database_config'] = '/var/lib/drone/drone.sqlite' 10 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | Berksfile 73 | Berksfile.lock 74 | cookbooks/* 75 | tmp 76 | 77 | # Cookbooks # 78 | ############# 79 | CONTRIBUTING 80 | CHANGELOG* 81 | 82 | # Strainer # 83 | ############ 84 | Colanderfile 85 | Strainerfile 86 | .colander 87 | .strainer 88 | 89 | # Vagrant # 90 | ########### 91 | .vagrant 92 | Vagrantfile 93 | 94 | # Travis # 95 | ########## 96 | .travis.yml 97 | -------------------------------------------------------------------------------- /libraries/env.rb: -------------------------------------------------------------------------------- 1 | module ChefDrone 2 | # Methods for generating drone container ENV from node attributes 3 | module Env 4 | def drone_env 5 | env = node['drone']['server']['config'].map { |k, v| "#{k.upcase}=#{v}" } 6 | node['drone']['server']['vault']['items'].each do |item| 7 | env = override_secret env, item 8 | end 9 | env 10 | end 11 | 12 | def agent_env 13 | env = node['drone']['agent']['config'].map { |k, v| "#{k.upcase}=#{v}" } 14 | node['drone']['agent']['vault']['items'].each do |item| 15 | env = override_secret env, item 16 | end 17 | env 18 | end 19 | 20 | # 21 | # Override attribute secrets if in Vault or DataBag 22 | # 23 | def override_secret(current_env, item) 24 | return current_env unless secret_exist? item 25 | 26 | Chef::Log.info("Loading secret '#{node['drone']['vault']['bag']}/#{item}' ...") 27 | secret = chef_vault_item(node['drone']['vault']['bag'], item)[item] 28 | current_env.delete_if { |env| env =~ /#{item.upcase}=/ }.push("#{item.upcase}=#{secret}") 29 | rescue ChefVault::Exceptions::SecretDecryption 30 | Chef::Log.warn "Could not load secret for '#{node['drone']['vault']['bag']}/#{item}' (ChefVault::Exceptions::SecretDecryption)" 31 | current_env 32 | end 33 | 34 | # 35 | # Check if secret exists in Vault or DataBag 36 | # 37 | def secret_exist?(item) 38 | Chef::DataBag.list.keys.include?(node['drone']['vault']['bag']) && Chef::DataBag.load(node['drone']['vault']['bag']).keys.include?(item) 39 | end 40 | end 41 | end 42 | 43 | Chef::Recipe.send(:include, ChefDrone::Env) 44 | DockerCookbook::DockerContainer.send(:include, ChefDrone::Env) 45 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'drone' 2 | maintainer 'Jacob McCann' 3 | maintainer_email 'jmccann.git@gmail.com' 4 | license 'Apache-2.0' 5 | description 'Installs/Configures Drone' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | source_url 'https://github.com/jmccann/chef-drone' 8 | issues_url 'https://github.com/jmccann/chef-drone/issues' 9 | chef_version '>= 12.0.0' 10 | version '6.0.0' 11 | 12 | depends 'chef-vault', '~> 2.1' 13 | depends 'docker', '~> 2.15' 14 | depends 'jmccann-docker-host', '3.0' 15 | 16 | supports 'ubuntu', '>= 16.04' 17 | supports 'centos', '>= 7.1' 18 | -------------------------------------------------------------------------------- /recipes/agent.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'chef-vault::default' 2 | 3 | docker_image 'agent' do 4 | repo node['drone']['agent']['repo'] 5 | tag node['drone']['version'] 6 | end 7 | 8 | docker_container 'agent' do 9 | repo node['drone']['agent']['repo'] 10 | tag node['drone']['version'] 11 | env agent_env 12 | volumes node['drone']['agent']['volumes'] 13 | network_mode node['drone']['agent']['network_mode'] if node['drone']['agent']['network_mode'] 14 | restart_policy 'always' 15 | sensitive true 16 | 17 | if node['drone']['docker'] 18 | node['drone']['docker'].each do |k, v| 19 | send(k, v) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /recipes/server.rb: -------------------------------------------------------------------------------- 1 | directory '/var/lib/drone' 2 | 3 | include_recipe 'chef-vault::default' 4 | 5 | docker_image 'drone' do 6 | repo node['drone']['server']['repo'] 7 | tag node['drone']['version'] 8 | end 9 | 10 | docker_container 'drone' do 11 | repo node['drone']['server']['repo'] 12 | tag node['drone']['version'] 13 | env drone_env 14 | volumes node['drone']['server']['volumes'] 15 | network_mode node['drone']['server']['network_mode'] if node['drone']['server']['network_mode'] 16 | restart_policy 'always' 17 | sensitive true 18 | port node['drone']['server']['port'] 19 | 20 | if node['drone']['docker'] 21 | node['drone']['docker'].each do |k, v| 22 | send(k, v) 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /recipes/standalone_agent.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'jmccann-docker-host::default' 2 | include_recipe 'drone::agent' 3 | -------------------------------------------------------------------------------- /recipes/standalone_server.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'jmccann-docker-host::default' 2 | include_recipe 'drone::server' 3 | -------------------------------------------------------------------------------- /spec/agent_spec.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: drone 3 | # Spec:: agent 4 | # 5 | 6 | require 'spec_helper' 7 | 8 | describe 'drone::agent' do 9 | context 'When all attributes are default, on ubuntu, getting secrets from attribtues' do 10 | cached(:chef_run) do 11 | runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node, _server| 12 | node.default['drone']['agent']['config']['drone_secret'] = "ATTRagentTOKEN" 13 | end 14 | runner.converge(described_recipe) 15 | end 16 | 17 | before do 18 | stub_command("docker info | grep 'Storage Driver: aufs'").and_return false 19 | end 20 | 21 | it 'converges successfully' do 22 | chef_run # This should not raise an error 23 | end 24 | 25 | it 'creates agent container' do 26 | expect(chef_run).to run_docker_container('agent').with(repo: 'drone/agent', tag: '0.8') 27 | end 28 | 29 | it 'mounts docker socket' do 30 | expect(chef_run).to run_docker_container('agent') 31 | .with(volumes_binds: ['/var/run/docker.sock:/var/run/docker.sock']) 32 | end 33 | 34 | describe 'agent container environment' do 35 | let(:agent_env) do 36 | chef_run.docker_container('agent').env 37 | end 38 | 39 | it 'sets DRONE_SERVER from attribute' do 40 | expect(agent_env).to include('DRONE_SERVER=localhost:9000') 41 | end 42 | 43 | it 'sets DRONE_TOKEN from attribute' do 44 | expect(agent_env).to include('DRONE_SECRET=ATTRagentTOKEN') 45 | end 46 | 47 | it 'is sensitive' do 48 | expect(chef_run).to run_docker_container('agent').with(sensitive: true) 49 | end 50 | end 51 | end 52 | 53 | context 'When all attributes are default, on ubuntu, getting secrets from vault' do 54 | cached(:chef_run) do 55 | runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node, server| 56 | server.create_data_bag('vault_drone', 'drone_secret' => { 'drone_secret' => 'RANDOMagentTOKEN' }) 57 | node.default['drone']['agent']['config']['drone_secret'] = "ATTRagentTOKEN" 58 | end 59 | runner.converge(described_recipe) 60 | end 61 | 62 | before do 63 | stub_command("docker info | grep 'Storage Driver: aufs'").and_return false 64 | end 65 | 66 | it 'converges successfully' do 67 | chef_run # This should not raise an error 68 | end 69 | 70 | describe 'agent container environment' do 71 | let(:agent_env) do 72 | chef_run.docker_container('agent').env 73 | end 74 | 75 | it 'sets secret for DRONE_TOKEN from vault' do 76 | expect(agent_env).not_to include('DRONE_SECRET=ATTRagentTOKEN') 77 | expect(agent_env).to include('DRONE_SECRET=RANDOMagentTOKEN') 78 | end 79 | end 80 | end 81 | 82 | context 'When attributes are overridden, on ubuntu, getting secrets from vault' do 83 | cached(:chef_run) do 84 | runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node, _server| 85 | node.normal['drone']['agent']['repo'] = 'jmccann/agent' 86 | node.normal['drone']['version'] = '0.6' 87 | node.normal['drone']['agent']['volumes'] = ['/var/run/docker.sock:/var/run/docker.sock', '/etc/ssl/certs/ca-bundle.pem:/etc/ssl/certs/ca-bundle.pem'] 88 | node.normal['drone']['docker']['log_driver'] = 'syslog' 89 | node.normal['drone']['docker']['log_opts'] = 'tag=myapp' 90 | end 91 | runner.converge(described_recipe) 92 | end 93 | 94 | before do 95 | stub_command("docker info | grep 'Storage Driver: aufs'").and_return false 96 | end 97 | 98 | it 'converges successfully' do 99 | chef_run # This should not raise an error 100 | end 101 | 102 | it 'installs drone from a different repo' do 103 | expect(chef_run).to run_docker_container('agent').with(repo: 'jmccann/agent') 104 | end 105 | 106 | it 'installs a different version of drone' do 107 | expect(chef_run).to run_docker_container('agent').with(tag: '0.6') 108 | end 109 | 110 | it 'mounts specified volumes' do 111 | expect(chef_run).to run_docker_container('agent') 112 | .with(volumes_binds: ['/var/run/docker.sock:/var/run/docker.sock', '/etc/ssl/certs/ca-bundle.pem:/etc/ssl/certs/ca-bundle.pem']) 113 | end 114 | 115 | it 'uses custom logging' do 116 | expect(chef_run).to run_docker_container('agent') 117 | .with(log_driver: 'syslog', log_opts: { 'tag' => 'myapp' }) 118 | end 119 | end 120 | end 121 | -------------------------------------------------------------------------------- /spec/server_spec.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: drone 3 | # Spec:: server 4 | # 5 | 6 | require 'spec_helper' 7 | 8 | describe 'drone::server' do 9 | context 'When all attributes are default, on ubuntu, getting secrets from attribtues' do 10 | cached(:chef_run) do 11 | runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node, _server| 12 | node.default['drone']['server']['config']['drone_secret'] = "ATTRagentSECRET" 13 | end 14 | runner.converge(described_recipe) 15 | end 16 | 17 | before do 18 | stub_command("docker info | grep 'Storage Driver: aufs'").and_return false 19 | end 20 | 21 | it 'converges successfully' do 22 | chef_run # This should not raise an error 23 | end 24 | 25 | it 'creates drone container' do 26 | expect(chef_run).to run_docker_container('drone') 27 | .with(repo: 'drone/drone', tag: '0.8', port: ['80:8000', '9000:9000'], 28 | volumes_binds: ['/var/lib/drone:/var/lib/drone', 29 | '/var/run/docker.sock:/var/run/docker.sock']) 30 | end 31 | 32 | describe 'drone container environment' do 33 | let(:drone_env) do 34 | chef_run.docker_container('drone').env 35 | end 36 | 37 | it 'does not set database driver' do 38 | expect(drone_env).to include('DRONE_DATABASE_DRIVER=sqlite3') 39 | end 40 | 41 | it 'does not set database config' do 42 | expect(drone_env).to include('DRONE_DATABASE_CONFIG=/var/lib/drone/drone.sqlite') 43 | end 44 | 45 | it 'sets DRONE_AGENT_SECRET from attr' do 46 | expect(drone_env).to include('DRONE_SECRET=ATTRagentSECRET') 47 | end 48 | 49 | it 'is sensitive' do 50 | expect(chef_run).to run_docker_container('drone').with(sensitive: true) 51 | end 52 | end 53 | end 54 | 55 | context 'When all attributes are default, on ubuntu, getting secrets from vault' do 56 | cached(:chef_run) do 57 | runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node, server| 58 | inject_databags server 59 | node.default['drone']['server']['config']['drone_secret'] = "ATTRagentSECRET" 60 | end 61 | runner.converge(described_recipe) 62 | end 63 | 64 | before do 65 | stub_command("docker info | grep 'Storage Driver: aufs'").and_return false 66 | end 67 | 68 | it 'converges successfully' do 69 | chef_run # This should not raise an error 70 | end 71 | 72 | describe 'agent container environment' do 73 | let(:drone_env) do 74 | chef_run.docker_container('drone').env 75 | end 76 | 77 | it 'sets secret for DRONE_AGENT_SECRET from vault' do 78 | expect(drone_env).not_to include('DRONE_SECRET=ATTRagentSECRET') 79 | expect(drone_env).to include('DRONE_SECRET=RANDOMagentSECRET') 80 | end 81 | end 82 | end 83 | 84 | context 'When attributes are set, on ubuntu' do 85 | cached(:chef_run) do 86 | runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node, _server| 87 | node.normal['drone']['server']['repo'] = 'jmccann/drone' 88 | node.normal['drone']['version'] = '0.6' 89 | node.normal['drone']['server']['port'] = ['443:8000', '9001:9000'] 90 | node.normal['drone']['server']['volumes'] = ['/var/lib/drone:/var/lib/drone', '/var/run/docker.sock:/var/run/docker.sock', '/etc/ssl/certs/drone.pem:/etc/ssl/certs/drone.pem', '/etc/ssl/private/drone.key:/etc/ssl/private/drone.key'] 91 | node.normal['drone']['docker']['log_driver'] = 'syslog' 92 | node.normal['drone']['docker']['log_opts'] = 'tag=myapp' 93 | end 94 | runner.converge(described_recipe) 95 | end 96 | 97 | before do 98 | stub_command("docker info | grep 'Storage Driver: aufs'").and_return false 99 | end 100 | 101 | it 'converges successfully' do 102 | chef_run # This should not raise an error 103 | end 104 | 105 | it 'installs drone from a different repo' do 106 | expect(chef_run).to run_docker_container('drone').with(repo: 'jmccann/drone') 107 | end 108 | 109 | it 'installs a different version of drone' do 110 | expect(chef_run).to run_docker_container('drone').with(tag: '0.6') 111 | end 112 | 113 | it 'runs drone on a different port' do 114 | expect(chef_run).to run_docker_container('drone').with(port: ['443:8000', '9001:9000']) 115 | end 116 | 117 | it 'runs drone with different volumes' do 118 | expect(chef_run).to run_docker_container('drone') 119 | .with(volumes_binds: ['/var/lib/drone:/var/lib/drone', '/var/run/docker.sock:/var/run/docker.sock', 120 | '/etc/ssl/certs/drone.pem:/etc/ssl/certs/drone.pem', 121 | '/etc/ssl/private/drone.key:/etc/ssl/private/drone.key']) 122 | end 123 | 124 | it 'uses custom logging' do 125 | expect(chef_run).to run_docker_container('drone') 126 | .with(log_driver: 'syslog', log_opts: { 'tag' => 'myapp' }) 127 | end 128 | end 129 | end 130 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'chefspec' 2 | require 'chefspec/berkshelf' 3 | require_relative 'support/matchers' 4 | 5 | def subdirs_for(dir) 6 | Dir.entries(dir).select do |entry| 7 | (File.directory? File.join(dir, entry)) && !(entry == '.' || entry == '..') 8 | end 9 | end 10 | 11 | def inject_databags(server) 12 | data_bags_path = File.expand_path(File.join(File.dirname(__FILE__), '../test/integration/data_bags')) 13 | subdirs_for(data_bags_path).each do |databag| 14 | Dir["#{data_bags_path}/#{databag}/*.json"].each do |item_path| 15 | item = File.basename(item_path, File.extname(item_path)) 16 | server.create_data_bag(databag, item => JSON.parse(File.read(item_path))) 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /spec/support/matchers.rb: -------------------------------------------------------------------------------- 1 | ChefSpec.define_matcher :docker_container 2 | 3 | def create_docker_installation_tarball(resource_name) 4 | ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_tarball, :create, resource_name) 5 | end 6 | 7 | def delete_docker_installation_tarball(resource_name) 8 | ChefSpec::Matchers::ResourceMatcher.new(:docker_installation_tarball, :delete, resource_name) 9 | end 10 | -------------------------------------------------------------------------------- /test/cookbooks/fake/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'fake' 2 | maintainer 'Jacob McCann' 3 | maintainer_email 'jmccann.git@gmail.com' 4 | license 'Apache 2.0' 5 | description 'Installs/Configures Drone' 6 | long_description 'Installs/Configures Drone' 7 | source_url 'https://github.com/jmccann/chef-drone' 8 | issues_url 'https://github.com/jmccann/chef-drone/issues' 9 | version '0.1.0' 10 | 11 | depends 'gogs' 12 | -------------------------------------------------------------------------------- /test/cookbooks/fake/recipes/gogs.rb: -------------------------------------------------------------------------------- 1 | # Fix to get supervisord to actually start gogs 2 | r = resources(supervisord_program: 'gogs') 3 | r.directory "#{node['gogs']['install_dir']}/gogs" 4 | r.environment HOME: '/home/git', USER: 'git' 5 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/.editorconfig: -------------------------------------------------------------------------------- 1 | ; EditorConfig is awesome: http://EditorConfig.org 2 | 3 | root = true 4 | 5 | ; Ruby style 6 | ; UTF-8 charset 7 | ; Unix-style newlines with a newline ending every file 8 | ; 2 space indent 9 | ; Trim trailing whitespace 10 | [*] 11 | indent_style = space 12 | indent_size = 2 13 | end_of_line = lf 14 | charset = utf-8 15 | trim_trailing_whitespace = true 16 | insert_final_newline = true 17 | 18 | ; Markdown 19 | ; 4 space indent 20 | [*.md] 21 | indent_size = 4 -------------------------------------------------------------------------------- /test/cookbooks/gogs/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | *~ 4 | *# 5 | .#* 6 | \#*# 7 | .*.sw[a-z] 8 | *.un~ 9 | 10 | # Bundler 11 | Gemfile.lock 12 | bin/* 13 | .bundle/* 14 | 15 | .kitchen/ 16 | .kitchen.local.yml 17 | .kitchen.list.yml 18 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: vagrant 4 | 5 | provisioner: 6 | name: chef_zero 7 | 8 | platforms: 9 | - name: ubuntu-12.04 10 | driver_config: 11 | network: 12 | - ["forwarded_port", {guest: 8080, host: 8080}] 13 | - name: ubuntu-14.04 14 | driver_config: 15 | network: 16 | - ["forwarded_port", {guest: 8080, host: 8080}] 17 | suites: 18 | - name: default 19 | run_list: 20 | - recipe[gogs::default] 21 | attributes: 22 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | cache: bundler 3 | rvm: 4 | - 2.1 5 | bundler_args: "--without integration --deployment --retry 3" 6 | before_script: 7 | - bundle exec berks 8 | script: 9 | - bundle exec rake travis 10 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | metadata 4 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log for gogs 2 | All notable changes to this project will be documented in this file. 3 | This project adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | ## [Unreleased][unreleased] 6 | ### Changed 7 | - Improve argument against commit logs. 8 | 9 | ## [0.0.2] - YYY-MM-DD 10 | ### Added 11 | - Explanation of the recommended reverse chronological release ordering. 12 | 13 | ### Changed 14 | - Refer to a "change log" instead of a "CHANGELOG" throughout the site 15 | to differentiate between the file and the purpose of the file — the 16 | logging of changes. 17 | 18 | ### Removed 19 | - Remove empty sections from CHANGELOG, they occupy too much space and 20 | create too much noise in the file. People will have to assume that the 21 | missing sections were intentionally left out because they contained no 22 | notable changes. 23 | 24 | ## 0.0.1 - YYYY-MM-DD 25 | ### Added 26 | - This CHANGELOG file to hopefully serve as an evolving example of a standardized open source project CHANGELOG. 27 | - CNAME file to enable GitHub Pages custom domain 28 | - README now contains answers to common questions about CHANGELOGs 29 | - Good examples and basic guidelines, including proper date formatting. 30 | - Counter-examples: "What makes unicorns cry?" 31 | 32 | [unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.8...HEAD 33 | [0.0.2]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.1...v0.0.2 -------------------------------------------------------------------------------- /test/cookbooks/gogs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | 1. Fork the repository on Github 4 | 2. Create a named feature branch (like `add_component_x`) 5 | 3. Write your change 6 | 4. Write tests for your change (if applicable) 7 | 5. Run the tests with `kitchen test`, ensuring they all pass 8 | 6. Submit a Pull Request using Github 9 | 10 | ## License and Authors 11 | 12 | Author:: Eddie Hurtig (eddie@hurtigtechnologies.com) -------------------------------------------------------------------------------- /test/cookbooks/gogs/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'berkshelf', '~> 3.2' 4 | gem 'chef-sugar' 5 | 6 | group :unit do 7 | gem 'foodcritic', '~> 4.0' 8 | gem 'rubocop', '~> 0.29' 9 | gem 'chefspec', '~> 4.2' 10 | end 11 | 12 | group :integration do 13 | gem 'test-kitchen', '~> 1.3' 14 | gem 'kitchen-vagrant', '~> 0.15' 15 | end 16 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/README.md: -------------------------------------------------------------------------------- 1 | # gogs [![Build Status](https://travis-ci.org/EdHurtig/chef-gogs.svg)](https://travis-ci.org/EdHurtig/chef-gogs) 2 | 3 | Installs gogs (Go Git Service), An open source Git Service. 4 | 5 | This cookbook installs gogs on port 8080 with sqllite3 by default. It skips the installer 6 | meaning that everything is set to go; however, you will need to create an admin account 7 | on your own. Do this by just going to the web ui and filling out the form or by inserting into 8 | the database. LWRP for that to come at some point. 9 | 10 | # Requirements 11 | 12 | * `apt` cookbook 13 | * `systemd` cookbook 14 | * `ark` cookbook 15 | * `chef-sugar` cookbook 16 | 17 | 18 | # Attributes 19 | 20 | ### Install Attributes 21 | 22 | * `node['gogs']['install_dir']` default: `'/opt'` 23 | 24 | The path to install gogs to, note that there will be a `gogs` subfolder created where everything will live. 25 | By default the executable and configuration lives in `/opt/gogs/`. 26 | 27 | * `node['gogs']['version']` default `'0.6.1'` 28 | 29 | The Release version to install. See https://github.com/gogits/gogs/releases 30 | 31 | ### Config Attributes 32 | 33 | The `node['gogs']['config']` tree gets parsed into the gogs [app.ini](https://github.com/gogits/gogs/blob/master/conf/app.ini). 34 | Note that the attributes are split into sections then into their individual settings. 35 | 36 | For Documentation on what each setting does please refer to the [app.ini](https://github.com/gogits/gogs/blob/master/conf/app.ini) 37 | 38 | An excerpt of [attributes/default.rb](https://github.com/EdHurtig/chef-gogs/blob/master/attributes/default.rb) 39 | to give you an idea of how these options work: 40 | 41 | ```ruby 42 | default['gogs']['config']['global']['APP_NAME'] = 'Gogs: Go Git Service' 43 | default['gogs']['config']['global']['RUN_USER'] = 'git' 44 | default['gogs']['config']['global']['RUN_MODE'] = 'prod' 45 | 46 | default['gogs']['config']['repository']['ROOT'] = '/ops/gogs/repos' 47 | default['gogs']['config']['repository']['SCRIPT_TYPE'] = 'bash' 48 | 49 | default['gogs']['config']['server']['PROTOCOL'] = 'http' 50 | default['gogs']['config']['server']['DOMAIN'] = 'localhost' 51 | default['gogs']['config']['server']['ROOT_URL'] = '%(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/' 52 | default['gogs']['config']['server']['HTTP_ADDR'] = '0.0.0.0' 53 | default['gogs']['config']['server']['HTTP_PORT'] = 8080 54 | ``` 55 | 56 | # Recipes 57 | 58 | ## default 59 | 60 | This recipe installs and configures gogs 61 | 62 | 1. Set up & updates apt using `apt::default` 63 | 2. Installs Git and Supervisord 64 | 3. Downloads and installs gogs from Github 65 | 4. Configures gogs according to `node['gogs']['config']` 66 | 67 | 68 | # Usage 69 | 70 | Include this recipe in a wrapper cookbook: 71 | 72 | ``` 73 | depends 'gogs', '~> 1.0' 74 | ``` 75 | 76 | ``` 77 | include_recipe 'gogs::default' 78 | ``` 79 | 80 | ## Contributing 81 | 82 | 1. Fork the repository on Github 83 | 2. Create a named feature branch (like `add_component_x`) 84 | 3. Write your change 85 | 4. Write tests for your change (if applicable) 86 | 5. Run the tests with `kitchen test`, ensuring they all pass 87 | 6. Submit a Pull Request using Github 88 | 89 | ## License and Authors 90 | 91 | Author:: Eddie Hurtig (eddie@hurtigtechnologies.com) 92 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | require 'bundler/setup' 4 | require 'rspec/core/rake_task' 5 | require 'rubocop/rake_task' 6 | require 'foodcritic' 7 | 8 | namespace :style do 9 | desc 'Run Ruby style checks' 10 | RuboCop::RakeTask.new(:ruby) 11 | 12 | desc 'Run Chef style checks' 13 | FoodCritic::Rake::LintTask.new(:chef) 14 | end 15 | 16 | desc 'Run all style checks' 17 | task style: ['style:chef', 'style:ruby'] 18 | 19 | desc 'Run ChefSpec unit tests' 20 | RSpec::Core::RakeTask.new(:unit) 21 | 22 | desc 'Run Test Kitchen integration tests' 23 | task :integration do 24 | require 'kitchen/rake_tasks' 25 | Kitchen.logger = Kitchen.default_file_logger 26 | Kitchen::Config.new.instances.each do |instance| 27 | instance.test(:always) 28 | end 29 | end 30 | 31 | desc 'Run style & unit tests on Travis' 32 | task travis: %w(style unit) 33 | 34 | desc 'Run all tests by default' 35 | task default: %w(travis integration) 36 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['gogs']['install_dir'] = '/opt' 2 | default['gogs']['version'] = '0.9.113' 3 | 4 | default['gogs']['config']['global']['APP_NAME'] = 'Gogs: Go Git Service' 5 | default['gogs']['config']['global']['RUN_USER'] = 'git' 6 | default['gogs']['config']['global']['RUN_MODE'] = 'prod' 7 | 8 | default['gogs']['config']['repository']['ROOT'] = '/ops/gogs/repos' 9 | default['gogs']['config']['repository']['SCRIPT_TYPE'] = 'bash' 10 | 11 | default['gogs']['config']['server']['PROTOCOL'] = 'http' 12 | default['gogs']['config']['server']['DOMAIN'] = 'localhost' 13 | default['gogs']['config']['server']['ROOT_URL'] = '%(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/' 14 | default['gogs']['config']['server']['HTTP_ADDR'] = '0.0.0.0' 15 | default['gogs']['config']['server']['HTTP_PORT'] = 8080 16 | default['gogs']['config']['server']['DISABLE_SSH'] = false 17 | default['gogs']['config']['server']['SSH_PORT'] = 22 18 | default['gogs']['config']['server']['OFFLINE_MODE'] = false 19 | default['gogs']['config']['server']['DISABLE_ROUTER_LOG'] = false 20 | default['gogs']['config']['server']['CERT_FILE'] = 'custom/https/cert.pem' 21 | default['gogs']['config']['server']['KEY_FILE'] = 'custom/https/key.pem' 22 | default['gogs']['config']['server']['ENABLE_GZIP'] = false 23 | default['gogs']['config']['server']['LANDING_PAGE'] = 'home' 24 | 25 | default['gogs']['config']['database']['DB_TYPE'] = 'sqlite3' 26 | default['gogs']['config']['database']['PATH'] = 'data/gogs.db' 27 | 28 | # default['gogs']['config']['database']['DB_TYPE'] = 'mysql' 29 | default['gogs']['config']['database']['HOST'] = '127.0.0.1:3306' 30 | default['gogs']['config']['database']['NAME'] = 'gogs' 31 | default['gogs']['config']['database']['USER'] = 'root' 32 | default['gogs']['config']['database']['PASSWD'] = '' 33 | default['gogs']['config']['database']['SSL_MODE'] = 'disable' 34 | 35 | default['gogs']['config']['admin'] = {} 36 | 37 | default['gogs']['config']['security']['INSTALL_LOCK'] = true 38 | default['gogs']['config']['security']['SECRET_KEY'] = SecureRandom.urlsafe_base64(nil, true) 39 | default['gogs']['config']['security']['LOGIN_REMEMBER_DAYS'] = 7 40 | default['gogs']['config']['security']['COOKIE_USERNAME'] = 'gogs_awesome' 41 | default['gogs']['config']['security']['COOKIE_REMEMBER_NAME'] = 'gogs_incredible' 42 | default['gogs']['config']['security']['REVERSE_PROXY_AUTHENTICATION_USER'] = 'X-WEBAUTH-USER' 43 | 44 | default['gogs']['config']['service']['ACTIVE_CODE_LIVE_MINUTES'] = 180 45 | default['gogs']['config']['service']['RESET_PASSWD_CODE_LIVE_MINUTES'] = 180 46 | default['gogs']['config']['service']['REGISTER_EMAIL_CONFIRM'] = false 47 | default['gogs']['config']['service']['DISABLE_REGISTRATION'] = false 48 | default['gogs']['config']['service']['REQUIRE_SIGNIN_VIEW'] = false 49 | default['gogs']['config']['service']['ENABLE_CACHE_AVATAR'] = false 50 | default['gogs']['config']['service']['ENABLE_NOTIFY_MAIL'] = false 51 | default['gogs']['config']['service']['ENABLE_REVERSE_PROXY_AUTHENTICATION'] = false 52 | default['gogs']['config']['service']['ENABLE_REVERSE_PROXY_AUTO_REGISTRATION'] = false 53 | default['gogs']['config']['service']['DISABLE_MINIMUM_KEY_SIZE_CHECK'] = false 54 | 55 | default['gogs']['config']['webhook']['TASK_INTERVAL'] = 1 56 | default['gogs']['config']['webhook']['DELIVER_TIMEOUT'] = 5 57 | default['gogs']['config']['webhook']['SKIP_TLS_VERIFY'] = false 58 | 59 | default['gogs']['config']['mailer']['ENABLED'] = false 60 | default['gogs']['config']['mailer']['SEND_BUFFER_LEN'] = 10 61 | default['gogs']['config']['mailer']['SUBJECT'] = '%(APP_NAME)s' 62 | default['gogs']['config']['mailer']['HOST'] = '' 63 | default['gogs']['config']['mailer']['SKIP_VERIFY'] = '' 64 | default['gogs']['config']['mailer']['USE_CERTIFICATE'] = false 65 | default['gogs']['config']['mailer']['CERT_FILE'] = 'custom/mailer/cert.pem' 66 | default['gogs']['config']['mailer']['KEY_FILE'] = 'custom/mailer/key.pem' 67 | default['gogs']['config']['mailer']['FROM'] = '' 68 | default['gogs']['config']['mailer']['USER'] = '' 69 | default['gogs']['config']['mailer']['PASSWD'] = '' 70 | 71 | default['gogs']['config']['oauth']['ENABLED'] = true 72 | 73 | default['gogs']['config']['oauth.github']['CLIENT_ID'] = '' 74 | default['gogs']['config']['oauth.github']['CLIENT_SECRET'] = '' 75 | default['gogs']['config']['oauth.github']['ENABLED'] = true 76 | default['gogs']['config']['oauth.github']['SCOPES'] = 'https://api.github.com/user' 77 | default['gogs']['config']['oauth.github']['AUTH_URL'] = 'https://github.com/login/oauth/authorize' 78 | default['gogs']['config']['oauth.github']['TOKEN_URL'] = 'https://github.com/login/oauth/access_token' 79 | 80 | default['gogs']['config']['oauth.google']['ENABLED'] = false 81 | default['gogs']['config']['oauth.google']['CLIENT_ID'] = '' 82 | default['gogs']['config']['oauth.google']['CLIENT_SECRET'] = '' 83 | default['gogs']['config']['oauth.google']['SCOPES'] = 84 | 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile' 85 | default['gogs']['config']['oauth.google']['AUTH_URL'] = 'https://accounts.google.com/o/oauth2/auth' 86 | default['gogs']['config']['oauth.google']['TOKEN_URL'] = 'https://accounts.google.com/o/oauth2/token' 87 | 88 | default['gogs']['config']['oauth.qq']['ENABLED'] = false 89 | default['gogs']['config']['oauth.qq']['CLIENT_ID'] = '' 90 | default['gogs']['config']['oauth.qq']['CLIENT_SECRET'] = '' 91 | default['gogs']['config']['oauth.qq']['SCOPES'] = 'get_user_info' 92 | default['gogs']['config']['oauth.qq']['AUTH_URL'] = 'https://graph.qq.com/oauth2.0/authorize' 93 | default['gogs']['config']['oauth.qq']['TOKEN_URL'] = 'https://graph.qq.com/oauth2.0/token' 94 | 95 | default['gogs']['config']['oauth.weibo']['ENABLED'] = false 96 | default['gogs']['config']['oauth.weibo']['CLIENT_ID'] = '' 97 | default['gogs']['config']['oauth.weibo']['CLIENT_SECRET'] = '' 98 | default['gogs']['config']['oauth.weibo']['SCOPES'] = 'all' 99 | default['gogs']['config']['oauth.weibo']['AUTH_URL'] = 'https://api.weibo.com/oauth2/authorize' 100 | default['gogs']['config']['oauth.weibo']['TOKEN_URL'] = 'https://api.weibo.com/oauth2/access_token' 101 | 102 | default['gogs']['config']['cache']['ADAPTER'] = 'memory' 103 | default['gogs']['config']['cache']['INTERVAL'] = 60 104 | default['gogs']['config']['cache']['HOST'] = '' 105 | 106 | default['gogs']['config']['session']['PROVIDER'] = 'memory' 107 | default['gogs']['config']['session']['PROVIDER_CONFIG'] = 'data/sessions' 108 | default['gogs']['config']['session']['COOKIE_NAME'] = 'i_like_gogits' 109 | default['gogs']['config']['session']['COOKIE_SECURE'] = false 110 | default['gogs']['config']['session']['ENABLE_SET_COOKIE'] = true 111 | default['gogs']['config']['session']['GC_INTERVAL_TIME'] = 86_400 112 | default['gogs']['config']['session']['SESSION_LIFE_TIME'] = 86_400 113 | 114 | default['gogs']['config']['picture']['SERVICE'] = 'server' 115 | default['gogs']['config']['picture']['AVATAR_UPLOAD_PATH'] = 'data/avatars' 116 | default['gogs']['config']['picture']['GRAVATAR_SOURCE'] = 'gravatar' 117 | default['gogs']['config']['picture']['DISABLE_GRAVATAR'] = false 118 | 119 | default['gogs']['config']['attachment']['ENABLE'] = true 120 | default['gogs']['config']['attachment']['PATH'] = 'data/attachments' 121 | default['gogs']['config']['attachment']['ALLOWED_TYPES'] = 'image/jpeg|image/png' 122 | default['gogs']['config']['attachment']['MAX_SIZE'] = 32 123 | default['gogs']['config']['attachment']['MAX_FILES'] = 10 124 | 125 | default['gogs']['config']['time']['FORMAT'] = '' 126 | 127 | default['gogs']['config']['log']['ROOT_PATH'] = '' 128 | default['gogs']['config']['log']['MODE'] = 'file' 129 | default['gogs']['config']['log']['BUFFER_LEN'] = 10_000 130 | default['gogs']['config']['log']['LEVEL'] = 'Info' 131 | 132 | default['gogs']['config']['log.console']['LEVEL'] = '' 133 | 134 | default['gogs']['config']['log.file']['LEVEL'] = '' 135 | default['gogs']['config']['log.file']['LOG_ROTATE'] = true 136 | default['gogs']['config']['log.file']['MAX_LINES'] = 1_000_000 137 | default['gogs']['config']['log.file']['MAX_SIZE_SHIFT'] = 28 138 | default['gogs']['config']['log.file']['DAILY_ROTATE'] = true 139 | default['gogs']['config']['log.file']['MAX_DAYS'] = 7 140 | 141 | default['gogs']['config']['log.conn']['LEVEL'] = '' 142 | default['gogs']['config']['log.conn']['RECONNECT_ON_MSG'] = false 143 | default['gogs']['config']['log.conn']['RECONNECT'] = false 144 | default['gogs']['config']['log.conn']['PROTOCOL'] = 'tcp' 145 | default['gogs']['config']['log.conn']['ADDR'] = '' 146 | 147 | default['gogs']['config']['og.smtp']['LEVEL'] = '' 148 | default['gogs']['config']['og.smtp']['SUBJECT'] = 'Diagnostic message from serve' 149 | default['gogs']['config']['og.smtp']['HOST'] = '' 150 | default['gogs']['config']['og.smtp']['USER'] = '' 151 | default['gogs']['config']['og.smtp']['PASSWD'] = '' 152 | default['gogs']['config']['og.smtp']['RECEIVERS'] = '' 153 | 154 | default['gogs']['config']['log.database']['LEVEL'] = '' 155 | default['gogs']['config']['log.database']['DRIVER'] = '' 156 | default['gogs']['config']['log.database']['CONN'] = '' 157 | 158 | default['gogs']['config']['git']['MAX_GIT_DIFF_LINES'] = 10_000 159 | default['gogs']['config']['git']['GC_ARGS'] = '' 160 | 161 | default['gogs']['config']['git.fsck']['ENABLE'] = true 162 | default['gogs']['config']['git.fsck']['INTERVAL'] = 24 163 | default['gogs']['config']['git.fsck']['ARGS'] = '' 164 | 165 | default['gogs']['config']['i18n']['LANGS'] = 166 | 'en-US,zh-CN,zh-HK,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL' 167 | default['gogs']['config']['i18n']['NAMES'] = 168 | 'English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本语,Español,Português,Polski' 169 | 170 | default['gogs']['config']['other']['SHOW_FOOTER_BRANDING'] = false 171 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | Berksfile 73 | Berksfile.lock 74 | cookbooks/* 75 | tmp 76 | 77 | # Cookbooks # 78 | ############# 79 | CONTRIBUTING 80 | 81 | # Strainer # 82 | ############ 83 | Colanderfile 84 | Strainerfile 85 | .colander 86 | .strainer 87 | 88 | # Vagrant # 89 | ########### 90 | .vagrant 91 | Vagrantfile 92 | 93 | # Travis # 94 | ########## 95 | .travis.yml 96 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'gogs' 2 | maintainer 'Eddie Hurtig' 3 | maintainer_email 'eddie@hurtigtechnologies.com' 4 | license 'apache2' 5 | description 'Installs and Configures a Go Git Service Server' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.1' 8 | 9 | supports 'ubuntu', '>= 12.04' 10 | 11 | depends 'chef-sugar' 12 | depends 'ark' 13 | depends 'apt' 14 | depends 'supervisord', '~> 1.0.0' 15 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: gogs 3 | # Recipe:: default 4 | # 5 | # Copyright 2015 Eddie Hurtig 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | include_recipe 'apt' 20 | 21 | include_recipe 'chef-sugar' 22 | 23 | include_recipe 'supervisord' 24 | 25 | os = 'linux' 26 | os = 'darwin' if osx? 27 | os = 'windows' if windows? 28 | 29 | package 'unzip' 30 | package 'git' 31 | 32 | user node['gogs']['config']['global']['RUN_USER'] do 33 | action :create 34 | comment 'Gogs User' 35 | home "/home/#{node['gogs']['config']['global']['RUN_USER']}" 36 | shell '/bin/bash' 37 | manage_home true 38 | end 39 | 40 | [ 41 | node['gogs']['install_dir'], 42 | "#{node['gogs']['install_dir']}/gogs/custom/conf", 43 | node['gogs']['config']['repository']['ROOT'] 44 | ].each do |dir| 45 | directory dir do 46 | owner node['gogs']['config']['global']['RUN_USER'] 47 | group node['gogs']['config']['global']['RUN_USER'] 48 | mode '0755' 49 | action :create 50 | recursive true 51 | end 52 | end 53 | 54 | ark 'gogs' do 55 | path node['gogs']['install_dir'] 56 | url "https://github.com/gogits/gogs/releases/download/v#{node['gogs']['version']}/#{os}_amd64.zip" 57 | owner node['gogs']['config']['global']['RUN_USER'] 58 | group node['gogs']['config']['global']['RUN_USER'] 59 | action :put 60 | end 61 | 62 | template "#{node['gogs']['install_dir']}/gogs/custom/conf/app.ini" do 63 | source 'app.ini.erb' 64 | owner node['gogs']['config']['global']['RUN_USER'] 65 | mode '0644' 66 | variables config: JSON.parse(node['gogs']['config'].to_json) 67 | end 68 | 69 | supervisord_program 'gogs' do 70 | directory "#{node['gogs']['install_dir']}/gogs" 71 | command "#{node['gogs']['install_dir']}/gogs/gogs web" 72 | autorestart true 73 | startretries 10 74 | user node['gogs']['config']['global']['RUN_USER'] 75 | environment [ 76 | "HOME=/home/#{node['gogs']['config']['global']['RUN_USER']}", 77 | "USER=#{node['gogs']['config']['global']['RUN_USER']}" 78 | ] 79 | stderr_logfile "#{node['gogs']['install_dir']}/gogs/supervisord_gogs.err.log" 80 | stdout_logfile "#{node['gogs']['install_dir']}/gogs/supervisord_gogs.out.log" 81 | action [:supervise, :start] 82 | end 83 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'chefspec' 2 | require 'chefspec/berkshelf' 3 | 4 | RSpec.configure do |config| 5 | config.formatter = :documentation 6 | config.color = true 7 | end 8 | 9 | at_exit { ChefSpec::Coverage.report! } 10 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/spec/unit/recipes/default_spec.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: gogs 3 | # Spec:: default 4 | # 5 | # Copyright 2015 Eddie Hurtig 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | require 'spec_helper' 20 | 21 | describe 'gogs::default' do 22 | context 'When all attributes are default, on an unspecified platform' do 23 | let(:chef_run) do 24 | runner = ChefSpec::ServerRunner.new 25 | runner.converge(described_recipe) 26 | end 27 | it 'converges successfully' do 28 | chef_run # This should not raise an error 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/templates/default/app.ini.erb: -------------------------------------------------------------------------------- 1 | <% @config.each do |section, settings| %> 2 | <% unless section == 'global' %> 3 | [<%= section %>] 4 | <% end %> 5 | <% settings.each do |key, val| %> 6 | <%= key %> = <%= val %> 7 | <% end %> 8 | 9 | <% end %> 10 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/test/integration/default/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'gogs::default' do 4 | # Serverspec examples can be found at 5 | # http://serverspec.org/resource_types.html 6 | it 'does something' do 7 | skip 'Replace this with meaningful tests' 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /test/cookbooks/gogs/test/integration/default/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | -------------------------------------------------------------------------------- /test/integration/data_bags/vault_drone/drone_secret.json: -------------------------------------------------------------------------------- 1 | { 2 | "drone_secret": "RANDOMagentSECRET" 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/drone-custom/default_spec.rb: -------------------------------------------------------------------------------- 1 | puts 'Waiting for gogs to start' 2 | sleep 5 3 | 4 | describe file('/var/lib/drone/drone.sqlite') do 5 | it { should be_file } 6 | end 7 | 8 | # Gogs 9 | describe port(8080) do 10 | it { should be_listening } 11 | end 12 | 13 | # Drone 14 | describe port(9080) do 15 | it { should be_listening } 16 | end 17 | 18 | # Ubuntu image doesn't doesn't have cURL by default but wget can be used. 19 | describe command("wget -q --no-check-certificate http://localhost:9080") do 20 | its(:exit_status) { should eq 0 } 21 | end 22 | 23 | # Agent connects 24 | describe command("docker logs agent") do 25 | its(:exit_status) { should eq 0 } 26 | its(:stdout) { should eq '' } 27 | its(:stderr) { should include('pipeline: request next execution') } 28 | end 29 | describe command("docker logs drone") do 30 | its(:exit_status) { should eq 0 } 31 | its(:stderr) { should include('agent connected: ip address 172.17.0.1') } 32 | end 33 | -------------------------------------------------------------------------------- /test/integration/drone-docker-overrides/default_spec.rb: -------------------------------------------------------------------------------- 1 | describe file('/var/lib/drone/drone.sqlite') do 2 | it { should be_file } 3 | end 4 | 5 | describe port(80) do 6 | it { should be_listening } 7 | end 8 | 9 | # Ubuntu image doesn't doesn't have cURL by default but wget can be used. 10 | describe command("wget -q --no-check-certificate http://localhost") do 11 | its(:exit_status) { should eq 0 } 12 | end 13 | 14 | # Should be logging to syslog 15 | describe command("docker logs agent") do 16 | its(:exit_status) { should eq 1 } 17 | end 18 | 19 | # No logs from agent (meaning no errors) 20 | log_file = "/var/log/syslog" 21 | log_file = "/var/log/messages" if os[:family] == "redhat" 22 | 23 | describe file(log_file) do 24 | its(:content) { should include('pipeline: request next execution') } 25 | end 26 | 27 | # Make sure running in host network mode 28 | describe command("docker inspect drone") do 29 | its(:stdout) { should include('"NetworkMode": "host"') } 30 | end 31 | describe command("docker inspect agent") do 32 | its(:stdout) { should include('"NetworkMode": "host"') } 33 | end 34 | -------------------------------------------------------------------------------- /test/integration/drone/default_spec.rb: -------------------------------------------------------------------------------- 1 | describe file('/var/lib/drone/drone.sqlite') do 2 | it { should be_file } 3 | end 4 | 5 | describe port(80) do 6 | it { should be_listening } 7 | end 8 | 9 | # Ubuntu image doesn't doesn't have cURL by default but wget can be used. 10 | describe command("wget -q --no-check-certificate http://localhost") do 11 | its(:exit_status) { should eq 0 } 12 | end 13 | 14 | # No logs from agent (meaning no errors) 15 | describe command("docker logs agent") do 16 | its(:exit_status) { should eq 0 } 17 | its(:stderr) { should include('pipeline: request next execution') } 18 | end 19 | 20 | # Make sure running in host network mode 21 | describe command("docker inspect drone") do 22 | its(:stdout) { should include('"NetworkMode": "bridge"') } 23 | end 24 | describe command("docker inspect agent") do 25 | its(:stdout) { should include('"NetworkMode": "bridge"') } 26 | end 27 | --------------------------------------------------------------------------------