├── .github └── workflows │ └── lint.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .yamllint ├── LICENSE ├── Makefile ├── README.md ├── README.yaml ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── tasks ├── configure.yml ├── install.yml ├── main.yml └── users.yml └── templates ├── config └── pritunl.conf ├── pritunl └── pritunl.service /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Lint 3 | 'on': 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | 11 | test: 12 | name: Lint 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Check out the codebase. 17 | uses: actions/checkout@v2 18 | 19 | - name: Set up Python 3.7. 20 | uses: actions/setup-python@v2 21 | with: 22 | python-version: '3.x' 23 | 24 | - name: Install test dependencies. 25 | run: pip3 install yamllint ansible-lint 26 | 27 | - name: Run yamllint. 28 | run: yamllint . 29 | 30 | 31 | - name: 'Slack Notification' 32 | uses: clouddrove/action-slack@v2 33 | with: 34 | status: ${{ job.status }} 35 | fields: repo,author 36 | author_name: 'Clouddrove' 37 | env: 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 39 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} 40 | if: always() 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignored files 2 | .idea 3 | *.iml 4 | *.zip 5 | molecule 6 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | repos: 3 | 4 | - repo: https://github.com/pre-commit/pre-commit-hooks.git 5 | rev: v2.2.3 6 | hooks: 7 | - id: end-of-file-fixer 8 | - id: trailing-whitespace 9 | - id: mixed-line-ending 10 | - id: check-byte-order-marker 11 | - id: check-executables-have-shebangs 12 | - id: check-merge-conflict 13 | - id: debug-statements 14 | - id: check-yaml 15 | - id: check-added-large-files 16 | 17 | - repo: https://github.com/ansible/ansible-lint.git 18 | rev: v4.1.0 19 | hooks: 20 | - id: ansible-lint 21 | files: \.(yaml|yml)$ 22 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | line-length: 6 | max: 120 7 | level: warning 8 | truthy: 9 | allowed-values: ['true', 'false', 'yes', 'no'] 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Cloud Drove 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export GENIE_PATH ?= $(shell 'pwd')/../../../genie 2 | 3 | include $(GENIE_PATH)/Makefile 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

5 | 6 |

7 | Ansible Role Docker Pritunl 8 |

9 | 10 |

11 | This ansible role is used to install Pritunl and Mongodb with docker on server. 12 |

13 | 14 |

15 | 16 | 17 | Ansible 18 | 19 | 20 | Licence 21 | 22 | 23 | Distribution 24 | 25 | 26 | Distribution 27 | 28 | 29 | Distribution 30 | 31 | 32 | 33 |

34 |

35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |

47 |
48 | 49 | 50 | 51 | We eat, drink, sleep and most importantly love **DevOps**. DevOps always promotes automation and standardisation. While setting up various environments like local, dev, testing, production, etc. it is critical to maintain the same environment across. This can easily be achieved using automating the environment setup & installation with the help of ansible-playbooks. 52 | 53 | Smaller roles are created for each environment elements; which also include tasks & tests. These roles can then be grouped together in [ansible-playbook](https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html) to achieve the desired yet consistent results. 54 | 55 | 56 | 57 | ## Prerequisites 58 | 59 | This module has a few dependencies: 60 | 61 | - [Ansible2.8](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) 62 | - [Python](https://www.python.org/downloads) 63 | - [Docker](https://docs.docker.com/install/linux/docker-ce/ubuntu) 64 | 65 | 66 | 67 | 68 | ## What Includes 69 | 70 | Followiing things includes in this role: 71 | 72 | - pritunl 73 | - mongodb 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | ## Example Playbook 82 | 83 | **IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/ansible-role-docker-pritunl/releases). 84 | 85 | 86 | ```yaml 87 | - hosts: localhost 88 | remote_user: root 89 | become: true 90 | roles: 91 | - clouddrove.ansible_role_docker_pritunl 92 | ``` 93 | 94 | ## For default password 95 | ```console 96 | $ sudo docker exec -it pritunl pritunl default-password 97 | ``` 98 | 99 | 100 | ## Variables 101 | 102 | ```yaml 103 | pritunl_version: "latest" 104 | pritunl_path: "/opt/pritunl" 105 | pritunl_log: "/var/log/pritunl.log" 106 | pritunl_user: pritunl 107 | pritunl_group: pritunl 108 | mongo_path: "/opt/pritunl/mongo" 109 | mongo_user: mongo 110 | mongo_group: mongo 111 | ``` 112 | 113 | 114 | ## Installation 115 | 116 | ```console 117 | $ ansible-galaxy install clouddrove.ansible_role_docker_pritunl 118 | ``` 119 | 120 | 121 | 122 | 123 | 124 | 125 | ## Feedback 126 | If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/ansible-role-docker-pritunl/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com). 127 | 128 | If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/ansible-role-docker-pritunl)! 129 | 130 | ## About us 131 | 132 | At [CloudDrove][website], we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering. 133 | 134 |

