├── .all-contributorsrc ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── defaults └── main.yml ├── meta └── main.yml ├── package-lock.json ├── package.json ├── tasks ├── database.yml ├── drone.yml └── main.yml └── vars └── main.yml /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "ansible-drone", 3 | "projectOwner": "paralect", 4 | "files": [ 5 | "README.md" 6 | ], 7 | "imageSize": 100, 8 | "commit": true, 9 | "contributors": [ 10 | { 11 | "login": "anorsich", 12 | "name": "Andrew Orsich", 13 | "avatar_url": "https://avatars3.githubusercontent.com/u/681396?v=4", 14 | "profile": "https://github.com/anorsich", 15 | "contributions": [ 16 | "doc", 17 | "ideas", 18 | "code", 19 | "doc", 20 | "ideas", 21 | "review" 22 | ] 23 | }, 24 | { 25 | "login": "ezhivitsa", 26 | "name": "Evgeny Zhivitsa", 27 | "avatar_url": "https://avatars2.githubusercontent.com/u/6461311?v=4", 28 | "profile": "https://github.com/ezhivitsa", 29 | "contributions": [ 30 | "doc" 31 | ] 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | .idea 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v1.2.1 (2019-07-12) 2 | 3 | * Fix typos in drone task 4 | 5 | ## v1.2.0 (2019-07-05) 6 | 7 | * Update dependencies. 8 | * Update drone to the version 1.0.0 9 | 10 | ## v1.1.0 (2019-07-05) 11 | 12 | * Update documentation. 13 | * Add bitbucket cloud integration 14 | 15 | ## v1.0.0 (2018-07-14) 16 | 17 | * Update documentation. 18 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at andrew@paralect.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING 2 | 3 | Contributions are always welcome, no matter how large or small. Before contributing, 4 | please read the [code of conduct](CODE_OF_CONDUCT.md). 5 | 6 | ## Pull Requests 7 | 8 | We actively welcome your pull requests. 9 | 10 | 1. Fork the repo and create your branch from `master`. 11 | 2. If you've added code that should be tested, add tests. 12 | 3. If you've changed APIs, update the documentation. 13 | 4. Ensure the test suite passes. 14 | 5. Make sure your code lints. 15 | 6. PR's must be rebased before merge (feel free to ask for help) 16 | 7. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you. 17 | 18 | ## Add yourself as a contributor 19 | 20 | This project follows the [all contributors](https://github.com/kentcdodds/all-contributors) specification. To add yourself to the table of contributors on the README.md, 21 | please use the automated script as part of your PR: 22 | 23 | ```console 24 | npm run add-contributor 25 | ``` 26 | 27 | Follow the prompt. If you've already added yourself to the list and are making a 28 | new type of contribution, you can run it again and select the added contribution 29 | type. 30 | 31 | ## License 32 | 33 | By contributing to Paralect Ship, you agree that your contributions will be licensed 34 | under its [MIT license](LICENSE). 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2017-present, Paralect LLC. https://www.paralect.com/ 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Drone 2 | 3 | [![Stack](https://raw.githubusercontent.com/paralect/stack/master/stack-component-template/stack.png)](https://github.com/paralect/stack) 4 | 5 | [![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors) 6 | [![Ansible Galaxy](https://img.shields.io/badge/ansible--galaxy-drone-blue.svg?style=flat-square)](https://galaxy.ansible.com/paralect/drone) 7 | [![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/paralect/ansible-mongo/blob/master/LICENSE) 8 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 9 | 10 | 11 | [![Watch on GitHub](https://img.shields.io/github/watchers/paralect/ansible-drone.svg?style=social&label=Watch)](https://github.com/paralect/ansible-drone/watchers) 12 | [![Star on GitHub](https://img.shields.io/github/stars/paralect/ansible-drone.svg?style=social&label=Stars)](https://github.com/paralect/ansible-drone/stargazers) 13 | [![Follow](https://img.shields.io/twitter/follow/paralect.svg?style=social&label=Follow)](https://twitter.com/paralect) 14 | [![Tweet](https://img.shields.io/twitter/url/https/github.com/paralect/ansible-drone.svg?style=social)](https://twitter.com/intent/tweet?text=I%27m%20using%20Stack%20components%20to%20build%20my%20next%20product%20🚀.%20Check%20it%20out:%20https://github.com/paralect/ansible-drone) 15 | 16 | An ansible role for the [drone](https://github.com/drone/drone) CI deployment with Github/Bitbucket Cloud integration and PostgreSQL database. 17 | 18 | ## Role Variables 19 | 20 | Available variables: 21 | 22 | |Name|Default|Description| 23 | |:--:|:--:|:----------| 24 | |**`drone_version`**|`latest`|Version of Drone CI, see other versions [here](https://hub.docker.com/r/drone/drone/tags)| 25 | |**`drone_user_create`**|`""`|Initial administrative account, which can be used to grant the administrator role to additional accounts. Read more [more](https://docs.drone.io/administration/user/admins)| 26 | |**`drone_agents`**|`[{name: "Nancy"}]`|Name of the docker agent container, you can add more than one agent| 27 | |**`drone_server_host`**|`""`|A string containing your Drone server hostname or IP address| 28 | |**`drone_rpc_secret`**|`hTirsXmrY4YsyK79ELgB`|Drone secret key, used for private communication between agent and web UI [more info](https://docs.drone.io/reference/server/drone-rpc-secret)| 29 | |**`drone_github_client_id`**|`""`|Github oauth application client identifier, [more info](https://docs.drone.io/installation/github/single-machine)| 30 | |**`drone_github_client_secret`**|`""`|Github oauth application client secret, [more info](https://docs.drone.io/installation/github/single-machine)| 31 | |**`drone_postgress_password`**|`droneRocks23@p`|A password to postgress db used by drone| 32 | |**`drone_postgress_user`**|`drone`|A username to postgress db used by drone, [read more](https://docs.drone.io/administration/server/database)| 33 | |**`drone_postgress_db`**|`drone`|A name of to postgress db used by drone, [read more](https://docs.drone.io/administration/server/database)| 34 | |**`drone_postgress_data_dir`**|`/drone-postgres-data`|A directory on a host machine, where postgresql data stored| 35 | |**`nginx_drone_internal_host`**|`http://localhost:8000`|Internal drone ui http url used by nginx to proxy traffic. For example: http://localhost:8000| 36 | 37 | ## Dependencies 38 | 39 | [Docker](https://www.docker.com/) must be installed on the server in order to use this role. If you don't have docker on your server we recommend [angstwad.docker_ubuntu](https://github.com/angstwad/docker.ubuntu) Ansible role. 40 | 41 | Example of using `angstwad.docker_ubuntu`: 42 | ```yml 43 | --- 44 | - name: Setup drone ci server 45 | hosts: drone 46 | become: true 47 | roles: 48 | - { role: angstwad.docker_ubuntu } 49 | ``` 50 | 51 | ## Quick example 52 | 53 | Example of the playbook file: 54 | 55 | ```yml 56 | --- 57 | - name: Deploy drone CI server 58 | hosts: drone 59 | become_user: root 60 | become: true 61 | roles: 62 | - role: paralect.drone 63 | # Version of Drone CI, see other versions here: https://hub.docker.com/r/drone/drone/tags/ 64 | drone_version: latest 65 | 66 | # the url, where drone instance will be publicly available 67 | # typically you would have nginx in front of Drone CI 68 | drone_server_host: 178.62.116.103 69 | 70 | # Drone secret key, used for private communication between agent and web UI 71 | # more info: https://docs.drone.io/reference/server/drone-rpc-secret/ 72 | drone_rpc_secret: hTirsXmrY4YsyK79ELgB 73 | 74 | # Github oauth application client id and secret, more info https://docs.drone.io/installation/github/single-machine/ 75 | drone_github_client_id: 76 | drone_github_client_secret: 77 | 78 | # A password to postgress db used by drone 79 | drone_postgress_password: droneRocks23@p 80 | # A username to postgress db used by drone, read more: https://docs.drone.io/administration/server/database/ 81 | drone_postgress_user: drone 82 | # A name of to postgress db used by drone, read more: https://docs.drone.io/administration/server/database/ 83 | drone_postgress_db: drone 84 | # a directory on a host machine, where postgresql data stored 85 | drone_postgress_data_dir: /drone-postgres-data 86 | ``` 87 | 88 | ## Change Log 89 | 90 | This project adheres to [Semantic Versioning](http://semver.org/). 91 | Every release is documented on the Github [Releases](https://github.com/paralect/node-mongo/releases) page. 92 | 93 | ## License 94 | 95 | Ansible-drone is released under the [MIT License](https://github.com/paralect/ansible-mongo/blob/master/LICENSE). 96 | 97 | ## Contributing 98 | 99 | Please read [CONTRIBUTING.md](https://github.com/paralect/ansible-drone/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. 100 | 101 | ## Contributors 102 | 103 | Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): 104 | 105 | 106 | 107 | | [
Andrew Orsich](https://github.com/anorsich)
[📖](https://github.com/paralect/ansible-drone/commits?author=anorsich "Documentation") [🤔](#ideas-anorsich "Ideas, Planning, & Feedback") [💻](https://github.com/paralect/ansible-drone/commits?author=anorsich "Code") [📖](https://github.com/paralect/ansible-drone/commits?author=anorsich "Documentation") [🤔](#ideas-anorsich "Ideas, Planning, & Feedback") [👀](#review-anorsich "Reviewed Pull Requests") | [
Evgeny Zhivitsa](https://github.com/ezhivitsa)
[📖](https://github.com/paralect/ansible-drone/commits?author=ezhivitsa "Documentation") | 108 | | :---: | :---: | 109 | 110 | 111 | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! 112 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Version of Drone CI, see other versions here: https://hub.docker.com/r/drone/drone/tags/ 2 | drone_version: latest 3 | 4 | # Initial administrative account, which can be used to grant the administrator role to additional accounts. 5 | # Read more: https://docs.drone.io/administration/user/admins/ 6 | drone_user_create: "" 7 | 8 | # Name of the docker agent container, you can add more than one agent 9 | drone_agents: [{name: "Nancy"}] 10 | 11 | # A string containing your Drone server protocol scheme. 12 | # This value should be set to http or https. 13 | drone_server_proto: http 14 | 15 | # A string containing your Drone server hostname or IP address. 16 | drone_server_host: 17 | 18 | # Drone secret key, used for private communication between agent and web UI 19 | # more info: https://docs.drone.io/reference/server/drone-rpc-secret/ 20 | drone_rpc_secret: hTirsXmrY4YsyK79ELgB 21 | 22 | # Github oauth application client id, more info https://docs.drone.io/installation/github/single-machine/ 23 | drone_github_client_id: 24 | # Github oauth application client secret, more info https://docs.drone.io/installation/github/single-machine/ 25 | drone_github_client_secret: 26 | 27 | # A password to postgress db used by drone 28 | drone_postgress_password: droneRocks23@p 29 | # A username to postgress db used by drone, read more: https://docs.drone.io/administration/server/database/ 30 | drone_postgress_user: drone 31 | # A name of to postgress db used by drone, read more: https://docs.drone.io/administration/server/database/ 32 | drone_postgress_db: drone 33 | # a directory on a host machine, where postgresql data stored 34 | drone_postgress_data_dir: /drone-postgres-data 35 | 36 | # Internal drone ui http url used by nginx to proxy traffic. For example: http://localhost:8000 37 | nginx_drone_internal_host: http://localhost:8000 38 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Paralect, LLC 4 | description: Drone CI deployment with Github integration and PostgreSQL database 5 | company: paralect 6 | license: MIT 7 | min_ansible_version: 1.2 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - trusty 12 | galaxy_tags: 13 | - drone 14 | - ci 15 | - system 16 | - cloud 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ansible-drone", 3 | "version": "1.2.1", 4 | "description": "An ansible role for the drone ci", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/paralect/ansible-drone.git" 8 | }, 9 | "author": "Paralect", 10 | "license": "MIT", 11 | "bugs": { 12 | "url": "https://github.com/paralect/ansible-drone/issues" 13 | }, 14 | "scripts": { 15 | "add-contributor": "all-contributors add", 16 | "generate-contributors": "all-contributors generate" 17 | }, 18 | "homepage": "https://github.com/paralect/ansible-drone#readme", 19 | "devDependencies": { 20 | "all-contributors-cli": "^6.7.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tasks/database.yml: -------------------------------------------------------------------------------- 1 | - name: start postgres for drone ci 2 | docker_container: 3 | name: postgres 4 | image: postgres:9.6.1 5 | state: started 6 | restart_policy: always 7 | ports: 8 | - "5432:5432" 9 | volumes: 10 | - "{{drone_postgress_data_dir}}:/var/lib/postgresql/data" 11 | env: 12 | POSTGRES_PASSWORD: "{{drone_postgress_password}}" 13 | POSTGRES_USER: "{{drone_postgress_user}}" 14 | POSTGRES_DB: "{{drone_postgress_db}}" 15 | tags: 16 | - postgres 17 | -------------------------------------------------------------------------------- /tasks/drone.yml: -------------------------------------------------------------------------------- 1 | - name: run drone server 2 | docker_container: 3 | name: drone-server 4 | image: "drone/drone:{{drone_version}}" 5 | state: started 6 | restart_policy: always 7 | ports: 8 | - "8000:8000" 9 | - "9000:9000" 10 | - "127.0.0.1:8080:80" 11 | - "127.0.0.1:8443:443" 12 | volumes: 13 | - /drone:/var/lib/drone/ 14 | - /var/run/docker.sock:/var/run/docker.sock 15 | links: 16 | - postgres 17 | env: 18 | DRONE_SERVER_HOST: "{{drone_server_host}}" 19 | DRONE_SERVER_ADDR: ":8000" 20 | DRONE_LOGS_DEBUG: "true" 21 | DRONE_RPC_SECRET: "{{drone_rpc_secret}}" 22 | DRONE_DATABASE_DRIVER: postgres 23 | DRONE_DATABASE_DATASOURCE: postgres://{{drone_postgress_user}}:{{drone_postgress_password}}@postgres:5432/{{drone_postgress_db}}?sslmode=disable 24 | DRONE_USER_CREATE: "{{drone_user_create}}" 25 | DRONE_GITHUB_CLIENT_ID: "{{drone_github_client_id}}" 26 | DRONE_GITHUB_CLIENT_SECRET: "{{drone_github_client_secret}}" 27 | DRONE_GITHUB_SKIP_VERIFY: "true" 28 | tags: 29 | - drone 30 | - server 31 | 32 | - name: run drone agent 33 | docker_container: 34 | name: "agent-{{item.name}}" 35 | image: "drone/agent:{{drone_version}}" 36 | privileged: yes 37 | state: started 38 | restart_policy: always 39 | volumes: 40 | - /var/run/docker.sock:/var/run/docker.sock 41 | links: 42 | - drone-server 43 | env: 44 | DRONE_RPC_SERVER: "drone-server:9000" 45 | DRONE_RPC_SECRET: "{{drone_rpc_secret}}" 46 | DRONE_LOGS_DEBUG: "true" 47 | with_items: "{{drone_agents}}" 48 | tags: 49 | - drone 50 | - agent 51 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include: database.yml 3 | - include: drone.yml 4 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paralect/ansible-drone/b9779067e195a00d85bcc634effba6f82df48c94/vars/main.yml --------------------------------------------------------------------------------