Git Product home page Git Product logo

ansible-digitalocean-vpn's Introduction

Ansible playbooks

!!! Not supported: I haven't been using this for couple years and don't plan to start using it again soon. I've heard somebody has ported this module to Ansible Galaxy -- please check there for an updated version. !!!

This is a collection of Ansible playbooks I use to automate certain tasks. They are intended for personal use only and chances are will not suite your needs. However bugrepots and pull requests are welcome.

All examples below imply that you have setup inventory for you.

Base image

Sets up the basic server with vim, git installed, nano uninstalled etc.

Usage:

ansible-playbook bootstrap.yml

OpenVPN server

Sets up the OpenVPN server configured to use with static key. You need to have a server in your inventory named vpn for this to work.

  • First you need to generate the static key and place it as files/static.key. (Pay attention to file name: this file is .gitignored but if you change the name you'll need to handle the gitignore also). You can generate is like the following:
openvpn --genkey --secret static.key
  • Check the list of variables in vpn.yml and adjust them to your needs.

  • Run ansible-playbook vpn.yml

If you meet no errors you'll get the OpenVPN server set up and running in less than a minute.

To configure your Ubuntu box to connect to this server do the following:

  • Install NetworkManager OpenVPN plugin: sudo apt-get install network-manager-openvpn-gnome
  • Add the OpenVPN connection from NetworkManager menu:
  • Enter the IP address of your server
  • Select "Static key authentication"
  • Choose static.key you've generated a while ago
  • Enter value from the playbook for server_addr into "Remote address" field and value for client_addr into "Local address".
  • Try to connect to VPN using this connection
  • Check that you are really using VPN: curl ipecho.net/plain

Autodeploy of VPN server to Digital Ocean

You can make ansible to do creation of DigitalOcean droplet for you prior to installing OpenVPN onto it.

To do that you need to do the configurations from the previous chapter ("VPN") and do the following additional configuration steps:

  • Add line localhost to your ansible inventory. My inventory file is looking as follows:
vpn ansible_ssh_user=root
localhost
  • Create file host_vars/localhost under you ansible configuration directory (i.e. /etc/ansiblie/host_vars/localhost) and put the following content to it:
---
do_client_id: YOUR_CLIENT_ID_HERE
do_api_key: YOUR_API_KEY_HERE
do_ssh_key_id: SSH_KEY_ID

You can generate your client ID and API key at https://cloud.digitalocean.com/api_access As for ssh key id, you can only know that by doing manual API request:

curl -k 'https://api.digitalocean.com/ssh_keys/?client_id=YOUR_CLIENT_ID&api_key=YOUR_API_KEY'

and check the number in "id" field.

  • Make sure you can login to your localhost by SSH as yourself or root

When you have the above in place you run the command:

./create_vpn.sh

and have the VPN server accessible as vpn hostname from your localhost in a several moments.

Important: If you use ansible-playbook instead and you don't have passwordless sudo for yourself set up on localhost you must run the command with -K key (like ansible-playbook -K vpn_digital_ocean.yml) or ansible will hang infinitely.

Contributing

Pull requests are welcome

License and Author

  • Author:: Timur Batyrshin
  • License:: Apache 2.0

ansible-digitalocean-vpn's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ansible-digitalocean-vpn's Issues

Convert to role for inclusion on galaxy

Not sure if you're still maintaining this. I'd like to fork the repo and toss it up on galaxy.ansible.com, so I can include it more easily in personal projects. In the process I'll need to restructure the project as a role, with default vars and other boilerplate. Let me know if you'd like to submit it to galaxy, otherwise I'll go ahead with the fork.

error while installing tugboat

PLAY [vpn] ******************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [vpn]

TASK: [install rubygems] ****************************************************** 
changed: [vpn]

TASK: [install tugboat] ******************************************************* 
changed: [vpn]

TASK: [create tugboat config] ************************************************* 
changed: [vpn]

TASK: [verify tugboat installation] ******************************************* 
failed: [vpn] => {"changed": false, "cmd": ["tugboat", "verify"], "delta": "0:00:00.026326", "end": "2014-02-27 04:51:21.342197", "item": "", "rc": 1, "start": "2014-02-27 04:51:21.315871"}
stderr: /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': /var/lib/gems/1.8/gems/tugboat-0.2.0/lib/tugboat/cli.rb:12: syntax error, unexpected ':', expecting kEND (SyntaxError)
    class_option :quiet, type: :boolean, aliases: "-q"
                              ^
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.8/gems/tugboat-0.2.0/lib/tugboat.rb:1
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.8/gems/tugboat-0.2.0/bin/tugboat:8
    from /usr/local/bin/tugboat:19:in `load'
    from /usr/local/bin/tugboat:19

FATAL: all hosts have already failed -- aborting

This is probably related to ruby version/tugboat gem version updated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.