We are The Cloud Experts!

135 |
136 |

We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.

137 | 138 | [website]: https://clouddrove.com 139 | [github]: https://github.com/clouddrove 140 | [linkedin]: https://cpco.io/linkedin 141 | [twitter]: https://twitter.com/clouddrove/ 142 | [email]: https://clouddrove.com/contact-us.html 143 | [terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language= 144 | -------------------------------------------------------------------------------- /README.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # This is the canonical configuration for the `README.md` 4 | # Run `make readme` to rebuild the `README.md` 5 | # 6 | 7 | # Name of this project 8 | name: Ansible Role Docker Pritunl 9 | 10 | # License of this project 11 | license: "MIT" 12 | 13 | # Canonical GitHub repo 14 | github_repo: clouddrove/ansible-role-docker-pritunl 15 | 16 | # Badges to display 17 | badges: 18 | - name: "Ansible" 19 | image: "https://img.shields.io/badge/Ansible-2.8-green?style=flat&logo=ansible" 20 | url: "https://www.ansible.com" 21 | - name: "Licence" 22 | image: "https://img.shields.io/badge/License-MIT-blue.svg" 23 | url: "LICENSE.md" 24 | - name: "Distribution" 25 | image: "https://img.shields.io/badge/ubuntu-16.x-orange?style=flat&logo=ubuntu" 26 | url: "https://ubuntu.com/" 27 | - name: "Distribution" 28 | image: "https://img.shields.io/badge/ubuntu-18.x-orange?style=flat&logo=ubuntu" 29 | url: "https://ubuntu.com/" 30 | - name: "Distribution" 31 | image: "https://img.shields.io/badge/centos-7.x-orange" 32 | url: "https://www.centos.org/" 33 | 34 | # Prerequesties to display 35 | # yamllint disable 36 | prerequesties: 37 | - name: "Ansible2.8" 38 | url: "https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html" 39 | - name: "Python" 40 | url: "https://www.python.org/downloads" 41 | - name: "Docker" 42 | url: "https://docs.docker.com/install/linux/docker-ce/ubuntu" 43 | # yamllint enable 44 | # What Includes to display 45 | what_includes: 46 | - name: "pritunl" 47 | - name: "mongodb" 48 | 49 | # description of this project 50 | description: |- 51 | This ansible role is used to install Pritunl and Mongodb with docker on server. 52 | 53 | # How to use this project 54 | usage: |- 55 | ```yaml 56 | - hosts: localhost 57 | remote_user: root 58 | become: true 59 | roles: 60 | - clouddrove.ansible_role_docker_pritunl 61 | ``` 62 | 63 | ## For default password 64 | ```console 65 | $ sudo docker exec -it pritunl pritunl default-password 66 | ``` 67 | 68 | # Variables use in the project 69 | variables: |- 70 | ```yaml 71 | pritunl_version: "latest" 72 | pritunl_path: "/opt/pritunl" 73 | pritunl_log: "/var/log/pritunl.log" 74 | pritunl_user: pritunl 75 | pritunl_group: pritunl 76 | mongo_path: "/opt/pritunl/mongo" 77 | mongo_user: mongo 78 | mongo_group: mongo 79 | ``` 80 | 81 | # How to install project 82 | installation: |- 83 | ```console 84 | $ ansible-galaxy install clouddrove.ansible_role_docker_pritunl 85 | ``` 86 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Pritunl variable 4 | pritunl_version: "latest" 5 | 6 | # Pritunl settings 7 | pritunl_path: "/opt/pritunl" 8 | pritunl_log: "/var/log/pritunl.log" 9 | pritunl_user: pritunl 10 | pritunl_group: pritunl 11 | 12 | # Mongo settings 13 | mongo_path: "/opt/pritunl/mongo" 14 | mongo_user: mongo 15 | mongo_group: mongo 16 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: restart pritunl 4 | service: 5 | name: pritunl 6 | state: restarted 7 | enabled: true 8 | 9 | - name: reload pritunl 10 | service: 11 | name: pritunl 12 | state: reloaded 13 | enabled: true 14 | 15 | - name: start pritunl 16 | service: 17 | name: pritunl 18 | state: started 19 | enabled: true 20 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | dependencies: [] 4 | 5 | galaxy_info: 6 | author: Anmol Nagpal 7 | description: This ansible role is used to install Pritunl and Mongodb with docker on server. 8 | company: "CloudDrove Inc." 9 | license: "license (BSD, MIT)" 10 | min_ansible_version: 2.4 11 | platforms: 12 | - name: Debian 13 | versions: 14 | - jessie 15 | - stretch 16 | - name: Ubuntu 17 | versions: 18 | - trusty 19 | - xenial 20 | - bionic 21 | galaxy_tags: 22 | - pritunl 23 | - mongodb 24 | - docker 25 | - centos 26 | - ubuntu 27 | -------------------------------------------------------------------------------- /tasks/configure.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: create pritunl dirs 4 | file: 5 | path: "{{item|safe|trim}}" 6 | state: directory 7 | owner: "{{pritunl_user}}" 8 | group: "{{pritunl_group}}" 9 | mode: 0755 10 | recurse: true 11 | with_items: 12 | - "{{pritunl_path}}" 13 | 14 | - name: create pritunl mongo dirs 15 | file: 16 | path: "{{item|safe|trim}}" 17 | state: directory 18 | owner: "{{mongo_user}}" 19 | group: "{{mongo_group}}" 20 | mode: 0755 21 | recurse: true 22 | with_items: 23 | - "{{mongo_path}}" 24 | 25 | - name: transfer pritunl.conf 26 | template: 27 | dest: "{{pritunl_path}}/pritunl.conf" 28 | src: "{{item}}" 29 | with_items: 30 | - config/pritunl.conf 31 | 32 | - name: create pritunl log 33 | shell: touch {{pritunl_log}} 34 | -------------------------------------------------------------------------------- /tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: copy pritunl script 4 | template: 5 | src: "pritunl" 6 | dest: /usr/local/bin/pritunl 7 | mode: 0755 8 | owner: root 9 | group: root 10 | 11 | - name: copy pritunl service 12 | template: 13 | src: "pritunl.service" 14 | dest: /etc/systemd/system/pritunl.service 15 | mode: 0644 16 | owner: root 17 | group: root 18 | notify: 19 | - restart pritunl 20 | 21 | - name: ensure pritunl service is restarted 22 | service: 23 | name: pritunl 24 | state: restarted 25 | enabled: true 26 | changed_when: false 27 | 28 | - name: wait for pritunl to become ready 29 | wait_for: 30 | host: "0.0.0.0" 31 | port: "443" 32 | state: started 33 | delay: 5 34 | connect_timeout: 15 35 | timeout: 500 36 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - import_tasks: users.yml 4 | - import_tasks: configure.yml 5 | - import_tasks: install.yml 6 | -------------------------------------------------------------------------------- /tasks/users.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: setup group 4 | group: 5 | name: "{{pritunl_group}}" 6 | system: false 7 | 8 | - name: setup user 9 | user: 10 | name: "{{pritunl_user}}" 11 | system: false 12 | group: "{{pritunl_group}}" 13 | 14 | - name: setup group 15 | group: 16 | name: "{{mongo_group}}" 17 | system: false 18 | 19 | - name: setup user 20 | user: 21 | name: "{{mongo_user}}" 22 | system: false 23 | group: "{{mongo_group}}" 24 | -------------------------------------------------------------------------------- /templates/config/pritunl.conf: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | { 3 | "mongodb_uri": "mongodb://localhost:27017/pritunl", 4 | "server_key_path": "/var/lib/pritunl/pritunl.key", 5 | "log_path": "{{ pritunl_log }}", 6 | "static_cache": true, 7 | "server_cert_path": "/var/lib/pritunl/pritunl.crt", 8 | "temp_path": "/tmp/pritunl_%r", 9 | "bind_addr": "0.0.0.0", 10 | "debug": false, 11 | "www_path": "/usr/share/pritunl/www", 12 | "local_address_interface": "auto" 13 | } 14 | -------------------------------------------------------------------------------- /templates/pritunl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eux -o pipefail 4 | 5 | # pull the image before so we dont first remove the container and then pull 6 | docker pull clouddrove/pritunl:{{ pritunl_version }} 7 | 8 | docker rm -f -v pritunl || : 9 | 10 | docker run --name pritunl --privileged \ 11 | -v "{{ pritunl_path }}":/var/lib/pritunl \ 12 | -v "{{ mongo_path }}":/var/lib/mongodb \ 13 | -v "{{ pritunl_path }}/pritunl.conf":/etc/pritunl.conf \ 14 | -v "{{ pritunl_log }}":{{ pritunl_log }} \ 15 | -v pritunl-conf:/etc \ 16 | -p 1194:1194/udp \ 17 | -p 1194:1194/tcp \ 18 | -p 80:80/tcp \ 19 | -p 443:443/tcp \ 20 | clouddrove/pritunl:{{ pritunl_version }} 21 | -------------------------------------------------------------------------------- /templates/pritunl.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Pritunl Server 3 | After=docker.service 4 | Requires=docker.service 5 | 6 | [Service] 7 | TimeoutStartSec=0 8 | Restart=always 9 | ExecStart=/usr/local/bin/pritunl 10 | ExecStop=-/usr/bin/docker rm -f -v pritunl 11 | 12 | [Install] 13 | WantedBy=multi-user.target 14 | --------------------------------------------------------------------------------